An update on strong mode(groups.google.com) |
An update on strong mode(groups.google.com) |
This has been my suspicion for a while. Perhaps I've missed other comments to this effect, but I don't think I've heard anyone else articulate it.
In general, we will focus on improving the performance of the most-used features first. Arrow functions, generators, etc. are high on the list.
[0]: https://twitter.com/addyosmani/status/699976753255751681
(Disclaimer: I'm a PM on the V8 team)
I have noticed that none of the features I'd hoped would save cycles (const, generators, fat arrow functions) seem to be helping at all in the browsers of today.
Of course, it may be that some ES6 features will still be slow even after they've been optimized for, but right now, as a practical matter, I think ES6 is slow simply because the engines don't yet optimize it.
I believe ES6 fat arrow functions are slow for a similar reasons as why regular functions are slow when you use the magic arguments variable.
Arrow functions seem like they would take (marginally) longer to parse than explicit function declarations due to having a more verbose AST that does not start with unambiguous tokens. That, and you have the implicit this binding which must come with a cost. Again, in time this might be okay.
Because right now there isn't enough cross-browser ES6 support to be able to use it reliably with compilation; given that the compilation procedure is easy and relatively pain-free (at least until you see the horrifying code that Babel produces when you ask it to transpile generators), I'm wondering how much of an issue ES6 performance is in the real world.
Strong mode is "a new language mode (an extension of strict mode) that implements a stronger semantics by removing brittle or costly features."
https://developers.google.com/v8/experiments
The conclusion is that "we have reluctantly decided not to pursue strong mode further."
Not all is lost. We continue to investigate the addition of types to V8. And in fact, typing may bring some of the benefits of strong mode for lower cost.
...probably have us readjust our design goals. In particular, we no longer believe that requiring type soundness _by default_ can ever work successfully in JavaScript.
TAKE-AWAY
Considering all that, we have reluctantly decided not to pursue strong mode further. We learned some worthwhile lessons, but overall it is not clear that the benefits justify the costs. Starting with the next version of V8, we will hence remove support for strong mode.
tl;dr we're changing engines mid-flight and that has as much to do with performance differences as the ES6 features themselves.
[0]: http://blog.chromium.org/2010/12/new-crankshaft-for-v8.html [1]: http://v8project.blogspot.com/2015/07/digging-into-turbofan-...
But I think that in ES6 without eval you can't refer to the current scope in a dynamic way; which means that the engine can resolve bindings at compile time without worrying about people fiddling with scopes behind the scenes, which should simplify optimisation a lot.