Learn Zig from printing to standard output to a small project, writing explicit, careful code with every exercise checked as you go.
8 lessons, 16 exercises. Runs Zig 0.17.
Not started
Hello, output
Write a Zig main function, print to standard output through a buffered writer, and add comments.
Values and variables
Declare constants and variables with const and var, pick integer, float, bool and string types, and meet Zig's strict compiler checks.
Reading input and arithmetic
Read lines from standard input with a buffered reader, parse them into numbers, and do arithmetic with Zig's explicit operators.
Making decisions
Branch with if and else, use them as expressions, match values and ranges with switch, and combine conditions with and, or and !.
Loops
Repeat work with while loops and their continue expressions, for loops over ranges, and break and continue for early exits.
Functions
Write functions with typed parameters and return values, return errors with error unions and try, and learn what a function can see.
Collections
Use arrays and slices, grow lists with ArrayList and an allocator, and count things with a hash map.
Strings and a small project
Work with strings as byte slices using std.mem and std.ascii, group data in a struct, and combine everything into a receipt printer.
Your progress is saved in this browser. Sign in to keep it on every device.