Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Features
Speaker Deck
PRO
Sign in
Sign up for free
Search
Search
So bright it burns
Search
dherman
November 04, 2011
Programming
250
3
Share
Embed
Copy iframe code
Copy JS code
Copy link
Start on current slide
So bright it burns
My YUIConf 2011 keynote
dherman
November 04, 2011
More Decks by dherman
See All by dherman
Rust + Node = Neon
dherman
1
380
Evolving the World's Most Popular Programming Language
dherman
0
710
Closing iterators
dherman
0
830
A better future for comprehensions
dherman
0
2.1k
Evolution is Awesome
dherman
0
670
Status Report: ES6 Modules
dherman
16
4.1k
Discussion with TC39 about the semantics of symbols
dherman
1
450
September 2013 Modules Status Update
dherman
2
1.3k
Rust: low-level programming without the segfaults
dherman
13
9.1k
Other Decks in Programming
See All in Programming
メソッドのジェネリクスでGoの夢は広がるか? / Kyoto.go #65
utgwkk
3
610
セキュリティの専門家じゃなくてもできる。「セキュリティ意識」をアップデートして サプライチェーン攻撃への耐性を高めよう。
tk3fftk
5
660
AIエージェントと協働するCLI開発 — BunとOpenClawで学んだこと
yoshikouki
1
240
IBM Bobを活用したレガシーアプリの最新化
oniak3ibm
PRO
1
180
Webフレームワークの ベンチマークについて
yusukebe
0
150
The NotImplementedError Problem in Ruby
koic
1
650
キャリア迷子上等 ─ "ない道"は自分で作ればいい
16bitidol
3
1.8k
AIとRubyの静的型付け
ukin0k0
0
550
JJUG CCC 2026 Spring: JSpecify で実現する Kotlin フレンドリーな Java API 設計
ternbusty
1
150
These Five Tricks Can Make Your Apps Greener, Cheaper, & Nicer
hollycummins
0
280
AI時代の仕事技芸論 — ソフトウェア開発で「遊ぶように働く」職人的熟達のすすめ
kuranuki
1
630
Inside Stream API
skrb
1
650
Featured
See All Featured
What does AI have to do with Human Rights?
axbom
PRO
1
2.2k
The Illustrated Children's Guide to Kubernetes
chrisshort
51
52k
Information Architects: The Missing Link in Design Systems
soysaucechin
0
960
Max Prin - Stacking Signals: How International SEO Comes Together (And Falls Apart)
techseoconnect
PRO
0
180
Thoughts on Productivity
jonyablonski
76
5.2k
AI: The stuff that nobody shows you
jnunemaker
PRO
8
690
[Rails World 2023 - Day 1 Closing Keynote] - The Magic of Rails
eileencodes
38
2.9k
Designing Powerful Visuals for Engaging Learning
tmiket
1
400
Producing Creativity
orderedlist
PRO
348
40k
WCS-LA-2024
lcolladotor
0
620
Getting science done with accelerated Python computing platforms
jacobtomlinson
2
220
JAMstack: Web Apps at Ludicrous Speed - All Things Open 2022
reverentgeek
1
460
Transcript
THE FUTURE OF JAVASCRIPT SO BRIGHT IT BURNS
Hi, I’m dherman @littlecalculist
I — JavaScript and I love the language it almost
is...
None
None
tl;dr
TIER 1 AWESOMENESS modules • block scoping • generators •
proxies • binary data • destructuring • rest-args & defaults TIER 2 AWESOMENESS name objects • custom iteration • comprehensions • string templates • hash tables & weak maps
Great languages deserve great libraries and that means modules
None
browser <script></script>
var Collections = (function() { function Dict()
{ ... } return { Dict: Dict }; })();
“The human compiler, at work.” — Paul Graham “The sincerest
form of feature request.” — someone?
module Collections { export function Dict() {
... } }
import { $ } from "jquery.js"; import { map, each
} from "underscore.js";
import { $ } from "jquery.js"; import { map, each
} from "underscore.js"; loaded once, before execution
let is the new var block scoping (at long, long
last)
for (i = 0; i < a.length; i++) {
var x = a[i]; x.onclick = function() { x.toggle() }; }
for (i = 0; i < a.length; i++) {
let x = a[i]; x.onclick = function() { x.toggle() }; }
Generator functions an alternative to callback spaghetti
function* counter() { yield 1;
yield 2; yield 3; } var g = counter(); alert(g.next()); // 1 alert(g.next()); // 2 alert(g.next()); // 3
XHR("foo.txt", function(foo) { XHR("bar.txt", function(bar) {
XHR("baz.txt", function(baz) { setTimeout(function() { status.innerHTML = foo + bar + baz; }, 1000); }); }); });
XHR("foo.txt", function(foo) { XHR("bar.txt", function(bar) {
XHR("baz.txt", function(baz) { setTimeout(function() { status.innerHTML = foo + bar + baz; }, 1000); }); }); }); pyramid of doom
function onTimeout(foo, bar, baz) { status.innerHTML =
foo + bar + baz; } XHR("foo.txt", function(foo) { XHR("bar.txt", function(bar) { XHR("baz.txt", function(baz) { setTimeout(function() { onTimeout(foo, bar, baz); }, 1000); }); }); });
function onTimeout(foo, bar, baz) { status.innerHTML =
foo + bar + baz; } function onBaz(foo, bar, baz) { setTimeout(function() { onTimeout(foo, bar, baz); }, 1000); } XHR("foo.txt", function(foo) { XHR("bar.txt", function(bar) { XHR("baz.txt", function(baz) { onBaz(foo, bar, baz); }); }); });
function onTimeout(foo, bar, baz) { status.innerHTML =
foo + bar + baz; } function onBaz(foo, bar, baz) { setTimeout(function() { onTimeout(foo, bar, baz); }, 1000); } function onBar(foo, bar) { XHR("baz.txt", function(baz) { onBaz(foo, bar, baz); }); } XHR("foo.txt", function(foo) { XHR("bar.txt", function(bar) { onBar(foo, bar); }); });
function onTimeout(foo, bar, baz) { status.innerHTML =
foo + bar + baz; } function onBaz(foo, bar, baz) { setTimeout(function() { onTimeout(foo, bar, baz); }, 1000); } function onBar(foo, bar) { XHR("baz.txt", function(baz) { onBaz(foo, bar, baz); }); } function onFoo(foo) { XHR("bar.txt", function(bar) { onBar(foo, bar); }); } XHR("foo.txt", onFoo);
Pour 1/2 cup water into pan. When you’re done: Bring
water to boil. When that’s done: Lower heat and add rice. After 15 minutes: Turn off heat and serve.
spawn(function*() { var foo = yield read("foo.txt"),
bar = yield read("bar.txt"), baz = yield read("baz.txt"); yield sleep(1000); status.innerHTML = foo + bar + baz; });
Proxies meta-programming for fun and profit
var p = new Proxy(obj, { get:
function(...) { ... }, set: function(...) { ... }, delete: function(...) { ... }, ... });
Bits, bytes and blobs binary file and network I/O
var Point2D = new StructType({ x: uint32,
y: uint32 }); var Color = new StructType({ r: uint8, g: uint8, b: uint8 });
var Pixel = new StructType({ point: Point2D,
color: Color }); var Triangle = new ArrayType(Pixel, 3);
new Triangle([ { point: { x: 0,
y: 0 }, color: { r: 255, g: 255, b: 255 } }, { point: { x: 5, y: 5 }, color: { r: 128, g: 0, b: 0 } }, { point: { x: 10, y: 0 }, color: { r: 0, g: 0, b: 128 } } ])
Destructuring try it, you’ll like it
var { r, g, b } = thing.color; var [x,
y] = circle.center; [a, b] = [b, a];
function div({ width, height, border }) {
... }
Rest-args and defaults death to the arguments object!
function f(i, j, ...rest) { return rest.slice(i,
j); }
array.push(thing1, thing2, ...moarThings); var shape = new Shape(...points);
function img(src, width=320, height=240) { ... }
function img({ src,
width=320, height=240 }) { ... }
Name objects first-class, unique property keys
function Container() { var secret = 3;
this.service = function() { if (secret-‐-‐) { ... } }; }
var key = Name.create("secret"); function Container() { this[key] = 3
} Container.prototype = { service: function() { if (this[key]-‐-‐) { ... } } };
Custom object iteration taming the for-in loop
for (x in [3, 4, 5])
// 0, 1, 2 (d’oh) for (x of [3, 4, 5]) // 3, 4, 5 for (x of keys(o)) // keys in o for (x of values(o)) // values of o for ([k, v] of items(o)) // props of o
import iterate from "@iter"; obj[iterate] = function() {
return { next: function() { ... } } } for (x of obj) { ... }
Comprehensions beautiful array processing
[ x * y for (x of obj1) for (y
of obj2) ] ( x * y for (x of obj1) for (y of obj2) )
String templates untangling string formatting code
"<p>\nohai, " + firstName + " " + lastName +
"\n</p>"
`<p> ohai, ${firstName} ${lastName} </p>`
safeHTML`<p> ohai, ${firstName} ${lastName} </p>`
Object-keyed tables hash tables and weak maps
var scores = new Map(); var player1 = { ...
}; scores.set(player1, 0); scores.get(player1) // 0
var markers = new WeakMap(); var tile = new Tile(...);
var results = [...]; tiles.set(tile, results);
There is a bigger picture.
“Be a better language for: a. complex apps b. libraries
c. code generators”
Motivated by use cases. Solve with simple, general, composable features.
Pieces have to fit together in a cohesive whole.
study the issues study the big picture study the issues
again study the big picture again study the issues again SHIP IT!
Work in the open wiki.ecmascript.org es-discuss
How soon is now?
We (Ecma) are working hard and fast on the spec.
We (vendors) are prototyping and shipping features now. Transpilers as language shims: Traceur, Narcissus
None