WebAssembly from the Ground Up

@wasmgroundup.com

A book about WebAssembly by @marianoguerra.org and @dubroy.com — learn Wasm by building a simple compiler in JavaScript. https://wasmgroundup.com/

A while back, someone in the @wasmgroundup.com Discord asked about resources for learning the formal notation used in the WebAssembly spec. One I like is Jeremy Siek's "Crash Course on Notation in Programming Language Theory": siek.blogspot.com/2012/07/cras...

Crash Course on Notation in Programming Language Theory

This blog post is meant to help my friends get started in reading my other blog posts, that is, this post is a crash course on the notation ...

siek.blogspot.com

One of our goals in the book was to encourage readers to become familiar with the WebAssembly spec. That's why, in the library we create for producing Wasm modules, we aim for "eye-closeness" with the spec. Left: code from the book. Right: the 1.0 spec text.

// im*:vec(import)
export function importsec(ims) {
  return section(SECTION_ID_IMPORT, vec(ims));
}

// mod:name  nm:name  d:importdesc
export function import_(mod, nm, d) {
  return [name(mod), name(nm), d];
}

export const importdesc = {
  // x:typeidx
  func(x) {
    return [0x00, typeidx(x)];
  },
};
Excerpt from the WebAssembly core specification show § 5.5.5. Import Section, and the definitions of `importsec`, `import`, and `importdesc`.