brain
tamnd's digital brain — notes, problems, research
42734 notes
A generic data structure is a data structure that works with more than one element type.
Type coercion means Zig converts a value from one type to another when the conversion is safe and well-defined.
A state machine is a simple way to describe a program that moves between fixed states.
A dynamic string is text whose length is not fixed ahead of time.
A build option is a value passed from the command line into build.zig.
Queues and stacks are two simple ways to organize a collection of items.
The page allocator asks the operating system for memory directly.
@typeInfo asks the compiler for structured information about a type.
Reflection means inspecting a type as data.
An error union is a value that can contain either:
A union stores one active field at a time.
Zig string data is usually stored as UTF-8 bytes.
Zig programs use memory in different places. The two most important places are the stack and the heap.
Terminal programming means writing programs that interact with the command line as more than simple text output.
A static file server is a program that reads files from a directory and sends them to a browser over HTTP.
@Type builds a type from compile-time type information.
Generating code at compile time means using Zig code to create specialized program behavior before the final executable is built.
anytype means the function parameter can accept many different types.
A tagged union is a type that can store one value from several possible shapes.
A sentinel-terminated array is an array with a special value at the end.
An opaque type is a type whose internal structure is hidden.
One of Zig’s strengths is compiler diagnostics. Zig tries to explain problems precisely instead of silently accepting dangerous behavior.
Zig does not have a separate built-in mutable String type.
An enum is a type whose value must be one item from a fixed list.
A linked list is a collection where each item points to the next item.
A C struct groups several fields into one value.
Fuzz testing means testing a program with many generated inputs.
A fixed buffer allocator gives memory from a buffer you already own.
@alignOf asks the Zig compiler for the required memory alignment of a type.
A compile-time loop is a loop that runs while Zig is compiling your program.
Parsing is the part of the compiler that reads source code and turns it into structure.
A Zig project can depend on other Zig packages.
macOS is one of Zig’s main desktop targets. You can use Zig on macOS to write command-line tools, development utilities, servers, libraries, and cross-platform applications.
Writing a file means sending bytes from your program to the operating system so they can be stored on disk.
An atomic operation is a small operation that can safely happen while several threads are running.
Alignment is a rule about where a value may be placed in memory.
Errors are for expected failures.
A plugin architecture lets a program be extended without rewriting the whole program.
Modern CPUs are fast, but memory is much slower.
Systems programming means working directly with the operating system.
Most Zig programs start with small error sets:
A generic function is a function that works with many types instead of only one type.
A JSON parser reads JSON text and turns it into data your program can use.
const std = @import"std";
A vector is a fixed-size group of values of the same type.
An anonymous struct is a struct type without a name.
A string literal is text written directly in your source code.
Pointer arithmetic means moving a pointer forward or backward through memory.
An error API is the part of your function signature that tells callers how failure works.
An exported function is a function made visible outside the current Zig program.
Calling a C function from Zig has three parts.
An arena allocator is an allocator that frees many allocations at once.
A StringHashMap is a hash map where the key is a string.
A table-driven test checks many input cases with one test loop.
@sizeOf asks the Zig compiler how many bytes a type needs in memory.
Inline branching means Zig chooses a branch during compilation, not during runtime.
An optional pointer is a pointer that may have no value.
Propagating an error means passing it to the caller instead of handling it immediately.
A calling convention defines how functions communicate at the machine level.
A compile error means Zig refused to build your program.
A slice is a view into memory.
A pointer stores the address of a value in memory.
A normal Zig struct is designed for ordinary data modeling.
When people talk about Zig compiler internals, they often mention stage2.
An inline function is a function where the compiler may place the function’s code directly at the call site instead of performing a normal function call.
Some parts of a program should never run.
When you first open the Zig source code repository, it can feel overwhelming.
Linux is one of the most natural platforms for Zig. Many Zig programs are built, tested, and deployed on Linux because Linux is common in servers, containers, embedded...
Reflection means a program can inspect information about types while the program is being compiled or running.
When a program feels slow, your first job is not optimization.
A system call is a request from your program to the operating system.
A mutex is a lock for shared data.
@cImport is Zig’s built-in way to import C declarations from header files.
Reading a file means asking the operating system for bytes stored on disk.
A unit test checks one small piece of code in isolation.
A Zig build is made from steps.
A HashMap is a data structure for storing values by key.
The general purpose allocator is Zig’s standard allocator for ordinary heap allocation.
One of the first Zig builtins you will learn is @import.
In the previous section, you learned that Zig can execute code during compilation.
errdefer is a cleanup tool.
An anonymous function is a function without a permanent name.
Many programs need to clean something up after using it.
Optional unwrapping means taking the value out of an optional.
A slice is a view into a sequence of values.
A slice is a view into a sequence of values.
A struct field can have a default value.
catch handles an error at the place where it happens.
Functions are values.
Zig has normal loops that run when the program runs.
Zig 0.16.0 was released on April 14, 2026. The release contains 8 months of work, with changes from 244 contributors across 1,183 commits. The largest themes are the new I/O...
The Zig compiler is not only a compiler for the Zig language. It is also the center of the Zig toolchain.
In this project, we will build a small command-line calculator.
Windows is one of Zig’s main supported platforms. You can write Zig programs on Windows, build Windows executables, call Windows system APIs, link with C libraries, and...
Zig has a formatting system built into the standard library. You have already used it many times through std.debug.print.
Performance is one of the main reasons people choose Zig.
A memory mapped file is a file that the operating system places into your program's address space.
A thread is a separate path of execution inside one program.
Zig works unusually well with C because it treats C as a first-class part of systems programming.
Zig has a built-in test system. You do not need a separate testing library to start writing tests.