Not sure if many people noticed that we now have a SafeAllocator in 0.17. Zig Documentation
All leaks will be reported. All double free and operation races will panic or segfault.
Most write after free will panic or segfault.
And it’s lock free thread safe, so you can pass the allocator along threads.
Since it addresses races and write after free and it’s thread safe, it’s more or less a more humane answer to borrow checker.
Also this is more explicit than the implicit drop.
And also, it can be backed by any allocator, unlike the DebugAllocator (the old GPA) always with page_allocator. So if you deal with a lot of C codes, you can use c_allocator as the backing allocator.
And also when it is backing the Arena allocator, the arena is lock free thread safe too.
With all those helps from the allocator, I can’t imagine how he still forgets to free memory, and he worries about overly abuse defer free… If his program has billions of syscall heap allocation and free, and if his program has billions of race and mutated writing and write after free, he probably would abuse Vec, String, HashMap with Rc RefMut or Arc Mutex if he wrote Bun in Rust from the very beginning…
I agree with someone here just said: it’s not the Rust that saves him, it’s the AI rewrite to help him to refactor his codes, doesn’t matter which language he uses.
Also I don’t think those “I want to see Zig’s answer to Rust’s blabla feature” is a viable way of choosing languages. I have never seen people waiting Rust’s answer to Pony’s strict lock free multi threading policy, so why another language will need to answer Rust, although many features have already given an answer.