Are all wasm speeds equal?

Viewed 136

As we know wasm can be 'compiled' from cpp c# typescript rust etc. Question is will it make a big performance difference whether the wasm was compiled from for example cpp or typescript? Or it doesn't matter where it was compiled from, the wasm will be the same wasm?

2 Answers

No. Ask yourself - Are all x86 programs using different languages have the same speed? No.

The same thing happens to wasm.

When different languages used, they hardly produce the same binaries. Actually, even with the same code with the same language they may perform differently depending on optimization options.

They don't share the same toolchain, libraries, optimizations, nor runtime. Even if you successfully built exactly the same binaries you still may have different host-side runtimes (or imported functions).

To add to Bumsik Kim’s answer, differences are not only caused by different implementations, but also the characteristics of the source languages: different semantics like static or dynamic typing or (im)mutability make possible / limit different optimizations. The fact that JavaScript’s semantics severely limit performance optimizations directly led to the development of WebAssembly itself.

Related