logo
Kurashizu Blogwhere ideas flow
  • Home
  • News
  • Blog
  • About
  • Home
  • News
  • Blog
  • About

© 2026 Kurashizu. All rights reserved.

Admin·New Post·Service Status
Powered by Cloudflare·01.11.26
← Back to news

How Our Rust-to-Zig Rewrite Is Going

Original article
rtfeldman.com|231 points|128 comments|by jorangreef|Jul 16, 2026

Progress Report: Transitioning the Roc Compiler from Rust to Zig

Date: July 15, 2026

For the last eighteen months, the developers behind the Roc compiler have been engaged in a massive undertaking: translating approximately 300,000 lines of Rust source code into Zig.

We have recently reached a pivotal landmark: full feature parity with the previous compiler implementation.

Given that the Bun team recently detailed their own transition (which moved in the opposite direction—from Zig to Rust), it felt like the perfect moment to analyze our journey and the current state of the project.

🚀 Achieving Feature Parity

Reaching this stage allowed us to update Rocci Bird, a delightful 2024 WASM-4 game created by Brendan Hansknecht (with art by Luke DeVault).

This project serves as an ideal benchmark because the entire game consists of fewer than 1,000 lines of Roc. You can experience it via [itch.io] or directly through WebAssembly.

Controls: Click/tap the game window, then use the Space key (or tap) to make the bird flap. Note: Mobile users should refresh the page to restart since there is no right arrow key.

The transition yielded impressive technical gains. The updated source code is more succinct, and the resulting binary size has plummeted.

MetricOriginal Rust CompilerNew Zig Compiler (--opt=size)
WASM Binary Size>62 KB> 62\text{ KB}>62 KB31 KB31\text{ KB}31 KB
StatusLegacyCurrent

While Rocci Bird is a small project, ensuring it functioned perfectly required the implementation of a vast array of compiler features. Seeing those iconic purple pixels animate again was a rewarding moment for the team. We are currently targeting a version 0.1.0 release for later this year.

🤝 Gratitude and Contributions

This achievement was a collective effort. I want to extend my deepest thanks to the following individuals:

  • Core Architecture:
    • Anthony Bullard & Sam Mohr (The new parser)
    • Jared Ramirez (Type-checker and various other systems)
    • Ayaz Hafiz (Lambda set resolution)
  • Ecosystem & Education:
    • Aurélien Geron (Manually updating 108 Exercism exercises)
    • Stephan (Implementing the "echo" platform for the homepage via a 2.5MB WASM binary)
  • Testing & Feedback:
    • Niclas Åhdén (Prolific production user and bug reporter)
    • JRI98 (Fuzzer error investigation and issue cleanup)
    • Jasper Woudenberg (API design for userspace packages)
  • The Foundation:
    • Folkert de Vries, Brendan Hansknecht, Brian Carroll, Josh Warner, Agus Zubiaga, and Jelle Teeuwissen (The original Rust compiler architects)
  • The Powerhouses:
    • Anton-4 and Luke Boswell (Their contributions across builtins, platforms, and community support are too numerous to list here!)

We also owe a debt of gratitude to our sponsors who make this work possible:

  • Corporate: rwx, Lambda Class, ohne-makler, martian, tweede golf, Vendr, NoRedInk.
  • Individuals: Many generous supporters who fund our contributors.

⏱️ The Timeline: A Comparative Look

Our rewrite spanned 487 days. In contrast, Bun's rewrite of ~500K lines of Zig into Rust took only 11 days.

Difference=487 days−11 days=476 days\text{Difference} = 487\text{ days} - 11\text{ days} = 476\text{ days}Difference=487 days−11 days=476 days

This discrepancy isn't a reflection of the languages themselves. Bun's process was a direct port, whereas our goal was a fundamental redesign. Because we changed so much of the underlying logic, comparing the Rust and Zig codebases is not an "apples-to-apples" comparison.

🛠️ New Capabilities Unlocked

The rewrite wasn't just about the language change; it unlocked critical features for Roc developers.

1. Hot Code Loading & Cross-Compilation

The new compiler now supports hot code loading during the development cycle.

  • Start a server: roc server.roc
  • Modify source code while the server is active.
  • The next incoming request is automatically handled by the updated code.

Hot Loading Demo Placeholder

When it's time for production, roc build server.roc generates a self-contained, LLVM-optimized binary. Furthermore, Roc now offers reliable cross-compilation. For instance: roc build --target=x64musl This produces a static Alpine Linux binary that is byte-for-byte identical regardless of whether it was compiled on a Mac or another OS.

2. Pattern Matching with String Interpolation

We have introduced a powerful new feature: string interpolation within pattern matching. This is not a runtime template string parse, but a compile-time, type-safe mechanism.

Consider this HTTP request handler:

match ( verb , path ) {
    ( "GET" , "/users/ ${ id } / ${ page } " ) = 
        match page {
            "" | "profile" = ok ( id )
            "settings" = ok ( with_default ( user_agent , id ) )
            "posts/ ${ post_id } " = ok ( "Post ID: ${ post_id } " )
            _ = not_found
        }
    ( "GET" , "/users/ ${ id } " ) = ok ( id )
    ( "POST" , "/posts/new" ) = created ( with_default (…) )
    _ = not_found
}

This approach ensures that the routing logic is handled efficiently and safely at the compiler level.