-
Notifications
You must be signed in to change notification settings - Fork 8
/
Copy pathindex.html
1299 lines (1066 loc) · 41.7 KB
/
index.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>The State of JavaScript</title>
<meta name="description" content="An easy to use CSS 3D slideshow tool for quickly creating good looking HTML presentations.">
<meta name="author" content="Hakim El Hattab">
<link href='http://fonts.googleapis.com/css?family=Chau+Philomene+One' rel='stylesheet' type='text/css'>
<link href='http://fonts.googleapis.com/css?family=Lato:400,700,400italic,700italic' rel='stylesheet' type='text/css'>
<link href='http://fonts.googleapis.com/css?family=Mate+SC' rel='stylesheet' type='text/css'>
<link href='http://fonts.googleapis.com/css?family=Trocchi' rel='stylesheet' type='text/css'>
<link href='http://fonts.googleapis.com/css?family=Open+Sans+Condensed:700' rel='stylesheet' type='text/css'>
<link rel="stylesheet" href="css/reset.css">
<link rel="stylesheet" href="css/main.css">
<link rel="stylesheet" href="lib/zenburn.css">
<link rel="stylesheet" href="css/jsvm.css">
<link rel="stylesheet" href="css/prism-dark.css" />
<script src="js/prism-es6.js"></script>
<style>
.orange .state-background {
background: #f1622f;
}
</style>
</head>
<body>
<div id="reveal">
<!-- Used to fade in a background when a specific slide state is reached -->
<div class="state-background"></div>
<!-- Any section element inside of this container is displayed as a slide -->
<div class="slides">
<section>
<h2 class="computer" style="color: #000; margin-bottom: 40px;">The State of JavaScript</h1>
<h3 class="inverted old-school">Brendan Eich / Strange Loop 2012</h3>
<img src="bb/assets/screenshots/09.jpg" height="420" width="672">
<script>
// Delicously hacky. Look away.
if( navigator.userAgent.match( /(iPhone|iPad|iPod|Android)/i ) )
document.write( '<p style="color: rgba(0,0,0,0.3); text-shadow: none;">('+'Tap to navigate'+')</p>' );
</script>
</section>
<section>
<h2>A very brief history</h2>
<div>
<ul>
<li>Ten days in May 1995: “Mocha”
<li>September 1995: “LiveScript”
<li>December 1995: “JavaScript”
<li>1996-1997: ECMA-262 Ed. 1, aka ES1
<li>1999: ES3: modern JS baseline
<li>2005: the Ajax revolution
<li>2008: ES4 RIP, Harmony founded in July
<li>2009: ES5: “use strict”, JSON, Object.create, etc.
<li>2012: ES6 under way: modules, let, proxies, etc.
</ul>
</div>
</section>
<section>
<h2>JS: Wat</h2>
<div style="position: relative; top: 50px;">
<img src="assets/images/wat.png">
<p><a href="https://www.destroyallsoftware.com/talks/wat">https://www.destroyallsoftware.com/talks/wat</a>
</div>
</section>
<section>
<section>
<h2>Wat Secrets Revealed</h2>
<div style="position: relative; top: 0px;">
<pre><code class="language-javascript">
js> {} + []
0
</code></pre>
</div>
</section>
<section>
<h2>Wat Secrets Revealed</h2>
<div style="position: relative; top: 0px;">
<pre><code class="language-javascript">
js> {}
js> + []
0
js> + ''
0
</code></pre>
</div>
</section>
<section>
<h2>Wat Secrets Revealed</h2>
<div style="position: relative; top: 0px;">
<pre><code class="language-javascript">
js> ({} + [])
"[object Object]"
</code></pre>
</div>
</section>
<section>
<h2>Wat Secrets Revealed</h2>
<div style="position: relative; top: 0px;">
<pre><code class="language-javascript">
js> {} + {}
NaN
</code></pre>
</div>
</section>
<section>
<h2>Wat Secrets Revealed</h2>
<div style="position: relative; top: 0px;">
<pre><code class="language-javascript">
js> {}
js> + {}
NaN
js> + '[object Object]'
NaN
</code></pre>
</div>
</section>
<section>
<h2>Wat Secrets Revealed</h2>
<div style="position: relative; top: 0px;">
<pre><code class="language-javascript">
js> ({} + {})
"[object Object][object Object]"
</code></pre>
</div>
</section>
<section>
<h2>Wat Secrets Revealed</h2>
<div style="position: relative; top: 0px;">
<pre><code class="language-javascript">
js> Array(16).join()
",,,,,,,,,,,,,,,"
</code></pre>
</div>
</section>
<section>
<h2>Wat Secrets Revealed</h2>
<div style="position: relative; top: 0px;">
<pre><code class="language-javascript">
js> Array(16).join().length
15
</code></pre>
</div>
</section>
<section>
<h2>Wat Secrets Revealed</h2>
<div style="position: relative; top: 0px;">
<pre><code class="language-javascript">
js> 'wat' - 1
NaN
</code></pre>
</div>
</section>
<section>
<img src="assets/images/jsfunge.png" height="591" width="1045">
</section>
</section>
<section>
<h2 style="position: relative; top: 150px;;">ES6 is coming</h2>
<div style="position: relative; top: 150px;">
<p> (JS evolves along with the rest of the web standards) </p>
</div>
</section>
<section>
<h2>ECMAScript Edition 6</h2>
<div style="position: relative; top: 50px;">
<p><a href="http://wiki.ecmascript.org/doku.php?id=harmony:harmony"><strong>Official goals</strong></a>: a better language for</p>
<ul>
<li><strong>applications</strong> <img src="assets/images/left-arrow.png" class="transparent" style="vertical-align: bottom; margin-left: 20px;" width=95 height=46></li>
<li>libraries</li>
<li>code generators</li>
</ul>
</div>
</section>
<section>
<h2>ECMAScript Edition 6</h2>
<div style="position: relative; top: 50px;">
<p><a href="http://wiki.ecmascript.org/doku.php?id=harmony:harmony"><strong>Official goals</strong></a>: a better language for</p>
<ul>
<li>applications</li>
<li><strong>libraries</strong> <img src="assets/images/left-arrow.png" class="transparent" style="vertical-align: bottom; margin-left: 20px;" width=95 height=46></li>
<li>code generators</li>
</ul>
</div>
</section>
<section>
<h2>Classes?!</h2>
<img src="assets/images/no-classes.jpg">
</section>
<section>
<h2>No class</h2>
<img src="assets/images/some-guys-have-no-class.jpg" height="384" width="576">
</section>
<section>
<section>
<h2>Maximally Minimal Classes</h2>
<pre><code class="language-javascript">
class SkinnedMesh extends THREE.Mesh {
constructor(geometry, materials) {
super(geometry, materials);
this.identityMatrix = new THREE.Matrix4();
this.bones = [];
this.boneMatrices = [];
...
}
update(camera) {
...
super.update();
}
}
</code></pre>
</section>
<section>
<h2>Instead of this mess</h2>
<pre><code class="language-javascript">
function SkinnedMesh(geometry, materials) {
SkinnedMesh.__super__.constructor
.call(this, geometry, materials);
this.identityMatrix = new THREE.Matrix4();
this.bones = [];
this.boneMatrices = [];
...
}
__extends(SkinnedMesh, THREE.Mesh)
SkinnedMesh.prototype.update = function (camera) {
...
SkinnedMesh.__super__.update.call(this);
}
</code></pre>
</section>
</section>
<section>
<h2>Modules</h2>
<pre><code class="language-javascript">
module FastMath {
export function sin() { /*...*/ }
export function cos() { /*...*/ }
}
import {sin, cos} from FastMath;
import $ from "http://js.com/jquery/1.8.1/jquery-min.js";
</code></pre>
</section>
<section>
<section>
<h2>Symbols</h2>
<pre><code class="language-javascript">
const cloneSym = new Symbol();
// Symbol names are guaranteed not to collide
Object.defineProperty(Object.prototype, cloneSym, {
value: function () {
// universal cloning code unobtainium here
}
});
var twin = obj[cloneSym]();
</code></pre>
</section>
<section>
<h2>Private Symbols</h2>
<pre><code class="language-javascript">
module Branding {
const brandSym = new Symbol(); // not exported
export function brand(obj, mark) {
if (!obj.hasOwnProperty(brandSym))
obj[brandSym] = mark;
}
export function hasBrand(obj, mark) {
return obj[brandSym] === mark;
}
}
</code></pre>
</section>
<section>
<h2>Symbol Syntax</h2>
<pre><code class="language-javascript">
public @clone;
Object.defineProperty(Object.prototype, @clone, {
value: function () {
// universal cloning code unobtainium here
}
});
var twin = obj.@clone();
</code></pre>
</section>
<section>
<h2>Private Symbol Syntax</h2>
<pre><code class="language-javascript">
module Branding {
private @brand; // not exported
export function brand(obj, mark) {
if (!obj.hasOwnProperty(@brand))
obj.@brand = mark;
}
export function hasBrand(obj, mark) {
return obj.@brand === mark;
}
}
</code></pre>
</section>
<section>
<h2>Private in Max/Min Classes</h2>
<pre><code class="language-javascript">
class SkinnedMesh extends THREE.Mesh {
private @identityMatrix,
@bones,
@boneMatrices;
constructor(geometry, materials) {
super(geometry, materials);
this.@identityMatrix = new THREE.Matrix4();
this.@bones = [];
this.@boneMatrices = [];
...
}
...
}
</code></pre>
</section>
<section>
<h2>Symbol Utilities</h2>
<pre><code class="language-javascript">
// Internal string name, for debugging and diagnostics
const myPublicSymbol = new Symbol("my public symbol");
// Binding initializers for renaming and full control
private @score = importedSharedSecrets.@score;
</code></pre>
</section>
</section>
<section>
<h2>Lots of other goodies</h2>
<img src="assets/images/cakes.jpg">
</section>
<section>
<h2>Default parameters</h2>
<pre><code class="language-javascript">
js> function f(a = 0, b = a * a, c = b * a) {
return [a, b, c];
}
js> f()
[0, 0, 0]
js> f(2)
[2, 4, 8]
js> f(2, 3)
[2, 3, 6]
js> f(2, 3, 4)
[2, 3, 4]
</code></pre>
</section>
<section>
<h2>Rest parameters</h2>
<pre><code class="language-javascript">
js> function f(a, b, ...r) {
print(Array.isArray(r));
return r.concat(a, b);
}
js> f(1, 2)
true
[1, 2]
js> f(1, 2, 3)
true
[3, 1, 2]
js> f(1, 2, 3, 4, 5)
true
[3, 4, 5, 1, 2]
</code></pre>
</section>
<section>
<h2>Spread</h2>
<pre><code class="language-javascript">
js> a = [3, 4, 5]
[3, 4, 5]
js> b = [1, 2, ...a]
[1, 2, 3, 4, 5]
js> function f(...r) { return r; }
js> function g(a) { return f(...a); }
js> g(a)
[3, 4, 5]
</code></pre>
</section>
<section>
<section>
<h2><code>for-of</code>, Iterators & Generators</h2>
<pre><code class="language-javascript">
js> for (var v of [1, 2, 3]) {
print(v)
}
1
2
3
</code></pre>
</section>
<section>
<h2>No Default Iterator</h2>
<pre><code class="language-javascript">
js> for (var [k, v] of {p: 3, q: 4, r: 5}) {
print(k, v)
}
typein:24:0 TypeError: ({p:3, q:4, r:5}) is not iterable
</code></pre>
</section>
<section>
<h2>Custom Iteration</h2>
<pre><code class="language-javascript">
js> Object.defineProperty(Object.prototype, @iterator, {
value: function () {
var obj = this;
var keys = Object.keys(obj);
var i = 0;
return {
next: function () {
if (i == keys.length) throw StopIteration;
var key = keys[i++];
return [key, obj[key]];
}
};
}
});
js> for (var [k, v] of {p:3, q: 4, r: 5}) print(k, v);
p 3
q 4
r 5
</code></pre>
</section>
<section>
<h2>Generators FTW</h2>
<pre><code class="language-javascript">
js> function* items(o) { // in ES6 standard library
for (var k in o) {
yield [k, o[k]];
}
}
js> for (var [k, v] of items({p:3, q: 4, r: 5})) {
print(k, v);
}
p 3
q 4
r 5
</code></pre>
</section>
<section>
<h2>Generator as Default Iterator</h2>
<pre><code class="language-javascript">
js> Object.defineProperty(Object.prototype, @iterator, {
value: items
});
js> for (var [k, v] of {p:3, q: 4, r: 5}) print(k, v);
p 3
q 4
r 5
</code></pre>
</section>
<section>
<h2>Callback Hell</h2>
<pre><code class="language-javascript">
load("config.json",
function(config) {
db.lookup(JSON.parse(config).table, username,
function(user) {
load(user.id + ".png", function(avatar) {
// <-- you could fit a cow in there!
});
}
);
}
);
</code></pre>
<a href="http://www.flickr.com/photos/fredo/128929221/sizes/q/in/photostream/"><img src="assets/images/cow-profile.jpg"></a>
</section>
<section>
<h2>Promises Purgatory</h2>
<pre><code class="language-javascript">
load("config.json")
.then(function(config) {
return db.lookup(JSON.parse(config).table);
})
.then(function(user) { return load(user.id + ".png"); })
.then(function(avatar) { /* ... */ });
</code></pre>
<img src="assets/images/string_on_finger.png">
</section>
<section>
<h2>Shallow Coroutine Heaven</h2>
<pre><code class="language-javascript">
import spawn from "http://taskjs.org/es6-modules/task.js";
spawn(function* () {
var config = JSON.parse(yield load("config.json"));
var user = yield db.lookup(config.table, username);
var avatar = yield load(user.id + ".png");
// ...
});
</code></pre>
</section>
<section>
<h2>Comprehensions</h2>
<pre><code class="language-javascript">
// Using depth-first search and constraint propagation,
// try all possible values.
function search(values) {
if (!values)
return false; // Failed earlier
if (all(values[s].length == 1 for (s in squares)))
return values; // Solved!
// Choose unfilled square s with fewest possibilities
let a = [values[s].length + s for (s in squares)
if (values[s].length > 1)]
.sort();
let s = a[0].slice(-2);
return some(search(assign(values.copy(), s, d))
for (d in values[s]));
}
</code></pre>
</section>
</section>
<section>
<section>
<h2>Map</h2>
<pre><code class="language-javascript">
js> var objkey1 = {toString: function(){return "objkey1"}}
js> var objkey2 = {toString: function(){return "objkey2"}}
js>
js> var map = Map([[objkey1, 42], [objkey2, true]])
js> map.get(objkey1)
42
js> map.get(objkey2)
true
js> assert(!map.has("objkey1") && !map.has("objkey2"))
</code></pre>
</section>
<section>
<h2>Map set & get</h2>
<pre><code class="language-javascript">
js> map.set(objkey1, 43)
js> map.get(objkey1)
43
</code></pre>
</section>
<section>
<h2>Map iteration, size</h2>
<pre><code class="language-javascript">
js> map.set("stringkey", "44!")
js> for (var [k, v] of map) {
print(k, v)
}
objkey1 43
objkey2 true
stringkey 44!
js> map.size()
3
</code></pre>
</section>
<section>
<h2>Map cycles</h2>
<pre><code class="language-javascript">
js> map.set(objkey2, objkey1)
js> map.set(objkey1, objkey2)
js> for (var [k, v] of map) {
print(k, v)
}
objkey1 objkey2
objkey2 objkey1
stringkey 44!
</code></pre>
</section>
<section>
<h2>Map delete</h2>
<pre><code class="language-javascript">
js> map.delete(objkey1)
true
js> map.delete(objkey1)
true
js> for (var [k, v] of map) {
print(k, v)
}
stringkey 44!
js> map.size()
1
</code></pre>
</section>
</section>
<section>
<section>
<h2>Set</h2>
<pre><code class="language-javascript">
js> var set = Set([1, true, "three"])
js> set.has(1)
true
js> set.has(2)
false
js> for (var e of set) {
print(e)
}
1
true
three
js> set.size()
3
</code></pre>
</section>
<section>
<h2>Set delete, iteration</h2>
<pre><code class="language-javascript">
js> set.delete("three")
true
js> for (var e of set) {
print(e)
}
1
true
js> set.size()
2
js> set.add("three")
js> set.size()
3
</code></pre>
</section>
<section>
<h2>Set add, has</h2>
<pre><code class="language-javascript">
js> var four = {toString: function(){return '4!'}}
js> set.add(four)
js> set.has(four)
true
js> for (var e of set) {
print(e)
}
1
true
three
4!
</code></pre>
</section>
</section>
<section>
<section>
<h2>WeakMap</h2>
<pre><code class="language-javascript">
js> var wm = WeakMap()
js> wm.set(objkey1, objkey2)
js> wm.set(objkey2, objkey1)
js> wm.has(objkey1)
true
js> wm.get(objkey1)
({toString:(function (){return "objkey2"})})
js> wm.has(objkey2)
true
js> wm.get(objkey2)
({toString:(function () {return 'objkey1'})})
</code></pre>
</section>
<section>
<h2>WeakMap, not LeakMap</h2>
<pre><code class="language-javascript">
js> gc()
"before 286720, after 282720\n"
js> objkey1 = null
null
js> wm.get(objkey2)
({toString:(function () {return 'objkey1'})})
js> objkey2 = null
null
js> gc()
"before 286720, after 282624\n"
</code></pre>
</section>
</section>
<section>
<section>
<h2>Proxy</h2>
<pre><code class="language-javascript">
js> var MethodSink = Proxy({}, {
has: function(target, name) { return true; },
get: function(target, name, receiver) {
if (name in Object.prototype) {
return Object.prototype[name];
}
return function(...args) {
return receiver.__noSuchMethod__(name, args);
}
}
});
</code></pre>
</section>
<section>
<h2>Default __noSuchMethod__</h2>
<pre><code class="language-javascript">
js> Object.defineProperty(
Object.prototype,
'__noSuchMethod__',
{
configurable: true,
writable: true,
value: function(name, args) {
throw new TypeError(name + " is not a function");
}
}
);
</code></pre>
</section>
<section>
<h2>Using __noSuchMethod__</h2>
<pre><code class="language-javascript">
js> var obj = {
foo: 1 ,
__proto__: MethodSink,
__noSuchMethod__: function(name, args) {
return name;
}
}
js> obj.foo
1
js> obj.bar()
"bar"
js> obj.toString
function toString() {
[native code]
}
</code></pre>
</section>
<section>
<h2>Proxying __noSuchMethod__</h2>
<pre><code class="language-javascript">
js> obj.bar
(function (...args) {
return receiver.__noSuchMethod__(name, args);
})
js> var thunk = obj.bar
js> thunk()
"bar"
</code></pre>
</section>
</section>
<section>
<h2>ECMAScript Edition 6</h2>
<div style="position: relative; top: 50px;">
<p><a href="http://wiki.ecmascript.org/doku.php?id=harmony:harmony"><strong>Official goals</strong></a>: a better language for</p>
<ul>
<li>applications</li>
<li>libraries</li>
<li><strong>code generators</strong> <img src="assets/images/left-arrow.png" class="transparent" style="vertical-align: bottom; margin-left: 20px;" width=95 height=46></li>
</ul>
</div>
</section>
<section>
<h2>Why compile to JS?</h2>
<ul class="altjs">
<li><img src="assets/images/coffeescript.png" width=138 class="transparent minicoffee" /> – lightweight syntax, conveniences
<li><img src="assets/images/clojure-logo10.png" width=150 class="transparent" /> – macros, uniform data abstraction (incl. DOM)
<li><img src="assets/images/roy.jpg" width=150 class="transparent" /> – pattern matching, types
<li><img src="assets/images/adsafe.gif" width=150 class="transparent" /> – security, isolation
<li><img src="assets/images/tamejs.png" width=150 class="transparent" /> – synchronous style events
<li>More at <a href="http://altjs.org/">altjs.org</a>
</ul>
</section>
<section>
<img src="assets/images/shanselman.png">
<img src="assets/images/shanselman-headshot.jpg" class="transparent" style="position: relative; top: 60px; left: -130px; box-shadow: 0px 3px 5px rgba(0, 0, 0, 0.3);">
</section>
<section>
<img height="450" width="600" src="assets/images/yunhbc.png">
</section>
<section>
<img style="position: relative; top: 100px; border: solid 1px lightgray;" class="transparent" src="assets/images/applet-loading.png" />
<img style="position: relative; top: -80px; left: -170px;" class="transparent" src="assets/images/sbbod.gif" />
</section>
<section>
<div style="position: relative; top: 150px;">
<blockquote>We had always thought that Java's JVM would be the VM of the web, but it turns out that it's JavaScript. JavaScript's parser does a more efficient job... than the JVM's bytecode verifier.</blockquote>
<p class="attribution">— <a href="http://www.hanselman.com/blog/JavaScriptIsAssemblyLanguageForTheWebPart2MadnessOrJustInsanity.aspx">Doug Crockford</a></p>
</div>
</section>
<section>
<h2>JS > bytecode</h2>
<ul>
<li>Dynamic typing ⇒ no verification
<li>Type inference ⇒ delayed optimization
<li>Would bytecode compress as well?
<li>Bytecode standardization would suck
<li>Bytecode versioning would suck more
<li>Low-level bytecode is future-hostile
<li>Many humans like writing JS
</ul>
</section>
<section>
<h2>One JS, for humans <u>and</u> computers</h2>
<img src="assets/images/yinyang.gif" width=300 class="transparent" style="position: relative; top: 50px;" />
</section>
<section>
<section>
<h2>Example: goto</h2>
<pre style="position: relative; top: 100px;"><code contenteditable>
function f() {
L0:
g();
L1:
if (p)
goto L0;
o.m();
goto L1;
}
</code></pre>
</section>
<section>
<img style="position: absolute; left: -120px; top: 320px;" src="assets/images/dijkstra.jpg" height=300 />
<h2>goto considered...</h2>
<ul style="position: relative; top: 100px;">
<li><b>Compilers:</b> yes please!
<li><b>Humans:</b> DO NOT WANT
</ul>
</section>
<section>
<h2>Better: proper tail calls</h2>
<pre style="position: relative; top: 50px;"><code contenteditable>
function f() {
function L0() {
g();
return L1(); // goto with arguments
}
function L1() {
if (p)
return L0(); // goto with arguments
o.m();
return L0(); // goto with arguments
}
return L0(); // goto with arguments
}
</code></pre>
<p style="position: relative; top: 80px;"><a href="http://wiki.ecmascript.org/doku.php?id=harmony:proper_tail_calls">ES6 proposal</a></p>
</section>
</section>
<section>
<h2 style="position: relative; top: 150px; line-height: 1.2em;">Cool story.<br/>But compared to native...</h2>
</section>
<section>
<img class="transparent" src="assets/images/nacl-rocks.jpg" width=1280 style="position: absolute; top: -100px; left: -190px; padding: 0; margin: 0;" />
<h1 style="color: white; position: relative; top: 50px;">NaCl?</h1>
<ul style="position: absolute; top: 400px; left: 50px;">
<li style="color: #008000;">Impressive engineering
<li style="color: #008000;">Driving competition
</ul>