>Why are C/C++ so much faster than JIT'ed Javascript? Can't a subset of Javascript be converted to ASM.js JS that'll run around the same speed? loops, arrays, conditional statements, etc. Why does Javascript have to be so much slower?
"So much slower"?
Perhaps you haven't been around this web scene for more than 5-6 years. JS is so much faster now it's not even funny. JS used to be in the "slow as molasses" category pre-2005.
Now it's like 10 times faster than Python for pure algorithmic code.
I'm asking to have C/C++ compared to JIT'ed Javascript. You are explaining how Javascript is so much faster than it used to be, and that it's 10x faster than Python. The fact that I mentioned JIT'ed Javascript should have given away that I understand Javascript's current performance.
If Javascript were fast enough, we wouldn't be looking for "4-10x" improvements with ASM.js and NaCL. Are we close to the limit of what can be done to improve Javascript performance? Perhaps another 2x?
>The fact that I mentioned JIT'ed Javascript should have given away that I understand Javascript's current performance.
Sure, but "understanding" is different than appreciating.
After all, a JIT is not some magic wand. If a language is very dynamic, memory hungry, less prone to optimizations, etc, JIT code will still be slower than C/C++. Plus, not everything in a JS program is getting JITed.
>Are we close to the limit of what can be done to improve Javascript performance?
With Javascript as it is, yes. Maybe some 2x at best. If we add type hints, contiguous storage, and frozen object guarantees though (some of which ES6 has, IIRC) that can be improved further.
"So much slower"?
Perhaps you haven't been around this web scene for more than 5-6 years. JS is so much faster now it's not even funny. JS used to be in the "slow as molasses" category pre-2005.
Now it's like 10 times faster than Python for pure algorithmic code.