Sikau

Learn WebAssembly

Read, write and compile to wasm — byte by byte.

Go beneath the tools: run a 41-byte module, decode LEB128 numbers, read a module's sections, build binaries by hand, interpret the stack machine, write an assembler for wasm text and a loop in bytecode, pass strings through linear memory — and finish with a compiler that turns expressions into real WebAssembly.

Advanced · 12 lessons · about 8 hours · free

Start WebAssembly free: run real code in your browserright here

Continue with Google

What you will learn

Unit 1: The binary format

Load modules, LEB128 numbers, sections — and build a module by hand.

  1. Day 1Hello, WebAssemblyA 41-byte binary module, compiled and called from JavaScript.30 min
  2. Day 2Numbers in the binary: LEB128Variable-length integers: small numbers take one byte, big ones more.35 min
  3. Day 3Reading a moduleThe magic number, the version, and a list of sized sections.35 min
  4. Day 4Project: Build a module from scratchEmit the sections yourself and run functions you assembled by hand.45 min

Unit 2: Inside the virtual machine

The stack machine, wasm text, memory, and a compiler.

  1. Day 5A stack machineWasm instructions push and pop an operand stack — interpret them yourself.35 min
  2. Day 6An assembler for wasm textTurn readable instructions into bytecode, then write a loop in it.40 min
  3. Day 7Linear memoryShare strings with wasm through its memory: write bytes, call, read back.35 min
  4. Day 8Capstone: A compiler to WebAssemblyParse arithmetic with precedence and emit real wasm bytecode.55 min

Unit 3: Across the boundary

Memory growth, imports, tables, and crossing between wasm and JavaScript.

  1. Day 9Memory in depth: pages, growth and byte orderGrow memory safely, mind detached views and read numbers in the right byte order.40 min
  2. Day 10Imports: wasm calling JavaScriptGive a module the functions it needs, and see what happens when they are missing.40 min
  3. Day 11Tables and indirect callsStore function references in a table and call them by number.40 min
  4. Day 12Capstone: Fast across the boundaryBatch data into memory, grow it when needed, and learn when wasm really pays off.50 min

Before you start

These courses make WebAssembly easier:

See all courses

Built with ❤️ by dibe.sh