News for hackers. Stuff that matters.
Re:Stanford's CS 101 course uses Javascript by bzbarsky on Saturday July 09, 2011 @10:25PM (#2746856)
I think the original comment about x + x + x there was not about JavaScript.

For JavaScript, you get all sorts of additional complications depending on how good your JIT is. For example, you have to check both integer addition and integer multiplication for overflow (at which point you have to recompile as doubles) unless your interval analysis is good enough. So the cost is more than just the cost of the machine add in some cases.

In practice, I'd be suprised if current JS JITs do strength-reduction in this case. They might get there sometime in the next few years, but there's lower-hanging fruit to be had so far.

Re:Stanford's CS 101 course uses Javascript by kingkilr on Sunday July 10, 2011 @12:06AM (#2747008)
Strength reduction in this vein is pretty trivial though, even if there is lower hanging fruit. For example this is what transforming some_int * a_power_of_two looks like in PyPy: https://bitbucket.org/pypy/pypy/src/default/pypy/jit/metaint...
Re:Stanford's CS 101 course uses Javascript by bzbarsky on Monday July 11, 2011 @10:48PM (#2753341)
It's trivial if you don't mind the extra compilation time.

If you're trying to make sure that your compile times are also short, it might not be worth it.... yet.