typestar

The module shape in WebAssembly

The smallest WebAssembly text: one module, one exported function.

;; Everything lives in one s-expression: a module of declarations.
(module
  ;; Export a function under the name the host will call.
  (func (export "answer") (result i32)
    i32.const 42))

How it works

  1. Everything is an s-expression; (module ...) wraps the whole program.
  2. (func (export "answer") ...) names the function for the host.
  3. (result i32) types the return; i32.const 42 pushes it.

Keywords and builtins used here

The run, in numbers

Lines
5
Characters to type
182
Tokens
20
Three-star pace
70 tpm

At the three-star pace of 70 tokens a minute, this run takes about 17 seconds.

Type this snippet

Step 1 of 3 in Modules, step 1 of 28 in Language basics.

Next →