Hacker News new | past | comments | ask | show | jobs | submit login

Might some of these little idiomatic optimizations be automatically performed by the Closure Compiler, making their absence from the original source irrelevant?



That was my first thought. I ran the "slow loop" through the online compiler at:

http://closure-compiler.appspot.com/home

And whether I checked "Simple" or "Advanced" I got:

for(var a = 0;a < arr.length;a++)

So it's not optimizing that pattern yet.


It would have to determine that arr.length doesn't change during the loop. Pretty difficult problem. :)


I'm unsure if the smiley means you're being sarcastic, but if not:

Such determinations are a pretty common thing for an optimizing compiler to attempt:

http://en.wikipedia.org/wiki/Loop-invariant_code_motion


Perhaps, but it does seem that the Google Closure developers are unaware of these optimizations. Unless the compiler was written by an entirely different group, I would be surprised.

Of course, there's an easy way to find out. :)


Closure was written by many, many different people. I can attest that the core developers (the ones whose names are on the project) are very aware of these optimizations - one of them interviewed me when I was being hired, and another was in charge of my JS readability review. But Closure's a big chunk of code, though, and the core developers tend to be very busy people, and not everyone can review everything.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: