JavaScript por debaixo dos panos1. JavaScript
por debaixo dos panos
ecossistema e linguagem na perspectiva da JVM
@qmx
http://blog.qmx.me/
Saturday, May 14, 2011
23. “mais de um
jeito de fazer”
Consultor Sênior
Saturday, May 14, 2011
26. “Ringo takes a pragmatical
and non-dogmatic stance on
things like I/O paradigms.”
Saturday, May 14, 2011
27. DTSTTCPW
Faça a coisa mais simples
possível com potencial de
funcionar
Saturday, May 14, 2011
31. ➜ rhino1_7R3 java -jar js.jar
Rhino 1.7 release 3 2011 05 10
js> date = new java.util.Date();
Thu May 12 11:12:24 BRT 2011
Saturday, May 14, 2011
48. Vantagens
e
Desvantagens
Saturday, May 14, 2011
53. 1 function Carro(nome, cor) {
2 this.nome = nome;
3 this.cor = cor;
4 this.anda = function(){
5 print("andando");
6 }
7 }
8
9 var x = new Carro("trovão azul", "azul (duh)");
10 x.anda();
Saturday, May 14, 2011
54. 1 function Carro(nome, cor) {
2 this.nome = nome;
3 this.cor = cor;
4 this.anda = function(){
5 print("andando");
6 }
7 }
8
9 var x = new Carro("trovão azul", "azul (duh)");
10 x.anda();
Saturday, May 14, 2011
55. 1 function MotorV8(){
2 this.liga = function(){
3 print("ligando...");
4 }
5 }
Saturday, May 14, 2011
56. 7 function Carro(nome, cor) {
8 this.nome = nome;
9 this.cor = cor;
10 this.motor = new MotorV8();
11 this.anda = function(){
12 print("andando");
13 }
14 this.liga = function(){
15 this.motor.liga();
16 }
17 }
Saturday, May 14, 2011
57. 19 var x = new Carro("trovão azul", "azul (duh)");
20
21 for(var i = 0; i< 10000; i++){
22 x.liga();
23 }
Saturday, May 14, 2011
58. 19 var x = new Carro("trovão azul", "azul (duh)");
20
21 for(var i = 0; i< 10000; i++){
22 x.liga();
23 }
Saturday, May 14, 2011
60. 19 var x = new Carro("trovão azul", "azul (duh)");
20
21 for(var i = 0; i< 10000; i++){
22 print(“ligando...”);
23 }
Saturday, May 14, 2011
62. 1 function MotorV8(){
2 this.liga = function(){
3 print("ligando...");
4 }
5 }
Saturday, May 14, 2011
63. 7 function Carro(nome, cor) {
8 this.nome = nome;
9 this.cor = cor;
10 this.motor = new MotorV8();
11 this.anda = function(){
12 print("andando");
13 }
14 this.liga = function(){
15 this.motor.liga();
16 }
17 }
Saturday, May 14, 2011
64. 19 var x = new Carro("trovão azul", "azul (duh)");
20
21 for(var i = 0; i< 10000; i++){
22 print(“ligando...”);
23 }
Saturday, May 14, 2011
71. JVM
no máximo 256 opcodes
Saturday, May 14, 2011
75. ldc #9
Saturday, May 14, 2011
76. ldc #9 // “Hello World”
Saturday, May 14, 2011
77. ldc #9 // “Hello World”
getstatic
Saturday, May 14, 2011
78. ldc #9 // “Hello World”
getstatic #15
Saturday, May 14, 2011
79. ldc #9 // “Hello World”
getstatic #15 // System.out
Saturday, May 14, 2011
80. ldc #9 // “Hello World”
getstatic #15 // System.out
swap
Saturday, May 14, 2011
81. ldc #9 // “Hello World”
getstatic #15 // System.out
swap
invokevirtual
Saturday, May 14, 2011
82. ldc #9 // “Hello World”
getstatic #15 // System.out
swap
invokevirtual #21
Saturday, May 14, 2011
83. ldc #9 // “Hello World”
getstatic #15 // System.out
swap
invokevirtual #21 // PrintWriter.println()
Saturday, May 14, 2011
84. ldc #9 // “Hello World”
getstatic #15 // System.out
swap
invokevirtual #21 // PrintWriter.println()
return
Saturday, May 14, 2011
107. function
identifier
Saturday, May 14, 2011
108. function
identifier
formal parameter list
Saturday, May 14, 2011
109. function
identifier
formal parameter list
function body
Saturday, May 14, 2011
112. n body function body functio
n body function body functio
n body function body functio
n body function body functio
n body function body functio
Saturday, May 14, 2011
113. JavaScript
===
um monte de blocos
executáveis
Saturday, May 14, 2011
116. JDK7
(prevista pra 7/7)
Saturday, May 14, 2011
130. dyn.js
100% invokedynamic js impl
Saturday, May 14, 2011
132. “Anyway, I know only one
programming language worse
than C and that is JavaScript”
Robert Caillau
Saturday, May 14, 2011