How Our Rust-to-Zig Rewrite Is Going
Points and comments are a snapshot, not live.
Roc's compiler rewrite from Rust to Zig achieved feature parity after 487 days.
The Roc compiler team rewrote 300,000 lines of Rust into Zig over 487 days, reaching feature parity. The new compiler unlocks hot code loading, cross-compilation, and pattern matching with string interpolation. The original compiler had 1,200 `unsafe` blocks; Zig's `ReleaseSafe` catches use-after-free at runtime. Build times and memory control were key reasons for the switch. The rewrite was motivated by architectural issues with lambda set specialization, which a prototype in OCaml showed required a full rewrite. The new compiler produces smaller Wasm binaries (31KB vs. double that) and supports zero-allocation HTTP routing.
What commenters are saying
Commenters were surprised Roc was still active, praising the 35ms incremental rebuild and hot code loading. The thread split into two camps: those valuing Rust's borrow-checker safety vs. those prioritizing Zig's faster builds and memory control. Some disputed the claim that compilers emitting machine code inherently need memory-unsafe operations, arguing that's only true for runtime features like hot patching. Several commenters noted that Rust's compile times are improving, while Zig has no plans for borrow-checker safety. A Zig team member confirmed the 35ms rebuild time is largely overhead from detecting changed files, not code generation.