Zig by Example

Lobsters Hottest Tools

Summary

Zig by Example is a hands-on introduction to the Zig programming language, featuring annotated example programs for version 0.16.

<p>Inspired by the infamous <a href="https://gobyexample.com/" rel="ugc">Go by Example</a></p> <p><a href="https://lobste.rs/s/s75zd9/zig_by_example">Comments</a></p>
Original Article
View Cached Full Text

Cached at: 07/25/26, 02:04 PM

# Zig by Example Source: [https://zigbyexample.neocities.org/](https://zigbyexample.neocities.org/) [Zig](https://ziglang.org/)is a general\-purpose programming language and toolchain for maintaining robust, optimal and reusable software\. Please read the[official documentation](https://ziglang.org/documentation/0.16.0/)to learn more\. *Zig by Example*is a hands\-on introduction to Zig using annotated example programs\. **The examples are written for version 0\.16\.**Check which version you’re using if something isn’t working\. ## Getting Started - [Hello, World\!](https://zigbyexample.neocities.org/hello-world.html) - [Formatted Output](https://zigbyexample.neocities.org/formatted-output.html) - [Unit Tests](https://zigbyexample.neocities.org/unit-tests.html) - [Basic Types](https://zigbyexample.neocities.org/basic-types.html) - [Variables](https://zigbyexample.neocities.org/variables.html) - [Illegal Behavior](https://zigbyexample.neocities.org/illegal-behavior.html) - [Build Modes](https://zigbyexample.neocities.org/build-modes.html) ## Basic Types - [Integers](https://zigbyexample.neocities.org/integers.html) - [Integer Operators](https://zigbyexample.neocities.org/integer-operators.html) - [Floating\-point Numbers](https://zigbyexample.neocities.org/floating-point-numbers.html) ## Functions and Errors - [Functions](https://zigbyexample.neocities.org/functions.html) - [Errors](https://zigbyexample.neocities.org/errors.html) - [Assertions](https://zigbyexample.neocities.org/assertions.html) ## Control Flow - [If Statements](https://zigbyexample.neocities.org/if-statements.html) - [Switch Statements](https://zigbyexample.neocities.org/switch-statements.html) - [While Loops](https://zigbyexample.neocities.org/while-loops.html) - [For Loops](https://zigbyexample.neocities.org/for-loops.html) - [Blocks](https://zigbyexample.neocities.org/blocks.html) - [Defer](https://zigbyexample.neocities.org/defer.html) - [Errdefer](https://zigbyexample.neocities.org/errdefer.html) ## Compound Types - [Arrays](https://zigbyexample.neocities.org/arrays.html) - [Slices](https://zigbyexample.neocities.org/slices.html) - [Pointers](https://zigbyexample.neocities.org/pointers.html) - [Optionals](https://zigbyexample.neocities.org/optionals.html) - [Structs](https://zigbyexample.neocities.org/structs.html) - [Tuples](https://zigbyexample.neocities.org/tuples.html) - [Enums](https://zigbyexample.neocities.org/enums.html) - [Unions](https://zigbyexample.neocities.org/unions.html) - [Tagged Unions](https://zigbyexample.neocities.org/tagged-unions.html) ## Standard Library - [Allocators](https://zigbyexample.neocities.org/allocators.html) - [ArrayList](https://zigbyexample.neocities.org/arraylist.html) - [AutoHashMap](https://zigbyexample.neocities.org/autohashmap.html) - [StringHashMap](https://zigbyexample.neocities.org/stringhashmap.html) - [HashMap](https://zigbyexample.neocities.org/hashmap.html) - [Sorting](https://zigbyexample.neocities.org/sorting.html) - [Random](https://zigbyexample.neocities.org/random.html) ## Command\-line Programs - [Arguments](https://zigbyexample.neocities.org/arguments.html) - [Environment Variables](https://zigbyexample.neocities.org/environment-variables.html) - [Exit Status](https://zigbyexample.neocities.org/exit-status.html) ## Async/Await and I/O - [Async](https://zigbyexample.neocities.org/async.html) - [Io Implementations](https://zigbyexample.neocities.org/io-implementations.html) - [Queue](https://zigbyexample.neocities.org/queue.html) - [File System](https://zigbyexample.neocities.org/file-system.html) - [Text I/O](https://zigbyexample.neocities.org/text-io.html) - [Binary I/O](https://zigbyexample.neocities.org/binary-io.html) ## Comptime - [Comptime](https://zigbyexample.neocities.org/comptime.html) - [Precomputed Data](https://zigbyexample.neocities.org/precomputed-data.html) - [Generic Functions](https://zigbyexample.neocities.org/generic-functions.html) - [Generic Types](https://zigbyexample.neocities.org/generic-types.html) - [Reflection](https://zigbyexample.neocities.org/reflection.html) ## Zig Tooling - [Build System](https://zigbyexample.neocities.org/build-system.html) ## Zig and C - [Using C](https://zigbyexample.neocities.org/using-c.html) - [C Types](https://zigbyexample.neocities.org/c-types.html) - [Time and Date](https://zigbyexample.neocities.org/time-and-date.html) [Zig by Example](https://zigbyexample.neocities.org/index.html)·[about](https://zigbyexample.neocities.org/about.html)·[source](https://codeberg.org/levin/zigbyexample)

Similar Articles

Zig by Example

Hacker News Top

A hands-on introduction to the Zig programming language via annotated examples, covering basic to advanced topics. Inspired by Go by Example.

Returning to Zig

Lobsters Hottest

The author describes their journey from Zig to Rust and back to Zig, exploring the trade-offs between stability and expressiveness in programming languages.

Why I Wrote a Game Boy Advance Game in Zig (2024)

Lobsters Hottest

A developer explains why they chose the Zig programming language to create a Game Boy Advance game, highlighting Zig's cross-compilation capabilities and suitability for embedded programming.

Build your project Zig-style

Lobsters Hottest

The author details building a tool called bygge-zig that uses the Zig build system to compile Rust projects, replicating Cargo's functionality in far fewer lines of code, highlighting the differences and challenges.

Writing a C Compiler, in Zig

Hacker News Top

A developer documents their experience building a C compiler named paella in Zig, following Nora Sandler’s tutorial series.