typestar

Languages

WebAssembly

A portable binary instruction format executed by all major browsers, shown here in its standard text form.

Practice WebAssembly

28 steps across 1 tours, from the basics to complete programs.

The tours

First released
2017
Created by
The W3C WebAssembly Working Group
Typing
A typed stack machine; every s-expression is one instruction
Snippets target
3.0
File extensions
.wat, .wasm

What it is for

WebAssembly is the fourth language browsers execute natively — after HTML, CSS, and JavaScript — and the only one nobody is expected to write by hand. It is a compile target: Rust, C, C++, Go, Kotlin, and dozens more compile to its compact binary form, and the engine runs it at near-native speed inside the same sandbox that contains JavaScript. Figma's editor, Google Earth, Photoshop on the web, and most in-browser video tooling all ship it.

Beyond the browser it became the neutral packaging format for untrusted code: serverless edge platforms, plugin systems for databases and proxies, and blockchain runtimes all embed wasm engines because the format is small, fast to start, and sealed by default — a module states its imports, and the host decides what to hand over. WASI extends that story toward files and sockets so the same module can run on a server unchanged.

The text format, WAT, is where humans meet it: s-expressions that map one-to-one onto the binary. Reading it teaches how the machine underneath actually works — an operand stack, typed locals, linear memory addressed by arithmetic — which makes it the rare assembly language that is genuinely pleasant to study, and the one every compiler-to-wasm engineer ends up reading in anger.

Where it came from

WebAssembly was announced in 2015 by engineers from all four browser vendors, growing out of Mozilla's asm.js — a proven trick of running C compiled to an optimizable JavaScript subset — and Google's Native Client. The design goal was the part asm.js could not deliver: a compact binary format with predictable near-native performance, validated and sandboxed, shipped by every engine identically.

The MVP reached all four major browsers in 2017, one of the fastest cross-vendor rollouts the web has had, and the W3C published WebAssembly as its fourth official web language recommendation in December 2019. The follow-on releases added the features hand-written WAT shows off: multiple return values, bulk memory operations, reference types, SIMD.

The Bytecode Alliance — founded by Mozilla, Fastly, Intel, and Red Hat — carried the format beyond the browser with WASI, the system interface, and production engines like Wasmtime. The component model, standardized through the 2020s, aims at the remaining dream: language-neutral libraries that compose across every host, with wasm as the common object format.

What it is like to type

WAT is parentheses and dotted instruction names, in that order. Every operation spells its type up front — i32.add, f64.sqrt, i64.extend_i32_s — so the fingers live on the home-row dot and the digits. Dollar-sign names label locals, functions, and jump targets, and the folded style nests close-parens into little staircases that end lines with )))) runs. There are no operators, no precedence, and no sugar: what you type is the instruction stream, which makes it slow, honest typing — the signature clusters are local.get, i32.const, and br_if.

Practice WebAssembly

28 steps across 1 tours, from the basics to complete programs.

Official documentation

Other languages