WebAssembly 2026-11-05
WebAssembly is a portable, low-level code format with precisely specified execution and validation rules. Programs are organized into WebAssembly modules, often produced by compilation from another programming language. Its type system and stack machine semantics make operations explicit. Although designed with web applications in mind, the core format does not require a web browser.[ref]
Here is a small WebAssembly text format module exporting addition: (module (func (export "add") (param i32 i32) (result i32) local.get 0 local.get 1 i32.add)). The two local.get instructions put the arguments on the operand stack; i32.add consumes them and produces one 32-bit result. The function maps inputs 3 and 4 to 7.[ref]
Integer addition wraps modulo . For example, adding one to the bit pattern representing produces zero, rather than an arbitrarily large integer. This is a rule of the machine format, not a numerical approximation.[ref]
A WebAssembly module obtains external facilities through its host and imports. WebAssembly linear memory is a controlled memory abstraction, not unrestricted access to every host address. Validation and runtime checks provide specified boundaries, but they do not make every allowed computation harmless: an imported operation has the authority that the host gives it.
WebAssembly module 2026-11-05
A WebAssembly module is the unit of deployment, loading and compilation in WebAssembly. It collects declarations such as functions, types and memories, can request imports, and can expose exports. Optional initialization includes data segments and a start function. A WebAssembly module is represented in a binary encoding or the readable WebAssembly text format.[ref]
Definitions use zero-based indices, with a separate index space for each kind of definition. Imported functions precede locally defined functions in the function index space. For example, with one imported function and two local functions, their function indices are respectively 0, 1 and 2; memory index 0 belongs to a different space. This explains why inserting a function import can change a numeric call target.[ref]
A WebAssembly module instance is the runtime realization of these declarations, with references to the allocated or imported objects. Keeping a WebAssembly module distinct from a WebAssembly module instance separates a code description from the state used while executing it. Imported state can be shared; the mere use of the same module does not specify all its runtime resources.[ref]
WebAssembly text format 2026-11-05
The WebAssembly text format is the readable textual encoding of WebAssembly modules. Parenthesized declarations describe the same structured program that can be encoded in binary. Symbolic identifiers such as $add help readers refer to definitions; numeric indices determine references in the underlying module.[ref]
For example, (module (func (export "add") (param i32 i32) (result i32) local.get 0 local.get 1 i32.add)) declares and exports a function accepting two 32-bit integers. The local.get instructions push its arguments onto the operand stack; i32.add consumes them and produces the result. Inputs 3 and 4 give 7. The folded instruction (i32.add (local.get 0) (local.get 1)) is an alternative notation for the same instruction sequence.[ref]
The parentheses of a folded instruction make operand grouping visible, but do not introduce a different arithmetic operation. Decoding either spelling yields the same instruction structure. Textual readability and runtime behavior are separate: indentation can help a human follow the WebAssembly module, while the declared types and instruction order govern execution.