3 ms·
Well-optimized C is likely to always be faster than well-optimized JavaScript. It is also possible that circuitlab is not well-optimized JavaScript. I will sa
by dangoor 14y ago
Well-optimized C is likely to always be faster than well-optimized JavaScript.
It is also possible that circuitlab is not well-optimized JavaScript.
I will say that it also depends on the problem domain. You can make a fast 3D game in JavaScript because WebGL does hardware acceleration of the graphics. You can also make a fast todo list in JavaScript because, well, it's a todo list :)
- Joeri 14y agoI don't think C will always be faster. A JIT-compiled language can theoretically be optimized better than a precompiled binary, because the JIT engine can recompile hot code based on observed behavior on the actual system with the actual data.
- im3w1l 14y agoTheoretically, a c-compiler could produce self modifying code.
- wisty 14y agoAlso, this theoretical c compiler could make use of implicit hints (like which variables to place together in memory), making it faster than JS (except asymptotically, when the JIT has run long enough to figure everything out). But the original point is basically right - one day JITs will be faster.
- pkolaczk 14y agoJITs don't have so much time to optimize, as static compilers do. Therefore, they can't do e.g. whole program analysis, or expensive cache related optimizations. Despite 15 years of effort of speeding up JVM, it is still slower in general than optimized C. Not by much (usually good Java code runs within a 2x slower margin), but still - it can't beat static compilers.