Keyboard shortcuts

Press ← or → to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

Introduction

简体中文

Puddi is a statically typed, expression-oriented language that compiles to WebAssembly. One source language targets the browser, WASI runtimes (servers, edge functions, command-line tools) and plugin hosts. Programs use the WebAssembly engine’s garbage collector (WasmGC) and talk to their host through the Component Model.

@derive(Eq, Show)
struct Todo {
    title: Str
    var done: Bool
}

fn main() {
    let todos = [Todo { title: "spec", done: true }, Todo { title: "compiler", done: false }]
    let pending = todos.filter(|t| !t.done)
    print("{pending.len()} of {todos.len()} left")
}
1 of 2 left

At a glance

TopicPuddi
OutputWebAssembly only; JavaScript appears only as loader glue
Hostsbrowser, wasi (WASI 0.3), plugin (any Component Model host)
MemoryWasmGC, no manual memory management
Typesstatic, with local type inference
Polymorphismgenerics, nominal traits, dyn Trait
Missing values and errorsno null: Option, Result, ?, AnyErr; panics trap
Mutabilitylet and var bindings, mutability declared per field
NumbersInt is 32-bit and overflow traps; lossless widening is implicit
Concurrencyasync fn, .await, structured task scopes, isolated workers
Toolchainone pud command, a pud.toml manifest, git-based packages

How this book is organized

  • Getting started installs pud and walks through a first program and a first package.
  • Language guide introduces the language one topic at a time. Every complete example in it is compiled, and the ones with output are run, against the released toolchain.
  • Toolchain and Host interop cover building for each target and talking to hosts.
  • Standard library lists the prelude and the std modules.
  • Reference holds the language specification, which is the normative definition of Puddi, and the conformance suite that checks the toolchain against it.

This book documents Puddi 0.1, the first release. The language is a draft and may still change between 0.x releases; the changelog records what changed.

Choose a path

I want toStart here
Run a command-line programHello, Puddi and the bundled examples
Put a program on a web pageThe browser
Write a plugin for an existing hostPlugins and WIT imports
Understand a compiler errorTroubleshooting and the implementation status
Work on the compilerCompiler development and contributing

Getting help