Any language compiler or runtime that requires me to manually optimize out the length of an array when iterating said array is not worth my time to program in.

var cachedArrayLengthLol = data.length;
for (var i = 0; i < cachedArrayLengthLol; i++) {
  console.log(data[i]);
}

I'm looking at you, ancient C compilers. And you, Javascript. Particularly you, shame on you for not having a humane syntax for iterating over collections.

I'm assuming V8 and any other modern fast Javascript runtime can handle figuring out that the array length isn't changing inside the loop. Boy, I sure hope so. I've got better things to do than program in assembly language.

techbad
  2011-03-19 01:18 Z