nowfound

Life & fun · March 12, 2025

WF

WebAssembly from the Ground Up – learn WASM by building a compiler

Hi HN! We (pdubroy & marianoguerra) just launched an online book called WebAssembly from the Ground Up. It's an online book to learn Wasm by building a simple compiler in JavaScript. This is the book we wish we'd had 3 years ago. Unlike many WebAssembly resources that focus on use cases and tooling, we wanted a deep dive into how Wasm actually works. We focus on the core of WebAssembly: the module format and the instruction set. We think the low-level details — the "virtual ISA" — are the most interesting part, and we had the crazy idea that writing a compiler is the best way to learn it.…

What it does

In the maker’s words, at launch

Hi HN! We (pdubroy & marianoguerra) just launched an online book called WebAssembly from the Ground Up. It's an online book to learn Wasm by building a simple compiler in JavaScript. This is the book we wish we'd had 3 years ago. Unlike many WebAssembly resources that focus on use cases and tooling, we wanted a deep dive into how Wasm actually works. We focus on the core of WebAssembly: the module format and the instruction set. We think the low-level details — the "virtual ISA" — are the most interesting part, and we had the crazy idea that writing a compiler is the best way to learn it. Over the course of the book, you'll build up two things: 1. An "assembler library", that can be used to produce WebAssembly modules. Here's an example: const mod = module([ typesec([functype([], [])]), funcsec([typeidx(0)]), exportsec([export_('main', exportdesc.func(0))]), codesec([code(func([], [instr.end]))]), ]); return Uint8Array.from(mod.flat(Infinity)); 2. A very simple compiler for a language called Wafer, which looks like this: extern func setPixel(x, y, r, g, b, a); func draw(width, height, t) { let y = 0; while y < height { let x = 0; while x < width { let r = t; let g = x; let b = y; let a = 255; setPixel(x, y, r, g, b, a); x := x + 1; } y := y + 1; } 0 } In case you're not a fan of JavaScript, we've already heard of readers who've worked through the book in F# and Haskell. :-D You can check out a sample here: https:&#x2F;&#x2F;wasmgroundup.com&#x2F;book&#x2F;contents-sample&#x2F; — we'd love to hear what you think! There's also a 25% discount for HN readers — just use the code HNWASM25 at checkout.

Does the same job

all alternatives →

More life & fun this month

the category →
  • TL

    Life & fun · 10d ago · louisabraham.github.io

  • Photosynthesis fires two of your iPhone

    Life & fun · 28d ago · photosynthesis.camera

  • SoloUno310

    Take control of hair pulling, nail biting & skin picking

    Life & fun · 28d ago · solouno.io

  • Scroll through all 43,252,003,274,489,856,000 reachable Rubik's Cube permutations.

    Life & fun · 26d ago · everycube.alen.is

  • The Interactive 3D Encyclopedia

    Life & fun · 21d ago · expeditione.fun

  • Hi HN, I built Eigendrum, a web tool that solves the 2D wave equation for arbitrary shapes so you can hear what they sound like as drums. How it works: * Solves -∇²u = λu using finite element analysis (Kφ = λMφ) on a triangle mesh. * Validated to <0.1% error against closed-form solutions for circles (Bessel zeros) and rectangles. * Sound model factors in strike location, Rayleigh damping, and mallet width. * Includes Kac drums I & II to demonstrate identical sound spectra from different geometries. * No frameworks, build steps, or dependencies. Repo and tests:…

    Life & fun · 26d ago · baselashraf81.github.io

Launched alongside, March 2025

the whole month →
  • Mimic Human Research & Save Findings in AI Knowledge Base

    AI · 2025 · sider.ai

  • The first AI dev team

    AI · 2025 · atoms.dev

  • Aha1,151

    The world's first AI influencer marketing team

    AI · 2025 · ahacreator.com

  • Fluently976

    Start speaking English as well as your native language

    AI · 2025 · getfluently.app

  • Conversational AI surveys, interviews, user tests, polls

    AI · 2025 · theysaid.io

  • Record your screen, share instantly, look like a PRO

    Growth · 2025 · supercut.ai