typeover
curriculum

Curriculum Basics

module 1 of 4

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.


themes

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…

9 ready begin →

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…

9 ready begin →

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…

9 ready begin →

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…

9 ready begin →

Zig functions look like TS with the type annotations shifted: fn name(param: Type) ReturnType { ... }. Visibility is opt-in via pub fn — top-level functions are private by defa…

9 ready begin →

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…

9 ready begin →

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…

9 ready begin →

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…

9 ready begin →