Every function declares what it is allowed to do.
A beginner's book for the Capa programming language, written by Nelson Duarte.
This is a hands-on introduction to Capa for complete beginners. It assumes no prior programming experience and builds up from your first program to three complete, end-to-end projects.
The book runs to roughly 278 pages and is organised into didactic chapters, each closing with Try It Yourself exercises, followed by three practical projects and a set of appendices. Appendix E contains worked solutions to the exercises.
Part I: The Basics (the Capa language, from your first program to testing your code)
- Getting Started
- Values and Simple Types
- Lists
- Maps and Sets
- Control Flow
- Functions
- Structs and Sum Types
- Errors as Values
- Your First Capability
- Attenuating Capabilities
- Defining Your Own Capabilities
- Modules, Visibility and Packages
- Information-Flow Control
- Testing Your Code
Part II: Projects (three complete programs, built end to end)
- Project 1: A Grade-Book Tool
- Generating the Report
- Files, Capabilities, and Robustness
- Project 2: Reading an SBOM
- Checking a Policy
- A CI-Ready Tool
- Project 3: Handling Secrets
- A Vault Capability
- The Service, Proven Safe
Appendices
- A. Installation and Troubleshooting
- B. Editors and the Language Server
- C. Capa for Python Programmers
- D. Getting Help and Going Further
- E. Solutions to the Exercises
The book is available as a PDF directly in this repository: download
Capa-The-Capability-Typed-Programming-Language.pdf.
This edition of the book corresponds to the Capa compiler v1.12.0.
- Compiler: https://github.com/nelsonduarte/capa-language
- Website: https://capa-language.com
- VSCode extension: https://marketplace.visualstudio.com/items?itemName=nelsonduarte.capa-language (covered in Appendix B)
The book content is licensed under the Creative Commons Attribution-NonCommercial 4.0 International licence (CC BY-NC 4.0). See the LICENSE file for details.