A number
getting-started

If you already know how to debug code in your editor of choice, skip this section.

We're not doing printf debugging in 2026. We hover the mouse over a variable and see its current value. We press F10 repeatedly and take a walk through the code as it runs. The debugger is the single best tool for understanding what your program is actually doing -- much better than guessing from a few print lines.

Install VS Code with three extensions: Zig Language, ZLS (Zig Language Server -- gives you autocomplete and error highlighting as you type), and CodeLLDB (lets you debug with breakpoints).

Create a .vscode folder in your project directory with this launch.json:

{
    "version": "0.2.0",
    "configurations": [{
        "type": "lldb",
        "request": "launch",
        "name": "Debug minizig",
        "program": "${workspaceFolder}/minizig.exe",
        "preLaunchTask": "build"
    }]
}

And this tasks.json:

{
    "version": "2.0.0",
    "tasks": [{
        "label": "build",
        "type": "shell",
        "command": "zig build-exe minizig.zig"
    }]
}

(On macOS/Linux, drop the .exe from the program path.)

Now replace your main with this:

pub fn main() void {
    const thing: i64 = 42;
    print("thing = {d}\n", .{thing});
}

thing is a const -- it can't change. Click in the gutter left of the print line -- a red dot appears. That's a breakpoint. Press F5. The program freezes at the dot. Hover over thing -- you see 42.

Now change const to var, and add a line before the print that sets thing to 99. Press F5 again. Step through with F10 and watch the value change in the debugger.

You'll live in this debugger for the rest of the book. Step through code with F10, step into functions with F11, hover over anything to inspect it. When something goes wrong (and it will), this is how you find out why.

const std = @import("std");
const print = std.debug.print;

pub fn main() void {
    var thing: i64 = 42;
    thing = 99;
    print("thing = {d}\n", .{thing});
}