Get AI summaries of any video or article — Sign up free
Why I Chose Rust Over Zig thumbnail

Why I Chose Rust Over Zig

The PrimeTime·
5 min read

Based on The PrimeTime's video on YouTube. If you like this content, support the original creators by watching, liking and subscribing to their content.

TL;DR

Rust’s memory-safety model becomes practical once stack vs. heap lifetimes and Drop behavior are understood.

Briefing

The case for staying with Rust over Zig comes down to one practical reality: Rust’s safety guarantees, mature tooling, and growing ecosystem have reached a level where it’s reliably productive for systems work—while Zig still feels like a promising but moving target.

Long-time C and C++ experience shapes the preference. The discussion starts with why C feels “right” after years in the Linux kernel, including learning how C compiles down to machine code and debugging real low-level failures using register dumps and kernel oopses. That background also highlights C’s pain points: manual memory management, missing built-in data structures, and the fragility of hand-rolled algorithms like balanced binary search trees. Even when C++ modernizations (like C++11 and later) reduced boilerplate via templates and classes, the inherited unsafety still meant debugging remained part of the job.

Rust enters as a response to that unsafety. Memory safety is the headline draw, but the path isn’t smooth: the early Rust era (around 2015) involved a rougher toolchain and a steep learning curve dominated by the borrow checker. Over time—especially after switching to professional Rust work—the borrow checker “clicked,” and concepts like stack vs. heap allocation and automatic deallocation made the model feel simpler than expected. Concurrency also becomes a turning point: understanding traits like Send and Sync helps Rust’s approach to multi-threaded code feel less like guesswork.

Zig earns respect, but not enough to replace Rust. Zig is described as “C-like” at the low level, and its compile-time execution (“comptime”) is treated as a standout capability: type-based reflection and code generation happen during compilation rather than runtime, avoiding the kind of runtime type switching seen in languages like Go. The tradeoff is that Zig’s tooling and ecosystem lag behind Rust’s. The lack of widely available books and the churn in the toolchain make learning harder, and third-party support—especially for tools like GitHub Copilot—doesn’t work as well. Industry adoption also weighs heavily: Rust has major backing signals such as Microsoft writing parts of Windows in Rust and Linux kernel support for Rust, while Zig is still seen as earlier-stage.

Even so, Zig’s runtime safety tooling is praised. Memory leak detection is highlighted as unusually comforting: when deinitialization is forgotten, Zig’s test/build tooling points directly to leaked allocations and where they originated. Null-safety is also treated as a deliberate design choice—using optional pointers (like “?”) forces checks at the right times.

In the end, the decision is framed as a timing and maturity question. Rust is portrayed as “boring” in the best sense: safer, better supported, and productive enough that it remains the default systems language. Zig may be where Rust was in 2015—promising, but not yet ready to displace Rust for this workflow, especially until learning resources and ecosystem stability catch up.

Cornell Notes

The preference for Rust over Zig rests on maturity and day-to-day productivity. Rust’s memory safety model (stack/heap lifetimes, automatic deallocation) and concurrency traits (Send/Sync) eventually become workable after an initial borrow-checker struggle, and the ecosystem has grown substantially since the early Rust era. Zig’s strengths—especially its C-like feel and powerful comptime metaprogramming—are acknowledged, but tooling churn, weaker third-party support, and limited learning resources make it harder to adopt confidently. Zig’s leak detection and optional-pointer safety features are praised, yet Rust’s industry adoption and “safer and boring” reliability keep it as the go-to systems language for now.

Why does C experience matter to the Rust-vs-Zig decision?

The discussion ties C comfort to kernel-level debugging and a deep understanding of how C maps to machine code. That background also exposes C’s recurring failure modes: unsafe memory handling, manual data-structure work (like rolling hash tables and linked lists), and the difficulty of implementing balanced trees correctly (including deletion and balancing rules). Those lessons make Rust’s safety promise feel less abstract and more like a direct fix for familiar pain.

