HACKER Q&A
📣 anon115

Is C++ logic code using WASM faster than JavaScript logic code?


say both logic code do the exact same thing but just written in C++ or Javascript will speed time be noticeable?


  👤 threatripper Accepted Answer ✓
This needs way more context. In general C++ is slower to develop and harder to maintain if you don't already have dedicated C++ developers and your code is being developed in C++.

Usually the best thing to do is to build a working prototype with tools that are most efficient in building working prototypes. If your idea doesn't do the job you save a lot of time and money. If it does the job really well you will have a lot of pain due to the technical debt that you acquired but you will also a lot of money to pay for the pain.

In conclusion: I'm 99% sure that you're asking the wrong question.


👤 pjmlp
WASM code (regardless of the language), will usually be faster if it is mostly compute and little DOM interactions, as doing that requires going through JavaScript anyway.

And if doing 3D stuff, you're better off doing performance critical stuff on shaders, powered by the GPU, than dealing with C++ targeting WebAssembly.


👤 ksherlock
The wasmboy benchmark compared typescript compiled to javascript vs typescript compiled to wasm and the wasm code has 40-60% higher fps.

👤 AA-BA-94-2A-56
Varied answers in here, but honestly it depends. We’re not at the stage where one is clearly better than the other.

👤 andsoitis
> Is C++ logic code using WASM faster than JavaScript.

No. The JavaScript code will be faster.