What is Wasm
Wasm, or WebAssembly is a binary instruction format for a stack-based virtual machine. In other words, it's a custom, language- and platform-agnostic byte-code representation of your code.
An example Wasm module bytes and instructions (via Wasm Code Explorer)
Whether you write in C, C++, Rust, Go, Ruby—almost any programming language—you can compile your code into a .wasm
binary module and execute the program within a Wasm runtime.
The major benefits of using Wasm are:
Speed. WebAssembly instructions are closer to machine code and could be optimized efficiently.
Portability. You can compiler your code into a Wasm module once and use everywhere.
Safety. Wasm runtimes are sandbox execution environments.
Let's talk about runtimes for a bit.
Wasm runtimes
The original and the most popular Wasm runtime is the WebAssembly running in your browser.
However, today is not the only consumer of Wasm modules (maybe, not even the primary one). Due to portability and safety features, Wasm became a popular choice for embedding foreign code into software programs.
You can execute Wasm modules directly on your computer using Wasmtime, or you can embed Wasm modules into Go programs via Wazero.
Serverless platforms are also popular Wasm users. CloudFlare, for example, supports Wasm Workers. There are also Wasm-first serverless platforms like WasmEdge.
To sum up, Wasm is getting more and more traction, and making your software Wasm-compatible can open new exciting possibilities.