> AFAIK web assembly is not much faster than native javascript for general purpose code.
I've heard this before, and I'm sure it's true for "naive" code, but I find this a very unsatisfying truism because it does not tell me why. What is keeping WASM from being faster? Or alternatively: what is giving JavaScript an inherent edge in certain tasks.
My guess would be that for more complicated tasks, WASM currently shines wherever Typed Arrays used to potentially give an increase in performance: wherever you can allocate a big chunk of memory once, and fast access to it is the main bottleneck, and that for most other things still is too much overhead in communication with the rest of the browser.
But I simply don't know and it annoys me tremendously.
The WASM compilers are still being optimized. Most of what you see in the wild is compiled using LLVM, even the Rust project. The WASM target is still under development so you can expect a lot of improvement there.
One day we will see a language that compiles natively to WASM. Maybe even exclusively to WASM, with crazy optimizations akin to GCC's tricks with x86. I just hope it won't have objects.
Ah, that makes sense. That also would imply that more and more domains where JS has the advantage now will shift towards WASM in the long term.
Might part of the issue also be that there are now two compilation phases: to-WASM, and WASM-to-native? If the WASM bytecode produced isn't easily optimised by the WASM-to-native phase (I assume only the most basic optimisations are made at that stage) that may also result in slowdowns.
I'm wondering if this can become a source of unexpected instability in WASM performance across JavaScript engines, kind of like how built-in functions can vary wildly in performance across JavScript engines right now.
I've heard this before, and I'm sure it's true for "naive" code, but I find this a very unsatisfying truism because it does not tell me why. What is keeping WASM from being faster? Or alternatively: what is giving JavaScript an inherent edge in certain tasks.
My guess would be that for more complicated tasks, WASM currently shines wherever Typed Arrays used to potentially give an increase in performance: wherever you can allocate a big chunk of memory once, and fast access to it is the main bottleneck, and that for most other things still is too much overhead in communication with the rest of the browser.
But I simply don't know and it annoys me tremendously.