Pudu programming language
Menu
All documentation pages
Documentation

Learn Pudu

Author
Chris M. Pérez Santiago
Version
0.1.0

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.

  1. Chapter 1Introduction

    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.

  2. Chapter 2Getting 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.

  3. Chapter 3Basics

    This page covers what every Pudu file is made of: a module, its imports, and the values and functions it declares.

  4. Chapter 4Functions

    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.

  5. Chapter 5Types

    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.

  6. Chapter 6Text

    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.

  7. Chapter 7Collections

    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.

  8. Chapter 8Control 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.

  9. Chapter 9Errors

    Pudu has no exceptions. Work that can fail says so in its type, and the caller decides what happens next.

  10. Chapter 10Ownership 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.

  11. Chapter 11Modules 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.

  12. Chapter 12Traits 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.

  13. Chapter 13Generics

    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).

  14. Chapter 14Testing

    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.

  15. Chapter 15Files 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.

  16. Chapter 16Data 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.

  17. Chapter 17HTTP 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.

  18. Chapter 18Concurrency

    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.

  19. Chapter 19Standard 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.

  20. Chapter 20Tooling

    Everything is one command: pudu. It checks, runs, tests, formats, and documents programs, and it speaks the language server protocol for editors.