Class Central is learner-supported. When you buy through links on our site, we may earn an affiliate commission.

Coursera

Zig From Zero

Pragmatic AI Labs via Coursera

Overview

Google, IBM & Meta Certificates — All 10,000+ Courses at 40% Off
One annual plan covers every course and certificate on Coursera. 40% off for a limited time.
Get Full Access
By the end of this course you will read Zig source confidently, build static binaries small enough to ship inside a 50-kilobyte microcontainer, pick the right allocator (GeneralPurposeAllocator, ArenaAllocator, FixedBufferAllocator, or page_allocator) for each workload, and tell a data engineering team where Zig wins versus where Rust still owns the problem. The course is pitched at Rust developers. Every Zig idiom is paired with the Rust pattern it replaces — allocator parameters versus `'a` lifetimes, the `!T` error type versus `Result`, `comptime T: type` versus trait bounds plus `derive` plus `macro_rules!`, and `defer` plus `errdefer` versus `impl Drop`. You finish with a clear mental model of when to reach for Zig (Lambda, edge, embedded, C interop) and when to stay with Rust (long-running services with shared state). Six modules cover the language tour, performance optimization, a Marco Polo CLI, four allocator strategies side by side, a Docker multi-stage build for a Zig HTTP server, and the Rust-or-Zig decision rule on a real data team.

Syllabus

  • Why Zig for Rust Developers
    • The four-card framing — memory, errors, generics, cleanup — and the four companion essays that walk each card against the Rust idiom it replaces. Allocator parameters travel through every function signature instead of lifetime annotations, !T plus try replaces Result plus the question-mark operator, comptime T type replaces trait bounds plus derive plus macro_rules, and defer plus errdefer replaces impl Drop with finer-grained lexically visible cleanup.
  • Getting Started with Zig
    • Install Zig 0.13, build a hello-world with zig build-exe, read the four release modes — Debug, ReleaseSafe, ReleaseFast, ReleaseSmall — against the same source file, and cross-compile to a Linux musl target with one -target flag. The week's payoff is the moment a Linux binary falls out of a macOS host with no extra toolchain — the same primitive that drives every later Lambda and edge-runtime deployment.
  • Performance and Optimization
    • The optimization matrix on a 4096-by-4096 matrix multiply — Zig versus Rust versus Go on the same workload — measuring binary size, cold-start, and steady-state throughput across all four release modes. The week teaches the measurement loop that turns "is this faster?" into "by how much, on which dimension, against which baseline?" — the same loop that drives the Lambda and edge decisions in later weeks.
  • CLI Tools and Memory Management
    • Build the marcopolo command-line tool from std.process.argsAlloc with a GeneralPurposeAllocator and std.testing.allocator so a leak fails the test suite, then walk all four standard-library allocators side by side — GPA for application code with debug-mode leak detection, ArenaAllocator for parse-and-discard scopes that free everything in a single deinit, FixedBufferAllocator for stack-only buffers with no heap, and page_allocator for direct mmap-backed allocations.
  • Servers and Microcontainers
    • A 30-line HTTP server using std.net plus std.http, then the multi-stage Dockerfile that lands the final image at single-digit megabytes against a scratch base, then the use-case map for AWS Lambda, edge runtimes, and embedded targets where the binary footprint and cold-start budget dominate the workload's value over the borrow checker's compile-time payoff.
  • Patterns and Production for Zig
    • Zig idioms a Rust developer trips on, when to reach for comptime versus a runtime branch, the Rust-or-Zig decision rule for a data-engineering team, the FFI patterns that let Zig call Rust and Rust call Zig over a C-ABI seam, and the path to Zig 1.0 that tells you which 0.13 features are stable to ship today versus which features need a feature-flag strategy.
  • Capstone Project
    • A culminating practice assignment that synthesizes every framework and pattern from Weeks 1 through 6 into one shippable production Zig component. Pick a Lambda or edge target, walk the four-card framing on the workload, build the Zig handler with a logic-versus-wiring split, ship the multi-stage Dockerfile against a scratch base, and add the named-contract assertInvariant helper that fires on container start before the binary fetches its first invocation. The reference implementation that grounds every deliverable lives at https://github.com/paiml/zig-from-zero — the workspace ships five demos (hello, marcopolo, http-server, sqlite-ws, lambda) that walk every standard-library allocator and every deployment target the course covers.

Taught by

Noah Gift

Reviews

Start your review of Zig From Zero

Never Stop Learning.

Get personalized course recommendations, track subjects and courses with reminders, and more.

Someone learning on their laptop while sitting on the floor.