3 ms·
People like to claim that JavaScript is only about 2-4 times slower than C++. And maybe that's true for heavily optimized JavaScript that gets to run for a lon
by Jweb_Guru 8y ago
People like to claim that JavaScript is only about 2-4 times slower than C++. And maybe that's true for heavily optimized JavaScript that gets to run for a long time. Personally, I rewrote an ES5 parser in Rust and saw about a 16x speedup on real world JS source code (directories, not just individual files), which I suspect is closer to what you'd see in reality. People vastly overestimate how long most programs should actually run (such that V8's optimizations would really kick in) and also the extent to which V8's optimizations can actually be applied. There is a link elsewhere in here suggesting that v8 it can eventually get to about 2x faster than AOT JavaScript, but it doesn't show significant improvements until 100,000 iterations over the same 100 lines--besides that being an unrealistic microbenchmark, almost no repositories come close to 10 million lines of code, so by the time v8 is done optimizing a much faster program will have finished long ago.