Is WebAssembly for Web developer?View other answers to this thread
Learn Something New Everyday,
Connect With The Best Developers!
Yes. WebAssembly is for web devs. Is it an alternative for JS, though? Yes and no.
First of all, WASM is mostly useful for web apps. It allows writing very fast code, based on some guarantees WASM has and the structure it is delivered in. That's why it is ideal for compute-code, something JS is rather bad at.
However, does "JS is bad at compute" mean, that JS is slow, and we should write everything in WASM now, so that we can have uber-performance? No. JS is not slow. It is very adequate for most use-cases. Plus, as usual, if your program is slow, it's usually because of your code. Profile you application, identify the hot-path and the bottleneck and based on that write code which leads to a faster execution (for example use caching, lookup-tables, change the algorithm used, etc.). JS has a lot of advantages and most web devs are familiar with JS, so I would write a web-app with JS first.
WASM should only be considered if after optimization the application is still too slow, or libraries are required which are only available in a different language, are too much work to port and would perform subpar when transpiled to JS. In these cases, WASM can work wonders - at a prize.
- WASM is one binary file. Hot-reloading code means replacing the whole blob, if at all supported (which means re-compiling all the code, which might take a moment)
- WASM needs to be written in a typed language with available compiler - for example Rust, C++, Go, Lua, (a subset of) TypeScript, etc. (see list here) - which means learning a new language or at least all the subtle differences, as a team
- Only the latest browsers support WASM (no accessibility, problems with corporate and special-machine usage, etc.)
On the bright side, we already have some tools which make life very easy, like the Parcel bundler if you need to extend a web-app, and a lot of frameworks in different ecosystems (I know at least about a lot of Rust crates, like the Amethyst game framework/engine) which are written with WASM in mind, if you want to create an app and need to bring it to the browser.