Curriculum Basics
Basics
The "you already know this, just spelled differently" module for Zig. Imports, entry points, variables, control flow, functions, the string-is-a-slice convention, and optionals. By the end, you trust that typeover's translation pattern works for Zig too, and writing a hello-world Zig program feels familiar.
1.1
Hello and output
Two reflexes Zig wants you to internalise on day one.
- Imports use a builtin, not a keyword. const std = @import("std");
binds the standard library to a name. There's no…
Zig defaults the other way from TypeScript. const is the default reflex; var is the explicit opt-in when you need to reassign. Type annotations come AFTER the name (`var x: i32…
Zig's if looks like TypeScript's: parens around the condition, optional braces around the body. The catch: Zig has no truthy values — the condition must be bool. switch is an…
1.4
while and for
Zig has while (cond) { ... } for condition-driven loops and for (slice) |item| { ... } for iteration. The C-style three-clause for (init; cond; step) is gone — its replacemen…
TypeScript has one numeric type — number — that swallows everything from booleans to billions. Zig is the opposite: every integer width is explicit (i8, i16, i32, i64, `u…
There's no String type in Zig. String literals are byte slices typed as []const u8 — same shape as any other slice of read-only bytes. Length comes from .len (a usize), ind…
1.8
Optionals (?T)
TypeScript uses T | null (or T | undefined) to mark "maybe absent" values; Zig's analogue is the type prefix ?T. A ?T value is either some T or null. Three idiomatic wa…