Zig by Example
Summary
A hands-on introduction to the Zig programming language via annotated examples, covering basic to advanced topics. Inspired by Go by Example.
View Cached Full Text
Cached at: 06/08/26, 03:17 PM
boringcollege/zig-by-example
Source: https://github.com/boringcollege/zig-by-example
Zig by Example
A hands-on introduction to Zig via annotated examples. Zig is a general-purpose, compiled systems language focused on robustness, optimality, and simplicity — no hidden control flow, no hidden allocations, no preprocessor.
Written by Dariush Abbasi for Boring College
- Hello, World
- Values
- Variables
- Integers
- Floats
- Strings
- Arrays
- Slices
- Vectors
- Structs
- Enums
- Unions
- Functions
- Blocks and Statements
- If / Else
- Switch
- While Loops
- For Loops
- Defer
- Errors
- Optionals
- Pointers
- Multi-Pointers
- Slices (Pointers)
- Comptime
- Generics
- Memory Allocation
- ArrayList
- HashMap
- Linked List
- Testing
- Formatting and Print
- File I/O
- Processes
- JSON
- Random Numbers
- Sorting
- Math
- Build System
- C Interop
Further Reading
Zig by Example is inspired by Go by Example by Mark McGranaghan. Examples target Zig 0.14.
Contributions welcome — see CONTRIBUTING.md.
Similar Articles
Zig by Example
Zig by Example is a hands-on introduction to the Zig programming language, featuring annotated example programs for version 0.16.
The Zig Journey
The blog post reflects on attending Zigtoberfest and provides tiered advice for using the Zig programming language, focusing on systems thinking, design depth, and software perfection.
Returning to Zig
The author describes their journey from Zig to Rust and back to Zig, exploring the trade-offs between stability and expressiveness in programming languages.
What Zig felt like, coming from Rust
An experienced Rust developer shares their journey of learning Zig by reimplementing a JSONPath tool, highlighting differences in IDE support and code organization.
Zig: From Beginner to Slightly Less Beginner
In his Zig talk at Code Maven, Sawyer X uses examples of configuration parsing and memory allocation to explain Zig’s core design philosophy: everything is visible, there is no hidden control flow, there are no macros or operator overloading, and problems should be turned into compile-time errors whenever possible.