joe (2015-02-15T15:35:43.000Z)
d at domenic.me (2015-02-21T00:42:08.367Z)
On Sun, Feb 15, 2015 at 7:16 AM, Benjamin (Inglor) Gruenbaum <inglor at gmail.com> wrote: > This is something that can be solved at the VM level. VMs perform much > much smarter optimizations than this already. There is no reason to > sacrifice code correctness and the principle of least astonishment in order > to get acceptable performance. Benchmarking against "proof of concept" > implementations is counter-productive in my opinion. The engines are > already 'allowed' to use the same object when there is no observable > difference. Even if we allow this 'optimization' it will take the engines > as much time to implement it so there is no gain from this anyway. Is 60,000 lines of source code a good enough "proof of concept for you"? I don't see what the problem is. My transpiler generators the following ES5 code: ```js //for (var item in set) var iter = obj.iterator(); while (1) { var ret = obj.next(); if (ret.done) break; var item = ret.value; ...loop body } ``` It works quite well. You may be right about the VM vendors, however. This requirement basically makes JS useless for anything other than minor scripting tasks. The VM people may not have any choice but to optimize it.