How Our Rust-to-Zig Rewrite Is Going(rtfeldman.com)
504 points by jorangreef 1 day ago | 268 comments
tl;dr: The Roc team rewrote their 300K-line compiler from Rust to Zig over 18 months, hitting feature parity and gaining benefits like hot code loading, zero-parse deserialization, and eventually ~35ms incremental builds (vs Rust's 3.4s). Memory safety concerns proved overblown: only 2 use-after-free bugs occurred in the Zig compiler itself, both minor. Key reasons for choosing Zig included better memory allocator control, faster builds, and access to Zig's LLVM bitcode serializer, though they miss Rust's borrow checker, private fields, and backwards-compatibility guarantees.
HN Discussion:
  • Challenges the article's claim that compilers inherently require memory-unsafe operations for emitting machine code
  • Disputes the article's assertion that Zig's ReleaseSafe catches use-after-free errors
  • Questions the rigor of the language selection process and the assumption that a low-level systems language was necessary
  • ~Agrees that Zig's fast incremental builds are compelling, though expects Rust to catch up eventually
  • Prefers Rust due to its post-1.0 stability and library ecosystem over Zig's build speed advantages