David Herman on ECMAScript.next

David Herman has posted a video of his talk on what he calls ECMAScript.next, the next version of JavaScript. Others call it “JavaScript Harmony”. It nicely complements my recent post on Brendan Eich’s ideas for Harmony [1], with a little overlap, but not much.

Roadmap for ECMAScript.next:

Spring 2011: proposal freeze (no more proposals allowed)

2013 (roughly): spec finished, parts will be in browsers before that.

opt-in via MIME type in script tag: <script type="application/javascript;version=next"> (where “next” is a placeholder for something that has still to be determined)

Broad themes:

Fixes: removing quirks

Expressiveness: support better, more concise idioms

Power: doing what couldn’t previously be done

Fixes

Eliminate the arguments variable:

function foo(x, y, ...rest) {
this.bar(...rest);
}

Extending typeof: "null" for null (currently "object")

Don’t auto-create global variables (already in strict mode [2])

Block-scoping, not function-scoping [3], via let (“let is the new var”)

Expressiveness

Sharp functions. [As an aside, these could also be called “pounders” from “pound sign” or “hash functions” (but: already used in the context of hashing).]

Old: var sizes = elts.map(function(elt) { return elt.size() });

New: var sizes = elts.map(#(elt) { elt.size() }) // implicit return

Non-methods don’t have implicit this argument, any more. Must declare explicitly that you expect this in sharp functions.