Learn Pudu
The language from a first program to traits, ownership, concurrency, and the standard library. Read the chapters in order, or start with the topic you need. Every example on these pages is a complete program that runs as written.
- Introduction
Pudu is a statically typed programming language for programs that are easy to read, safe to change, and honest about failure. What a function takes, what it gives back, whether it can fail, and whether it changes what it was given are all written in its signature, so a reader can tell what code promises without reading its body.
- Getting started
This chapter takes you from an installed compiler to a project with its own modules and tests. By the end you will have run a program, changed it, split it into modules, and checked it with a test suite.
- Basics
This page covers what every Pudu file is made of: a module, its imports, and the values and functions it declares.
- Functions
Functions are where a Pudu program does its work. This chapter covers declaring them, calling them, giving parameters defaults, passing functions as values, and writing function literals.
- Types
Every value in Pudu has one type, known when the program is compiled. This page covers the built-in types, the types a program declares, and the collections the language provides.
- Text
Text in Pudu is the Str type: a sequence of Unicode characters stored as UTF-8. A single character is a Char. This chapter covers writing text, placing values inside it, and the everyday operations on it.
- Collections
Most programs hold many values at once. Pudu has three built-in collections — arrays, maps, and sets — and the standard library adds more for special shapes of data. This chapter covers the three you will use every day.
- Control flow
Pudu's control flow is made of expressions: if and match produce values, and a loop can produce the value it was searching for.
- Errors
Pudu has no exceptions. Work that can fail says so in its type, and the caller decides what happens next.
- Ownership and references
A Pudu value has one owner, and what may change is written where a reader can see it: var on a binding, mut on a record field, and &mut in a signature and at the call. This page covers how values move, how a function borrows a value to read it or to change it, and what the checker refuses.
- Modules and packages
A program grows past one file by splitting into modules. This chapter covers how a module names itself, what it shows to other modules, the ways to import, and how a project and its dependencies are described.
- Traits and methods
A trait names behavior that types can provide. An implementation provides it for one type, and generic code can ask for any type that does.
- Generics
Generic code is written once and used with many types. Array[T], Option[T], and Result[T, E] are generic, and your own functions and types can be too. This chapter builds on [functions](/docs/functions) and [traits](/docs/traits).
- Testing
Tests in Pudu are ordinary programs. A test module builds a suite of checks with Std.Test, runs it, and reports; pudu test finds those modules and runs them. There is no separate test language to learn.
- Files and the system
Programs read files, write output, and ask the machine questions. In Pudu every one of those can fail, so every one returns a Result, and nothing reaches the outside world except through a standard library call you can see.
- Data formats
Programs exchange data as text: JSON between services, CSV from spreadsheets, TOML in configuration files. The standard library reads each into ordinary Pudu values and writes them back, and a malformed document is always a Result you handle rather than a crash.
- HTTP servers and clients
Std.Http.Server answers HTTP requests and Std.Http.Client makes them. A server is built from values — routes, a router, handlers — so most of it can be written and tested without opening a socket.
- Concurrency
Pudu has two tools for work that happens alongside other work: asynchronous functions joined by structured scopes, and host workers that run in parallel and talk over channels.
- Standard library
The standard library ships with the compiler. Every module lives under Std, nothing is imported implicitly, and a program imports exactly what it uses. This page is a map; the [API reference](/modules) documents every public declaration.
- Tooling
Everything is one command: pudu. It checks, runs, tests, formats, and documents programs, and it speaks the language server protocol for editors.
