What is WebAssembly?
WebAssembly (Wasm) is a low‑level binary format that runs in modern browsers at near‑native speed. It allows developers to compile languages like C, C++, Rust, and Go to run on the web alongside JavaScript.
Why Use WebAssembly?
- Performance: Executes faster than JavaScript for compute‑intensive tasks.
- Portability: Same binary runs on any browser that supports Wasm.
- Interoperability: Can call JavaScript functions and be called from them.
Running Your First Wasm Module
Below is a minimal add function written in WebAssembly Text format, compiled to binary, and executed in the browser.
(module
(func $add (param $a i32) (param $b i32) (result i32)
local.get $a
local.get $b
i32.add)
(export "add" (func $add)))