
Binary Format
WebAssembly’s Binary Format is a highly efficient, machine-friendly encoding. It reduces transfer size and accelerates parsing compared to text-based formats, enabling faster start-up times in browsers and runtimes.
Reducing code size and parse overhead is critical for applications with large codebases or limited bandwidth.
Stack-Based Virtual Machine
WebAssembly uses a stack-based virtual machine (VM) with a Last-In, First-Out (LIFO) execution model. Operands are pushed onto the stack, operations pop them, then push results back on.
local.get $a→ Pushes the first parameter.local.get $b→ Pushes the second parameter.i32.add→ Pops both values, adds them, then pushes the sum.
Linear Memory
Linear memory in WASM is a contiguous, mutable array of bytes with addresses starting at zero. Data types (i32, i64, f32, f64) specify how many bytes to read/write.

| Instruction | Description |
|---|---|
i32.load | Read 4 bytes (32 bits) from linear memory |
i32.store | Write 4 bytes (32 bits) to linear memory |
7 at byte address 16, and then reads it back:
Modules
A WebAssembly module bundles functions, memory, globals, and tables into a self-contained unit. Modules can be imported, instantiated, and linked with other modules or JavaScript.
add function:
add at runtime.
Security and Sandboxing
WebAssembly executes inside a secure sandbox, preventing unauthorized access to host resources. The browser enforces strict boundaries: any out-of-bounds memory access or forbidden system call triggers an immediate trap.
Always validate and limit the memory and table sizes a module can request. Untrusted modules should never be granted excessive resource quotas.
JavaScript Interoperability
WebAssembly modules interoperate seamlessly with JavaScript. You can import functions from JS into WASM and export WASM functions back to JS, sharing linear memory when needed.
add function from JavaScript:
The WebAssembly Text Format (WAT) is invaluable for debugging and learning, but production workflows typically use the binary format for performance.