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
The Future of JavaScript
Search
Sponsored
·
SiteGround - Reliable hosting with speed, security, and support you can count on.
→
dherman
April 20, 2012
Programming
8.6k
52
Share
Embed
Copy iframe code
Copy JS code
Copy link
Start on current slide
The Future of JavaScript
SFRails, 4/19/12
dherman
April 20, 2012
More Decks by dherman
See All by dherman
Rust + Node = Neon
dherman
1
380
Evolving the World's Most Popular Programming Language
dherman
0
720
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
net-httpのHTTP/2対応について
naruse
0
480
JavaDoc 再入門
nagise
0
320
Claspは野良GASの夢をみるか
takter00
0
190
New "Type" system on PicoRuby
pocke
1
850
メソッドのジェネリクスでGoの夢は広がるか? / Kyoto.go #65
utgwkk
3
720
IBM Bobを活用したレガシーアプリの最新化
oniak3ibm
PRO
1
190
AI時代のUIはどこへ行く?その2!
yusukebe
21
7.1k
Spec Driven Development | AI Summit Lisbon
danielsogl
PRO
0
180
LLM本来の能力を解き放つサンドボックス技術とAI民主化への適用
yukukotani
3
3.7k
Datadog × OpenTelemetry 入門と実践のあいだ
kn_to_maxpno
1
150
The ROI of Quarkus for Spring Boot Applications
hollycummins
0
110
「AIで開発し、AIを届ける」をEvalでつなぐ 〜AIネイティブに始めるプロダクト開発の実践〜 / Connecting "Develop with AI, deliver AI" with Eval
rkaga
4
5k
Featured
See All Featured
Thoughts on Productivity
jonyablonski
76
5.2k
Designing Powerful Visuals for Engaging Learning
tmiket
1
410
Utilizing Notion as your number one productivity tool
mfonobong
4
320
Unsuck your backbone
ammeep
672
58k
Mozcon NYC 2025: Stop Losing SEO Traffic
samtorres
1
250
Abbi's Birthday
coloredviolet
2
8k
[RailsConf 2023 Opening Keynote] The Magic of Rails
eileencodes
31
10k
Designing Dashboards & Data Visualisations in Web Apps
destraynor
231
55k
Lightning Talk: Beautiful Slides for Beginners
inesmontani
PRO
2
570
The Limits of Empathy - UXLibs8
cassininazir
1
360
The Art of Delivering Value - GDevCon NA Keynote
reverentgeek
16
2k
Collaborative Software Design: How to facilitate domain modelling decisions
baasie
1
250
Transcript
THE FUTURE => OF JAVASCRIPT Dave Herman
Hi, I’m dherman @littlecalculist
I — JavaScript and I love the language it almost
is...
None
None
modules • block scoping • generators • proxies • binary
data • destructuring • rest-args & defaults • name objects • custom iteration • comprehensions • string templates • hash tables & weak maps • class syntax • full Unicode • function/object shorthands tl;dr:
Great libraries need modules
var Collections = (function() { function Dict()
{ ... } return { Dict: Dict }; })();
None
browser <script></script>
“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
Generators cleaning up callback spaghetti
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; }); promise
Binary data efficient memory layout and I/O
var Point2D = struct({ x: uint32,
y: uint32 }); var Color = struct({ r: uint8, g: uint8, b: uint8 });
var Pixel = struct({ point: Point2D,
color: Color }); var Triangle = array(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 } } ])
Name objects first-class, unique property keys
function Container() { var secret = 3;
this.service = function() { if (secret-‐-‐) { ... } }; }
var key = new Name("secret"); function Container() { this[key] =
3 } Container.prototype = { service: function() { if (this[key]-‐-‐) { ... } } };
Familiar friends… should be no surprise for Rubyists
Destructuring: var [x, y] = getPair(); Parameter defaults: function(x=0, y=0)
{ } Rest/splat: function(...args) { return args } Iterators: for (x of keys(obj)) { } String interpolation: `Hello ${username}!`
The 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
[email protected]
Work in the open wiki.ecmascript.org
[email protected]
Thank you.