Programming in Goose
Memory-safe systems programming without a heap
Written for Goose v2026.3, October 2026
A book about Goose, a systems programming language with no heap, written for programmers who know C, Odin or Rust. Every example in it is compiled and run as part of building the book, and the output shown is the output the compiler gave.
Download
- Print — Letter, double-sided, notes in the outer margin, 4.6 MB
- Mobile — small pages for reading on a phone, 4.1 MB
- Mobile, dark — the mobile layout on a dark background, 4.1 MB
Contents
- Part IGetting Started
The first five chapters cover the parts of Goose that will feel familiar if you have written C, Odin or Rust: running programs, the scalar types, control flow and functions. Goose has its own opinions even here (about integer widths, about
%, about what a block evaluates to), so even the familiar chapters are worth reading closely. - 1Introduction
- 2Hello, Goose
- 3Values and Types
- 4Control Flow as Expressions
- 5Functions
- Part IIMemory Without a Heap
This part is the heart of the book. It explains where Goose keeps values whose size is not known at compile time, why references into them can never dangle, and how strings, arrays and structs are laid out as plain, contiguous bytes. Read it in order: each chapter builds on the one before.
- 6Where Values Live
- 7The Array Family
- 8References and Slices
- 9Strings Are Bytes
- 10Structs and Inline Data
- 11Optionals
- Part IIIModelling Data
With the memory model in place, this part turns to shaping data: values that can be one of several kinds, structures linked together without pointers, data whose lifetimes do not follow the shape of the code, and the ways a program reports that something went wrong.
- 12Enums in Two Sizes
- 13Links Without Pointers
- 14Pools for Lifetimes That Don't Nest
- 15Errors
- Part IVAbstraction and the Library
This part covers the tools for writing code once and using it many times: generic functions, functions passed as arguments and blocks, recursion, and the standard library that is built from them. It ends with how a program is split across files and how it uses libraries written by other people.
- 16Generics and Blocks
- 17Recursion
- 18A Tour of the Standard Library
- 19Programs, Namespaces and Packages
- Part VSystems Work
The last four chapters of the language proper deal with the program's edges: running work on several threads, saving data to files and loading it back safely, calling C and being called from it, and finding and removing the costs that safety adds.
- 20Threads That Share Nothing
- 21Saving and Loading Bytes
- 22Talking to C
- 23Performance
- Part VITwo Programs
The chapters so far have shown each feature in a snippet of its own. This part shows two complete programs, each a page or two long, and looks at the decisions in them: where the data lives, how errors travel, and what the compiler checks. Neither is built up step by step. Each is shown whole, and then taken apart.
- 24A Word Counter
- 25A Calculator
- AGoose for C, Odin and Rust Programmers
- BLimitations
- CSolutions to the Exercises
- C.1Chapter 2: Hello, Goose
- C.2Chapter 3: Values and Types
- C.3Chapter 4: Control Flow as Expressions
- C.4Chapter 5: Functions
- C.5Chapter 6: Where Values Live
- C.6Chapter 7: The Array Family
- C.7Chapter 8: References and Slices
- C.8Chapter 9: Strings Are Bytes
- C.9Chapter 10: Structs and Inline Data
- C.10Chapter 11: Optionals
- C.11Chapter 12: Enums in Two Sizes
- C.12Chapter 13: Links Without Pointers
- C.13Chapter 14: Pools for Lifetimes That Don't Nest
- C.14Chapter 15: Errors
- C.15Chapter 16: Generics and Blocks
- C.16Chapter 17: Recursion
- C.17Chapter 18: A Tour of the Standard Library
- C.18Chapter 19: Programs, Namespaces and Packages
- C.19Chapter 20: Threads That Share Nothing
- C.20Chapter 21: Saving and Loading Bytes
- C.21Chapter 22: Talking to C
- C.22Chapter 23: Performance
- C.23Chapter 24: A Word Counter
- C.24Chapter 25: A Calculator
The diagrams, text and examples are original. The fonts are Lora, JetBrains Mono and Patrick Hand, under the SIL Open Font License; their licences are in fonts/.