161 points · by tilt · 9y ago · 38 comments
Looking at the destructuring example, it seems like part of the problem is that the new constructs are actually more general, since their semantics are defined in terms of iterators in order to support user defined types... I guess, on the other hand, this still allows for better overall system performance (e.g. one can now pass lazy-evaluated transformations instead of producting new arrays all the time when writing functional-style code.). An alternative would be to have sepparate syntax [a, b, c...] for arrays and (a, b, c...) for iterator based destructuring. There is the risk then that then everyone starts using the former syntax for the sake of premature optimization and we end up with over-restrictive API's that then disable the opportunities for lazy-evaluation and so on described before.
Definitely and interesting case. It would be nice to be able to read some of the discussion of the standardization process and see how these performance trade-offs where considered. Anyone has some pointers?
There's the mailing list at https://esdiscuss.org/
More recently there's been more discussion around specific proposals in github repos under the tc39 org: https://github.com/tc39
And Rick Waldron takes TC39 meeting notes in this repo: https://github.com/rwaldron/tc39-notes
* Take a language that compiles to JS, with the option to target either ES5.1 features or ES2015 features. For example, Scala.js.
* Take a macro-benchmark suite, or an application with measurable performance metrics, written in that language. For example, https://github.com/sjrd/scalajs-benchmarks
* Run the benchmarks when targeting ES5.1 (default in Scala.js) versus ES2015 (with `scalaJSOutputMode := OutputMode.ECMAScript6`)
* Enjoy the slowdown :-p
I did that 1.5 years ago when I was developing Strong Mode support for Scala.js (now defunct). Results were awful at the time: https://groups.google.com/d/msg/strengthen-js/Bfa_HPhVbiY/yM... They probably have improved since then; I should redo the benchmarks one of these days.
How is only a 1.2x speed regression acceptable? For... Syntactic sugar? [0]
[0] https://docs.google.com/presentation/d/1wiiZeRQp8-sXDB9xXBUA...
And even with optimizations that detect when it is a well-known fundamental iterator (like an Array), you still have to pay for the detection (after all, you might have an eval that calls this function with a non-Array, and Array can be monkey-patched).