Computer Science with Zig
Checkpoints
- Boolean Basis Learn how Zig's bool type works, how comparison and logical operators produce and combine boolean values, and how short-circuit evaluation can make your conditions both safer and more efficient.
- Calling Stack Basis Learn how the call stack manages function calls at runtime: what a stack frame contains, how the stack pointer tracks active frames, and what causes a stack overflow.
- Code Block Basis Learn what code blocks are in Zig, how they create their own scopes and control variable lifetimes, and how Zig's unique block-as-expression feature lets a block produce a value using labeled break — eliminating the need for many temporary variables.
- Condition Statement Basis Learn how to branch program execution in Zig using if/else if/else, if as an expression, optional unwrapping with if, and switch — including how Zig's strict bool requirement and exhaustive switch matching help you write safer, more correct branching logic.
- Float Number Basis Explore Zig's floating-point types in depth: how IEEE 754 represents fractional values, the five float widths Zig provides, writing float literals and scientific notation, arithmetic operators, special values (NaN and infinity), precision pitfalls, and safe conversion between float and integer types.
- Function Basis Learn how to declare and call functions in Zig, how parameters and return values work, why the pub keyword controls visibility, and how keeping functions small and focused makes programs easier to understand and change.
- Represent Graph in Zig Basis The adjacency matrix and the adjacency list store the same graph with opposing trade-offs: the matrix gives O(1) edge lookup but uses O(n²) space, while the list uses O(n+m) space but makes neighbor enumeration proportional to the actual degree. You will implement both in Zig and learn when each is the right choice.
- Hash Map Basis A hash map stores key-value pairs and retrieves any value by its key in O(1) average time. You will learn to use Zig's standard-library hash maps as a black box: how to create them, insert and look up entries, and decide when a hash map is the right tool.
- Integer Basis Explore Zig's integer type system in depth: arbitrary-width types, numeric literals in different bases, arithmetic operations, overflow behavior across build modes, and safe type casting with `@as`, `@intCast`, and `@truncate`.
- Standard Input and Output Basis Programs need to talk to the outside world. This checkpoint covers Zig's standard I/O — printing to stdout, reading from stdin, parsing numbers from text, and handling the errors that I/O inevitably raises.
- Loop Statement Basis Learn how Zig's while and for loops work, how to control loop flow with break and continue, and how loops can be used as expressions that produce a value.
- Allocate Heap Memory Basis The stack cannot hold data that is too large or whose size is unknown at compile time. This checkpoint explains how to allocate and free heap memory in Zig using its allocator interface, why getting that pairing wrong causes serious bugs, and how Rust's ownership system eliminates those bugs at compile time.
- Memory Layout Basis
- Pointer Basis A pointer stores a memory address rather than a value directly. You will learn how to create and dereference pointers in Zig, why every pointer is the same size regardless of what it points to, and why recursive data structures cannot exist without them.
- Preparing Zig Environment Basis Learn why this course uses Zig to teach computer science fundamentals, and set up Zig on your Unix-like system so you are ready to write and run low-level code.
- Recursion Basis A recursive function calls itself to solve a smaller version of the same problem. This checkpoint explains how recursion uses the call stack, why every recursion needs a base case, and when an iterative loop is the better fit.
- Simple Variable Basis Learn what variables are, how to declare them in Zig with `const` and `var`, the four fundamental types (integers, floats, booleans, and pointers), how to print their values, and how Zig's scope rules control where a variable lives.
- String Basis In Zig, a string is a slice of bytes (`[]const u8`). This checkpoint explains how string literals are stored in memory, why the number of bytes is not always the number of visible characters, and how to perform common operations like printing, slicing, comparing, and building strings at runtime.
- Summary of Zig Course Basis A review of everything covered in the Zig course — from primitive types to manual memory management and recursive algorithms — and a bridge to the Rust and JavaScript/TypeScript courses ahead.