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
Sponsored
·
Your Podcast. Everywhere. Effortlessly.
Share. Educate. Inspire. Entertain. You do you. We'll handle the rest.
→
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
390
Evolving the World's Most Popular Programming Language
dherman
0
730
Closing iterators
dherman
0
840
A better future for comprehensions
dherman
0
2.1k
Evolution is Awesome
dherman
0
690
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.4k
Rust: low-level programming without the segfaults
dherman
13
9.1k
Other Decks in Programming
See All in Programming
仕様駆動開発の消費期限
watany
7
2.7k
Claude CodeとAgentCore Gatewayを繋ぐ際の認証認可 / Authentication and authorization when connecting Claude Code with AgentCore Gateway
har1101
1
180
全PRの83%がAIレビューだけでマージできるようになった開発組織はその後どうなったか
athug
1
1.4k
言語を使う側から、作る側へ。 自作 Lisp で得た新たな気づき。
andpad
0
150
freee が目指す データ マネジメント戦略 AI-Ready 時代を支える 攻めのガバナンスとは
freee
PRO
0
250
AIが無かった頃の素敵な出会いの話
codmoninc
1
380
今さら聞けない .NET CLI
htkym
0
180
AI時代に設計が 最大の生産性レバーになる 意図駆動開発とデータを消さない設計|Don't Delete Your Data or Your Intent — Design as the Deepest Lever in the AI Era
tomohisa
1
660
ビデオ通話が繋がる0.2秒で何が起きているのか
supurazako
2
170
信頼性について考えてみる(SRE NEXT 2026 miniLT)
hayama17
0
240
その節約、円になってますか?
isamumumu
1
680
Go言語とトイモデルで学ぶTransformerの気持ち / fukuokago23-transformer
monochromegane
0
160
Featured
See All Featured
Believing is Seeing
oripsolob
1
180
The Limits of Empathy - UXLibs8
cassininazir
1
590
Fight the Zombie Pattern Library - RWD Summit 2016
marcelosomers
234
17k
The AI Search Optimization Roadmap by Aleyda Solis
aleyda
1
6k
AI in Enterprises - Java and Open Source to the Rescue
ivargrimstad
0
1.4k
Bash Introduction
62gerente
615
220k
The State of eCommerce SEO: How to Win in Today's Products SERPs - #SEOweek
aleyda
2
11k
How People are Using Generative and Agentic AI to Supercharge Their Products, Projects, Services and Value Streams Today
helenjbeal
1
260
The Art of Programming - Codeland 2020
erikaheidi
57
14k
Why You Should Never Use an ORM
jnunemaker
PRO
61
9.9k
GitHub's CSS Performance
jonrohan
1033
470k
Game over? The fight for quality and originality in the time of robots
wayneb77
1
240
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