The Roc team has been working on rewriting their compiler from Rust to Zig for over a year and a half, with a focus on achieving feature parity with the original compiler. Recently, they passed an exciting milestone, updating Brendan Hansknecht's WASM-4 game, Rocci Bird, to use the new compiler [1]. This milestone demonstrates the progress made in the rewrite and the potential benefits of using Zig, such as faster build times and improved performance [2]. The team has also implemented hot code loading, which allows for automatic reloading of code during development, and cross-compiled binaries, enabling the creation of static binaries that can run on various platforms [3].

Furthermore, the team has explored pattern matching with string interpolation, a feature that provides type safety and performance benefits [4]. The decision to rewrite the compiler in Zig was motivated by several factors, including the desire for faster build times, better memory control, and a more suitable ecosystem for the project's needs [5]. The team has learned from their experiences with both Rust and Zig, and their choice of Zig has provided benefits such as faster build times and improved performance [6]. However, they also acknowledge the trade-offs and challenges associated with using Zig, such as the need for manual memory management and the potential for memory safety issues [7].

Overall, the Roc team's rewrite journey offers valuable insights into the benefits and challenges of using Zig and the importance of careful consideration when choosing a programming language for a project.

Sources

  1. github.com/lukewilliamboswell/roc-wasm4/blob/d4161199b0a8afd55d24c30dae304b8a0358f433/exam
  2. rtfeldman.com/rust-to-zig
  3. ziglang.org/documentation/master
  4. github.com/roc-lang/roc/blob/012eb3d50f3cd0673a653e1b9bc4f653dbee1eb2/src/builtins/dec.zig
  5. news.ycombinator.com/item?id=48933149
  6. ziglang.org/documentation/0.16.0/#Incremental-Builds
  7. ziglang.org/documentation/0.16.0/#Memory-Safety