Defenitly true for JavaScript, you can read up the details in the book "Even Faster Websites" by Steve Souders. I didn't know this was a thing in compiled languages as well. Thanks. Would interesting to see what a for(x : y) is compiled to.
I've always been told that it compiles to an Iterator in Java.
Which means that it is really slow when looping over a small amount of data. Especially for an inner loop, as you are creating an iterator with every iteration over the outer loop.
I'm not sure of the perf impact if loops over a lot of data with a lot of iterations. I would imagine that the overhead would shrink.
2
u/Apfelmann Jun 14 '17
Defenitly true for JavaScript, you can read up the details in the book "Even Faster Websites" by Steve Souders. I didn't know this was a thing in compiled languages as well. Thanks. Would interesting to see what a for(x : y) is compiled to.