Zig course

Zig Level 6: Comptime

Comptime is level 6 of 11 of the LoWisa Zig course. It has 3 lessons and 9 ideas. Below is every lesson and what it teaches, in one line each.

Updated 2026-11-25

Compile-Time Evaluation

  • comptime. comptime runs Zig at compile time: the same language, executed while building.
  • comptime parameters. A comptime parameter must be compile-time known: types and configuration as arguments.
  • Compile-time asserts. comptime asserts check invariants at build: wrong configurations refusing to compile.

Generic Programming

  • Types as values. Types are values at comptime: fn List(comptime T: type) type returns a new struct.
  • Duck-typed generics. Generic code checks per instantiation: capabilities verified where used, errors at the call site.
  • std as the example. The standard library IS the generics textbook: ArrayList and HashMap built from comptime.

Compile-Time Code Generation

  • Inline for. inline for unrolls over fields and types at compile time: reflection without a runtime.
  • @typeInfo. @typeInfo inspects types as data: serialisers and validators generated from struct shapes.
  • Restraint. comptime power is budgeted: readable instantiations over clever meta-towers.

Before and after this level

In the app each of these ideas is taught and then asked back, and the level ends with a checkpoint and flashcards. See Checkpoints and flashcards.

Frequently asked questions

What does Zig Level 6: Comptime cover?

Compile-Time Evaluation, Generic Programming, Compile-Time Code Generation: 3 lessons and 9 ideas.

What should I know before this level?

The level before it, Level 5: Errors & Optionals, which covers Error Unions, Optionals, Explicit Failure Handling.

Learn Zig on your phone

The first level is free. LoWisa is on Google Play and the App Store.