Open-Source Careers with Loris Cro

Agreed! Richard has done a lot of Rust programming in the past couple years, so he’s very familiar with it, but he’s also a functional language fan, so that is probably his perspective.

Richard is also working on the Roc language, which the compiler is written in Rust.

This is interesting:

Why does Roc use both Rust and Zig?

Roc’s compiler has always been written in Rust. Roc’s standard library was briefly written in Rust, but was soon rewritten in Zig.

There were a few reasons for this rewrite.

  1. We struggled to get Rust to emit LLVM bitcode in the format we needed, which is important so that LLVM can do whole-program optimizations across the standard library and compiled application.
  2. Since the standard library has to interact with raw generated machine code (or LLVM bitcode), the Rust code unavoidably needed unsafe annotations all over the place. This made one of Rust’s biggest selling points inapplicable in this particular use case.
  3. Given that Rust’s main selling points are inapplicable (its package ecosystem being another), Zig’s much faster compile times are a welcome benefit.
  4. Zig has more tools for working in a memory-unsafe environment, such as reporting memory leaks in tests. These have been helpful in finding bugs that are out of scope for safe Rust.

The split of Rust for the compiler and Zig for the standard library has worked well so far, and there are no plans to change it.