Earlier quoted context omitted.
It has to do with JavaScript's "scope chain" method of looking up symbol bindings. If something isn't in the current scope, it has to incrementally check each "scope" (such a bastardization..) for the binding it's looking for. If it works its way back up to the global (window) object's "scope" and doesn't find it, it gives up and returns undefined. "with", try/catch, etc. all introduce another level of scope, which m…
Why can't scope be resolved at compile-time? I realize that things like window.x can be added at runtime, but local scopes ought to be simple to rule out.... as long as there are no calls to eval() ..... eval(), which can introduce local bindings at runtime from arbitrary, runtime-constructed strings .... Ugh. And since aliases to eval can also be created, in any scope, from other dynamically eval()'d code strings, y…
Extreme JavaScript Performance
11–18 of 18 posts
Re: Extreme JavaScript Performance
#12Stupid microoptimisations. Not only one should never optimize prematurely, and that is noted in the slides, but one should also never optimize like that (at least in the JS context). The interpreters/compilers/whatever will evolve for the readable cases, not for obscure idiocies, and programs using these techniques today will just run slower tomorrow.
Re: Extreme JavaScript Performance
#13Re: Extreme JavaScript Performance
#14Earlier quoted context omitted.
It has to do with JavaScript's "scope chain" method of looking up symbol bindings. If something isn't in the current scope, it has to incrementally check each "scope" (such a bastardization..) for the binding it's looking for. If it works its way back up to the global (window) object's "scope" and doesn't find it, it gives up and returns undefined. "with", try/catch, etc. all introduce another level of scope, which m…
Why can't scope be resolved at compile-time? I realize that things like window.x can be added at runtime, but local scopes ought to be simple to rule out.... as long as there are no calls to eval() ..... eval(), which can introduce local bindings at runtime from arbitrary, runtime-constructed strings .... Ugh. And since aliases to eval can also be created, in any scope, from other dynamically eval()'d code strings, y…
If it's easy to do, it is probably only a matter of time until the major implementations include it. They seem to be competing on speed, after all.
Re: Extreme JavaScript Performance
#15In my job I was always shocked to see massive HTML strings appended or replaced in an objects innerHTML, and instead wrote lots of createElements and createTextNodes. Apparently, for performance's sake (and especially in loops) it is MUCH more efficient to use a string and replace methods to alter the content.
Re: Extreme JavaScript Performance
#16Re: Extreme JavaScript Performance
#17The one I wish they had measured was createElement compared to innerHTML replacement. In my job I was always shocked to see massive HTML strings appended or replaced in an objects innerHTML, and instead wrote lots of createElements and createTextNodes. Apparently, for performance's sake (and especially in loops) it is MUCH more efficient to use a string and replace methods to alter the content.
Re: Extreme JavaScript Performance
#18I wish his summary charts were less binary. He shades the "winner" algorithm's box green. But many of those wins are insignificant. I don't think I'd inflict ~~(1*"12.5") on someone for an insignificant gain when a parseInt() is obvious. (I also suspect that at least one of those implementations constant folded it.)