What is Web Assembly?
Web Assembly(Wasm) is a way of taking code written in programming languages other than JavaScript and running that code in the browser.
It is generated by the compiler with a binary format which allows us to execute any language code on the browser
How does it work?
Despite its name, WebAssembly is not quite an assembly language because it’s not meant for any specific machine. It’s for the browsers, and when you’re delivering code to be executed in the browser, you don’t know what kinds of machines will your code be running on.
What WebAssembly enables you to do is to take things like C, C++ or Rust code and compile it into what is called a WebAssembly module. You can load that into your web application and call it from JavaScript.
Wasm programs are deployed in two stages.
- Wasm module is generated from the source code (any language of your choice other than JavaScript)
- Once the Wasm module is built, it can be run anywhere with a few lines of JavaScript glue:
It’s not a replacement for JavaScript, it works alongside JavaScript.
Here is a great article to go more in details.