Captain is a language for programs that are checked before they run. Its main author is increasingly a machine, and people mainly read its programs, review them and approve their plans; so it favours explicit rules, visible boundaries and one obvious way to write each thing. It has two strengths, and this book treats both as first-class:
- operations you can approve. A program's effects are known before any of them happen. You can render the plan, approve it by its digest, and run exactly what you approved. Every run is recorded and can be replayed.
- calculations you can audit. A pure entry has no effects at all. Its numbers are exact decimals, its result is deterministic, and the same inputs always give the same result.
This book is for people who write Captain programs and for people who embed Captain in their own software. It documents the language as the toolchain built from the same source implements it; where something depends on a release, it is on Versions and VM generations.
Part 1. Getting started
Part 2. A tour
Part 3. The language
- Lexical structure
- Modules and names
- Procedures and keyword selectors
- Integers, booleans and conversion
- Text and octets
- Symbols, quantities and tagged values
- Structs and enums
- Option and Result
- Lists and shapes
- Blocks and control
- Types as arguments, and generics
- What Captain leaves out, and why
- Why Captain is the way it is
Part 4. Effects and safety
- Effects
- Frontiers
- Plans and approval
- Secrets, receipts and grants
- Determinism, run records and replay
- Host policies
Part 5. Numbers
Part 6. The standard library
- The standard library: overview
- Using library modules
- Text, lists and logic
- Numbers, tagged values and secrets
- Octets and digests
- JSON and number text
- Processes, HTTP and hosts
- Files
- Compiler-known modules
- The
Stdsource modules - System and tool modules
- Worker, app and Gump modules
Part 7. Embedding Captain
- Embedding Captain in Rust: overview
- The pure profile
- Values in and out
- Limits, run records and errors
- Process and command profiles
Part 8. Where Captain runs
- Captain in the platform's tools: overview
- Forge: build recipes
- Bosun: a project's tasks
- Mate: commands on a machine
- Fleet: servers and their software
- Apps: whole applications in Captain
- Workers: HTTP handlers
- Lifeboat and Gate
Part 9. Reference
How the examples are checked
Every Captain example in this book is checked against the real toolchain:
- a block marked
captainis a whole module, andcaptain checkmust pass; - a block marked
captain failis a whole module that must be refused, and when the block names diagnostic codes, the checker must report each one; - a block marked
captain fragmentis a piece of a program, shown to make a point about syntax. It is not checked on its own, and the text around it says what it belongs to; - a
consolesession markedrunis executed, command by command, and its output compared with the book's. A line...stands for lines left out, and[..]for text left out of a line, such as a digest.