Skip to main content
In this guide, we’ll dive into WebAssembly’s core instructions (the verbs) and data types (the nouns) that power efficient, predictable execution in browsers and other WASM runtimes. By mastering these fundamentals, you can write low-level modules that perform reliably across platforms.

WebAssembly Instructions

WebAssembly instructions are low-level opcodes executed by the WASM virtual machine. Because they resemble machine code more than high-level languages, browsers can optimize them aggressively for speed.

Basic Arithmetic Examples

  • i32.add ‒ adds two 32-bit integers
  • f64.sub ‒ subtracts one 64-bit float from another
Each instruction strictly enforces its operand types. Supplying mismatched types (e.g., passing a boolean into an arithmetic opcode) will trigger a runtime trap.
Always verify operand types before invoking an instruction. WebAssembly performs no implicit conversions and will trap on type mismatches.

WebAssembly Data Types

Choosing the right data type in WebAssembly ensures efficient memory usage and accurate calculations. For instance, consider a web app that displays two temperature readings:
  • 25 °C (an integer)
  • 25.5 °C (a decimal)
In WASM you’d represent these as:
  • 25 °C → i32
  • 25.5 °C → f64
The image illustrates WebAssembly data types, showing temperature values (25°C and 25.5°C) alongside a code snippet with "i32" and "f64" data types.
Below is a quick overview of the core WebAssembly types:
The image is a diagram showing WebAssembly data types, categorized into integers (i32, i64), floating-point numbers (f32, f64), and others (v128, funcref, externref).

Fundamental WebAssembly Instructions

WebAssembly categorizes its instructions into arithmetic, comparison, control flow, and memory operations. Here’s a concise reference:

Further Reading

Watch Video