KotobaDocs

Learn the Amu compiler step by step

Amu checks Kotoba programs and turns them into artifacts for a selected execution target. This course starts with a program that returns 42, then gradually adds features while following the path from source to native execution. Along the way, it connects Kotoba forms, IPLD, Unison-inspired content-addressed definitions, the Kototama VM, and performance engineering.

You need to know functions, variables, and conditionals. Each chapter introduces the compiler, Lisp, and IPLD concepts it uses, with an example, an explanation, source references, and an exercise with an answer. Like Simple, the course follows a gradual learning path; it reads the real Amu implementation rather than copying a separate compiler into each chapter.

English is the default. The language links on each page switch between the English and Japanese versions of that page. Both versions share the executable examples and recorded observations.

Contents

ChapterWhat you learnWhat you work with
01 The first 42 and the big pictureThe roles of Amu, Kotoba, Kototama, and AiueOSReturning an integer
02 Source and Kotoba formsS-expressions, syntax trees, canonical forms, reader sugarReading addition as a tree
03 Reading and name resolutionLexing, reading, scope, and resolved referenceslet and an undefined name
04 Type checking and intermediate representationsChecked KIR, the Seed tree, and SIRType errors and conditionals
05 IPLD and content addressingDAG-CBOR, CIDs, blocks, and handlesDistinguishing source from definitions
06 Unison-inspired definition identityAlpha normalization, dependency CIDs, recursive SCCsRenaming and dependency updates
07 Effects and authorityStatic effects, grants, invocation admissionRefusing an unsupported operation
08 Machine code and executablesLowering, instruction selection, registers, fixups, ABILoops and function calls
09 The Kototama VMTransitions, IPLD state, admission, receipts, typed evalDescribing one execution
10 Making generated code fasterStructural recognition, constants, loops, SIMD, fuel and boundsComparing observable behavior
11 Faster builds and selfhostingCompiler costs, DefCID caches, self-rebuildsDesigning reuse conditions
12 Reading the implementation and running experimentsSource exploration, negative controls, measurements, SimpleCompleting a small investigation

Run the first example

Use the native CLI on an Apple Silicon Mac. Read the Amu checkout's public entry scope and instructions first. Replace /path/to with the actual locations.

/path/to/amu/bin/amu check /path/to/this/docs/learn/amu/examples/00-literal.kotoba
/path/to/amu/bin/amu run /path/to/this/docs/learn/amu/examples/00-literal.kotoba

The commands print ok and 42, respectively. Linux uses its own entry, target, and format; this Mac observation does not qualify Linux or browser execution. See the instructions and observations for all examples.

Four states to distinguish

A language or VM contract defines the behavior an implementation must preserve. Adopted source identifies the composition of a particular compiler. An experiment or candidate is an implementation being investigated. An execution result or measurement is an observation for the recorded artifact, input, and host.

For example, the existence of a DefCID contract does not mean every native build uses a persistent per-definition cache. Running a small native example also does not establish the complete Kototama state, authority, and receipt contract. Each chapter keeps these distinctions beside the feature concerned.

References and reading guide

These primary sources explain the ideas used in the course. Each chapter connects them to Kotoba's own contracts and pinned implementation; a comparison or compatibility profile needs its own implementation evidence.

TopicPrimary sourceConnection to this course
S-expressions and LispMcCarthy's Lisp paper, 1960Symbolic expressions and recursive computation; chapter 2 distinguishes source syntax, frontend trees, and canonical forms.
IPLDIPLD Docs, Data Model, DAG-CBOR specificationValues, content-addressed links, and encoding; chapter 5 separates source, definition, artifact, and value identities.
UnisonThe big ideaDefinition identity and human-readable names; chapter 6 explains Kotoba's checked definition contract and its implementation scope.
SimpleSeaOfNodes/SimpleA chapter-by-chapter compiler learning path; chapter 12 explains which progression and graph ideas are useful when reading Amu.
Filecoin execution modelsFilecoin Virtual Machine, Filecoin EVM runtimeAn execution platform and a runtime layered on it; chapter 9 relates FVM/FEVM to Kototama's VM and compatibility-profile boundaries.

Reference baseline

The reference date is 6 November 2026. Amu implementation links are pinned to a4c16e7c, and Kototama links to b7bbcc44. Relative links lead to language contracts in this repository. Pinned links keep the explanation reproducible when files later move. Check the owning contracts, manifests, and execution evidence when using a newer version.

Back to the language documentation.