# Zig Level 6: Comptime

> Level 6: Comptime of the LoWisa Zig course: Compile-Time Evaluation, Generic Programming, Compile-Time Code Generation. 3 lessons and 9 ideas, each explained in one line.

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

## 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

- **Before:** [Level 5: Errors & Optionals](/courses/zig/level-5-errors-and-optionals/): Error Unions, Optionals, Explicit Failure Handling.
- **Next:** [Level 7: Modules & Build System](/courses/zig/level-7-modules-and-build-system/): Modules, Zig Build, Dependencies and Cross Compilation.

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](/help/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.

---

Source: https://lowisa.dev/courses/zig/level-6-comptime/ · Updated 2026-11-25
