Curriculum Types
Types
Zig's type vocabulary is similar enough to TypeScript that you can lean on the analogues — struct matches object literals, enum matches string literal unions, union(enum) matches discriminated unions. The diverging bits are pointers (*T, *const T, [*]T, ?*T — each meaning something specific) and arrays vs slices ([N]T length-in-type vs []T slice). Lays the type foundation that Memory + Errors + Comptime build on.
TypeScript reaches for string-literal unions ("red" | "green" | "blue") for enums and discriminated unions ({ kind: "circle", radius: 5 } | { kind: "square", side: 3 }) for sum…
2.4
Arrays vs slices
Zig has two collection shapes where TypeScript has one. [N]T is a fixed-length array; the length N is part of the type, known at compile time. []T is a slice: a pointer plus a runt…