# Colophon

## Colophon

This book describes the Zig programming language as of Zig 0.16.

The examples were written to stay small. Most fit on one screen. The intent was not to demonstrate every feature at once, but to show one idea clearly before introducing the next.

Zig encourages direct programs:

- values have visible ownership
- allocation is explicit
- errors are explicit
- mutation is explicit
- control flow is explicit

The language avoids hidden allocation, hidden exceptions, hidden preprocessing stages, and hidden runtime behavior. Many parts that would be compiler magic in other systems are ordinary Zig code.

The standard library follows the same style. It exposes operating system facilities with relatively little abstraction. Containers, allocators, formatting, networking, filesystems, and testing tools are built from small parts rather than large frameworks.

The compiler itself is also part of the language experience. Zig treats warnings as errors in many situations:

```text
unused variables
ignored errors
unreachable states
invalid casts
unsafe arithmetic
```

This makes programs stricter early, while they are still small enough to repair easily.

Several themes appear repeatedly through the book.

First, types are real values at compile time. Generic programming, reflection, and code generation come from ordinary language mechanisms rather than a separate template language.

Second, memory management is visible. A function that allocates memory usually receives an allocator explicitly.

```zig
fn readFile(
    allocator: std.mem.Allocator,
) ![]u8 {
    ...
}
```

The caller can then choose the allocation strategy.

Third, errors belong in types. A function that may fail declares that fact directly.

```zig
fn parseInt(text: []const u8) !i32
```

The caller must decide how to handle failure.

Finally, Zig keeps the boundary with C simple. A Zig program can call C directly, export functions to C, compile C files, and link system libraries without introducing a separate foreign-function system.

Many modern languages attempt to remove low-level details from the programmer. Zig instead tries to make those details visible and manageable. The result is a language suited for systems software, tools, libraries, embedded targets, command-line programs, game engines, and infrastructure where predictable behavior matters more than abstraction layers.

A reader who finishes this book should be able to:

- read ordinary Zig programs
- write command-line tools
- use allocators correctly
- handle errors explicitly
- build generic containers
- interoperate with C libraries
- understand Zig build scripts
- cross-compile programs
- navigate the standard library
- debug common compiler errors

The next step is not another book. It is source code.

Read the Zig standard library. Read allocators. Read parsers. Read build scripts. Read operating system interfaces. Then write programs small enough that every line still fits in your head.

