We've been lied to: JavaScript is fast
Those are some really bad benchmarks.<p>JavaScript is probably like 10x or 100x slower than C or similar languages when you write something bigger and any of the following happens:<p>- the ratio of code size to run time is too big. Then the jit can’t keep up.<p>- you use a lot of value types. Them be structs in C, no need for allocation. In JS them be objects. The JS VM will try to escape analyze them, and it will succeed some of the time, but fail enough of the time to cause massive punishment.<p>- you churn objects while having a large base heap size and the generational hypothesis holds only a bit. Then you’ll wait for the GC a lot.<p>- you have a class hierarchy with many descendants and you often access properties or call methods on the base type. Then vtables or whatever work great but JS inline caches blow up.<p>- probably lots of other conditions.<p>Write enough code and at least one of these will hold and you’ll be slow in JS, fast in C.<p>(Source: I work on JSC and I implemented a lot of its optimizations. Benchmarks like the ones in this post are the sort of thing my JITs eat for breakfast. It’s cool to see people throwing me softballs but I like to be honest about what the technology I work on is capable of.)