3 ms·
Modern JS engines only interpret cold functions, and static vs dynamic doesn't matter once type information has been collected. The real reason is that HotSpot
by PeCaN 7y ago
Modern JS engines only interpret cold functions, and static vs dynamic doesn't matter once type information has been collected.
The real reason is that HotSpot has 10+ more years of work put into it than V8.
- ufo 7y agoStatic vs dynamic still matters if the program is doing "dynamic stuff", where "dynamic stuff" means any thing that the JIT compiler is currently not able to optimize.
- PeCaN 7y agoThat's fair, but that's also stuff that you just can't really do in Java in general¹, so it's not useful for a comparison. The fact is that the vast majority of JavaScript code is pretty static and there's nothing preventing it from running as fast as Java other than man-decades of compiler engineering. ― ¹ Possibly excluding reflection. It's been a long time since I used the Java reflection APIs and I have no idea if you can do things like add class fields named after arbitrary strings at runtime. Even if you could, presumably this bails out of jitted code so the situation is basically the same as in JS.