spacer

The Future of JavaScript – take a peek today!

Friday, February 10, 2012

Labels: javascript

The ECMA committee is working hard on designing the next version of JavaScript, also known as "Harmony". It is due by the end of next year and it is going to be the most comprehensive upgrade in the history of this language.

Chrome and V8 are committed to pushing JavaScript forward and have already started implementing the new features. You can try some of them today in the latest dev channel release. Here’s a summary:

  • Lexical scoping. Now "let" is the new "var" – traditional "var" declarations are complemented with "let" and "const". Both are properly block-scoped bindings, eliminating a common source of errors and weird behaviour. Function declarations are now officially allowed in local scope as well, and also obey lexical scoping. (Note: Lexical scoping is only available in ES strict mode.)
  • Collections. Efficient maps and sets will make your life easier. Any value can be used as a key or element, including objects. No surprises, no more need to abuse objects as dictionaries. (Caveat: Iteration over collections is not yet specified.)
  • Weak maps. A special kind of map for which the garbage collector determines when a key is no longer reachable, so that the key-value pair can be removed from the map automatically. This goes a long way towards avoiding memory leaks in long-lived tables and relieves the developer from worrying about stale entries.
  • Proxies. A proxy simulates a JavaScript object or function, and can customize just about any aspect of their behaviour that you can imagine. This is a real power feature, that takes reflection to a new level and can be used to implement various advanced abstractions and interfaces. 
 ...and there is a lot more to come, as the V8 team will continue working on bringing new Harmony features to you.

To enable Harmony features in the latest dev channel release of Chrome, go to chrome://flags and toggle on "Experimental JavaScript features". We encourage you to try them out and give us feedback!

Posted by Andreas Rossberg and Michael Starzinger, Software Engineers

6 comments:

Darth said...

Is it possible to get a script include (non third party, but directly from Chrome team, so that it matches how and when V8 develops the new features) on browsers that dont have the matching experimental versions of javascript/syntax to have better interoperability? Like a shim. I think there are a couple of random ones floating on the web/github but far from useful. Unless people only use Chrome, it will be hard to justify use of the new proposals unless we can get some way to start writing code with a script include.

Mentifex said...

The truest, most awesome future of JavaScript is artificial intelligence, in English, in Russian, and in other languages. JavaScript initiates the basic AI for other programming languages to pick up and run with.

russell.milliner said...

When will these features make their way into Google App Script?

Christopher Smith said...

The binary data stuff strikes me as the biggest news of them all. JavaScript is a very odd language in it's lack of standard binary data processing support.

Phil said...

So, would there be anyway to make this stuff work in Internet Explorer. Surely, it won't be native until, at least, version 11.

Jonathan @ jadbox.com said...

Can't we just make Coffeescript a native browser language? ;)

Older Post Home

gipoco.com is neither affiliated with the authors of this page nor responsible for its contents. This is a safe-cache copy of the original web site.