What makes Rust’s borrow checker feel less magical over time?

The borrow checker becomes easier to reason about once the stack/heap model is internalized. Values live on the stack; heap allocations are referenced by fat pointers (pointer plus length/capacity details for strings). When stack variables go out of scope, Drop runs and frees heap data automatically. That turns “freeing” into a lifetime problem rather than a manual action, and returning ownership transfers the responsibility cleanly.

How does concurrency understanding shift the Rust perspective?

After months of friction, the discussion points to Send and Sync traits as key mental tools for multi-threaded Rust. Once those traits and the ecosystem’s concurrency patterns are understood, Rust stops feeling like constant borrow-checker battles and starts feeling like a structured way to write safe parallel code.

What is comptime in Zig, and why does it impress?

Comptime is code executed during compilation, enabling type-based reflection and code generation without runtime type switching. The example uses a duck-typing style check: if a type has both “waddle” and “quack,” it qualifies as a duck; different types (rubber duck vs. duct) lead to different generated functions. The key payoff is that the reflection logic is resolved at compile time rather than via runtime branching.

Why does Zig still lose despite strong safety tooling?

Zig’s memory leak detection is praised—tests/build output can pinpoint leaked allocations and the exact line where deinitialization was missed. Optional pointers also force explicit nil checks. But the overall adoption friction remains: Zig’s ecosystem and third-party tooling (including GitHub Copilot support) are less mature, learning resources are scarce (few books), and the toolchain changes frequently. Industry backing is also framed as weaker than Rust’s.

How do industry adoption signals influence the final choice?

Rust is described as having major momentum: Microsoft writing parts of Windows in Rust and Linux kernel support for Rust are treated as long-term commitment signals. Zig is viewed as earlier-stage—potentially destined to improve, but not yet at the same level of broad, stable adoption and support.

Review Questions

  1. What specific Rust concepts (stack/heap lifetimes, Drop, Send/Sync) are presented as making the language feel simpler or more productive?
  2. Compare Zig’s comptime approach to runtime type switching: what advantage does compile-time resolution provide?
  3. Which factors—tooling maturity, learning resources, third-party support, or industry adoption—carry the most weight in the decision, and why?

Key Points

  1. 1

    Rust’s memory-safety model becomes practical once stack vs. heap lifetimes and Drop behavior are understood.

  2. 2

    Early Rust learning friction is attributed largely to the borrow checker, but professional use helps it “click.”

  3. 3

    Send and Sync traits are highlighted as key to making Rust concurrency feel manageable.

  4. 4

    Zig’s comptime metaprogramming is a major technical strength, enabling type-based reflection and code generation at compile time.

  5. 5

    Zig’s tooling and ecosystem maturity lag—especially learning materials and third-party support like GitHub Copilot—slows adoption.

  6. 6

    Rust’s industry momentum is treated as a decisive factor, citing Microsoft’s Rust work and Linux kernel Rust support.

  7. 7

    Zig’s leak detection and optional-pointer safety are praised, but they don’t outweigh the broader adoption and learning friction for now.

Highlights

Rust’s safety story is grounded in lifetimes: heap allocations are freed automatically when stack-owned owners go out of scope via Drop.
Zig’s comptime enables duck-typing-style checks that generate specialized functions during compilation rather than branching at runtime.
Zig’s test tooling can report memory leaks with precise locations, making missed deinitialization easy to diagnose.
Rust is framed as “safer and boring” largely because of stronger ecosystem maturity and visible industry backing.

Topics

  • Rust vs Zig
  • Borrow Checker
  • Comptime Metaprogramming
  • Memory Safety
  • Tooling Ecosystem

Mentioned

  • Pekka
  • Chris Lner
  • Jared
  • Joran
  • TJ
  • IO
  • AVL
  • Arc
  • mutex
  • C++
  • C
  • Rust
  • C++11
  • CPU
  • AVX
  • GPU
  • TJ
  • Arc mutex