WebAssembly · Lesson 1 · On the house

What WebAssembly is

Binary format, portable target, browsers and runtimes; .wat vs .wasm; WASM vs JS. Lesson 1 is free — on the house.

Lessons · WebAssembly · Lesson 1 of 10 · On the house

What WebAssembly is

Binary format, portable target, browsers and runtimes; .wat vs .wasm; WASM vs JS.

Illustration for WebAssembly
Lesson 1 is on the house.

WebAssembly (WASM) is a binary instruction format for a stack-based virtual machine. Compilers emit it as a portable compilation target — not a language you usually write by hand for whole apps.

Engines run .wasm modules in browsers (Chrome, Firefox, Safari, Edge) and outside them (Wasmtime, Wasmer, Node’s WebAssembly API). Same bytecode, different hosts.

JavaScript stays the browser’s dynamic language for DOM and glue. WASM shines for CPU-heavy, predictable code compiled from C, C++, Rust, and others. They cooperate: JS loads and calls into a module.

Text format is .wat (S-expressions humans can read). Binary is .wasm (what engines load). Convert with WABT: wat2wasm and wasm2wat. Magics start with bytes \0asm (U+0061 ‘a’, etc.).

Misses: treating WASM as a JS dialect, editing .wasm in a text editor as if it were source, or assuming WASM replaces HTML/CSS.

what-wasm

;; add.wat — text format
(module
  (func (export "add") (param i32 i32) (result i32)
    local.get 0
    local.get 1
    i32.add))
Match this when you type.

Quiz

What is WebAssembly primarily?

Quiz

Which file is the binary engines load?

Quiz

What is .wat?

Quiz

How do WASM and JavaScript relate in the browser?

Check

Match the still for: What WebAssembly is.

Open-book: the answers are on this page. Pass every quiz and check (5) to mark the lesson done. This visit: 0/5.