news.volyx.in

How Our Rust-to-Zig Rewrite Is Going (rtfeldman.com)

530 points by jorangreef · 42 days ago · 310 comments on HN

Article summary

The Roc compiler team has completed a rewrite of their 300,000 lines of Rust code into Zig, achieving feature parity with the original compiler. The team chose Zig due to its faster build times, better memory control, and more relevant ecosystem. The rewrite has unlocked new features for Roc programmers, including hot code loading and cross-compiled binaries. The team reflects on their experiences with Rust and Zig, discussing the trade-offs between the two languages.

Main themes

  • Rust vs Zig
  • Compiler Rewrites
  • Memory Safety
  • Language Design
  • Performance Optimization

What commenters say

  • Zig's incremental builds are a significant advantage over Rust, but it's unclear if Rust will catch up in the near future.
  • Go's runtime is highly optimized, but its performance benefits may not be applicable to all use cases, and its garbage collection may not be suitable for every workload.
  • Adding a borrow checker to Zig is theoretically possible, but it would require significant changes to the language and may not be ergonomic or effective.
  • Some commenters argue that Rust's memory safety features are essential and cannot be replicated in other languages, while others believe that similar safety guarantees can be achieved through other means, such as formal verification or static analysis.
  • The trade-offs between Rust and Zig are complex, and the choice between the two languages depends on the specific needs and goals of a project.
  • Some projects have successfully added safety features to existing languages, but these efforts often require significant investment and may not provide the same level of guarantees as languages designed with safety in mind from the start.