WebAssembly from the Ground Up — a hands-on book

Learn how WebAssembly works and why it's a big deal.

This book takes a hands-on, bottom-up approach: you'll go from hand crafting bytecodes to writing a real compiler for a simple programming language.

Forget the hype — get your hands dirty and see for yourself what WebAssembly is all about.

$39 $29 Beta price

Buy now for $29

This book is a work in progress. The beta price includes:

  • Access to 10 chapters of technical content.
  • Early access to new chapters as they're completed.
  • Membership in our private Discord.
  • A 30-day money-back guarantee.

Our approach

Representation of WebAssembly concepts as the atomic model with binary format, validation and execution at the center and Web API, JS API, WASI and others orbiting around

To really understand what WebAssembly is and what makes it special, you need to dive into the low-level details.

We use a hands-on approach to teach you the core of WebAssembly: the instruction set and the module format.

Since WebAssembly is primarily a compilation target, we think the best way to learn the details is by writing a compiler. (Really.)

You'll build a compiler that compiles a simple programming language down to WebAssembly.

The focus is on WebAssembly, not the finer details of parsing. The compiler is built in JavaScript, using Ohm, a user-friendly parsing toolkit.

All the code you need is provided in the book. Everything proceeds step by step — in small, logical increments.

You'll learn...

  • What exactly WebAssembly is, and what makes it unique.
  • How to instantiate a WebAssembly module in JavaScript and run its functions.
  • The binary module format, and how to hand craft a module from scratch.
  • How to create a simple compiler with Ohm.
  • The instruction set: numeric instructions, memory access, control flow, etc.
  • How to interact with the outside world.
  • The WebAssembly security model: what makes it safe?

Who should read this book?

The book is mainly targeted at experienced programmers. You don't need to be an expert, but ideally you've been programming for a few years and are fluent in more than one language. For important topics that some readers might not be familiar with, we've included optional deep dive sections to get you up to speed.

In order to understand the code, you'll need at least intermediate knowledge of JavaScript, or a willingness to learn. We try to stick to "the good parts" and to avoid any advanced or obscure features.

You do not need any previous experience with writing a compiler! Our compiler is based on Ohm, a framework that handles the lower-level details of parsing. This lets us keep the focus on WebAssembly.

For some reason, many people believe that writing a compiler is a complex, esoteric task. But we hope to convince you that it's really not.

About the authors

Mariano Guerra 🐦 🐘 🦋 🏠

is a co-founder of Instadeq, a data analysis and visualization product, and the creator of GlooData, a no-code automation tool. He has a long history of language- and compiler-related side projects, including the programming languages Efene and Interfix. In the past, he worked with IBM Research and on high-performance computing at Intel. Originally from Córdoba, Argentina, he now lives in Stuttgart, Germany.

Patrick Dubroy 🐦 🐘 🦋 🏠

is a programmer and independent researcher based in Munich, Germany. He's a co-creator and the primary maintainer of Ohm, a user-friendly parsing toolkit for JavaScript. At the beginning of his career, he spent four years working on the J9 Java VM at IBM. Since then, he's worked at companies like Google (on Chrome and Android), Lyft, and Sourcegraph.

Not convinced?

If you're not ready to buy the book yet, you can subscribe to our mailing list and we'll let you know when the book is finished. Don't worry — it's very low traffic, and you can unsubscribe with one click.