ECMAScript 6: new OOP features besides classes
2ality.com
2ality.com
Then wait for v8 performance: http://jsperf.com/performance-frozen-object ES5 is doing good...
And at last: Wait for < IE-11 to die.
It remains to be seen if io.js will boosts ES Next for the server. Since bound to v8 i don't expect much.
Other implementations like the ahead of time compiler echojs become interesting. I am also curious how Typescript will look at v2.0.
I am ready, however I still don't use arrow functions... Which were first heard of in 2010? 2011?
It still feels like so far away.
On the other hand, there are already a few decent solutions for transpiling ECMAScript 6 to ES5 [1]:
* Traceur (there are Traceur-based plugins for Grunt, Gulp, browserify, webpack, etc.): https://github.com/google/traceur-compiler
* 6to5: https://6to5.org/
* es6-transpiler.js: https://github.com/termi/es6-transpiler
Using those tools results in a workflow that is much like using CoffeeScript.
Nearly every JavaScript ecosystem has a class pattern. Ember, Angular, YUI, React, MooTools etc. All of them are incompatible.
A spec gives us a common target to iterate toward, even if we need to get there via transpilers. Just like standardizing on Promises means I can consume jQuery's ajax method without learning a new callback syntax, ES6 classes will mean I don't need to learn a new API for extending a parent class in every framework.
The Ember community has had amazing success adopting ES6 modules despite there being no browser support at all. I expect any framework would have a similar success story with classes.
Generators are indeed being prioritized over classes and inheritance; the former is starting to see support in browsers but there's no sign of the latter.
The async-await keywords are not in ES6, but they are trivial to mimic with generators and promises if you so desire.
>Even block scoping I mean maybe I'm nuts but function scoping if you take the time to understand it, it works.
Block scoping introduces no new pitfalls (unless you count learning two new keywords a pitfall). It does however eliminate two classes of bugs - redeclaring a var with the intent of shadowing the previous one but actually overwriting it, and using a var outside of a scope where it has a legal value. I'd say it's worth it.
Yes, if you can use `let`, there is no reason whatsoever to use `var` ever again.
If you want the `var` behavior, just put your declaration at the very top of the innermost function. With most code conventions, that's where you'd put a `var` declaration anyways.
For what it's worth, Crockford also recommended to use `let` exclusively as soon as you can.
- Classes (except inheritance requires a tiny shim function)
- Destructuring (except destructuring iterators)
- Rest parameters
- Arrow functions
- Shorthand object literals
- Computed properties
- Template strings (although tagged template strings require a non-trivial amount of shimming to mimic)
- let and const (check correctness before transpiling, then compile to var. Transformation is non-trivial when inside loops, etc.)
- Modules
Features that do require a runtime / library:
- Iterators and generators
- Promises
- Symbols
- New ES6 methods on Object, Number, String, etc. (like Number.isNaN)
Although we already have C++.
In JS there are a lot of other stuff to fix before adding syntax. (non commutativity of ==).
But adding stuff like macro, confusing multiline chars it looks like a hell to maintain to me.
Hours of painfully finding what could have triggered the bug!
The code? The macro? Is this a ' or a ` ? ....
Hell, this is hell coming on us my fellow grunt programmers.