Hacker News new | ask | show | jobs
by emilecantin 1011 days ago
Yes, Javascript is used in browsers and has a few different competing runtimes, and as such, there are a lot of resources invested in making it faster than the other runtimes.

As a result, except in only very trivial cases, Javascript is only slower than C++ by about a factor of 2-4. This is a much smaller difference than the "orders of magnitude" mentioned above.

The following list of benchmarks illustrates this point: https://programming-language-benchmarks.vercel.app/javascrip...

The only exception is "hello world", which is about one order of magnitude slower in JS, but that's probably explained by the runtime startup / teardown.

1 comments

Those are microbenchmarks, and as such are misleading when it comes to evaluating JIT-ed languages. They also don’t involve ever touching the DOM, which is a major source of slowdowns in real-world JS apps.
Yes, but any UI stuff in C++ is also going to be a major source of slowdowns.

And C++ compiled to WASM will have the same slowdowns if it needs to touch the DOM.

That actually makes me want to create a set of UI benchmarks comparing performance standard UI operations in C++ with Qt vs JS with DOM. I think I’ll look into it over the weekend.