When Zig is safer and faster than Rust: I recently wanted to compare Rust vs Zig, so I wrote a garbage collected bytecode interpreter in both languages It turned out that the Zig version was actually faster AND safer than the Rust version How come?
Garbage collection is a hard problem to solve in Rust, it fundamentally is something that doesn't play nicely with the borrow checker. It's possible to write one in safe Rust, typically using refcounting or arenas+handles, but those seem to be slower than a typical mark/sweep gc
So to compete with Zig (and also for for fun), I decided to practice the dark arts and use unsafe Rust. It turns out that unsafe Rust is hard. There are a lot of complicated rules about undefined behaviour. It's super easy to violate them and cause subtle bugs
@zack_overflow You don't need those, you can simply treat memory directly and keep the reference for the heaps alive, so that your bytecode interpreter accepts the heaps and return the heaps modified for the GC. Exactly how you would do in assembly.