2 ms·
Which, relevantly, is something where Zig excels. OOM is just another ordinary error to be handled, and indeed is an error that can be leveraged on a much more
by yellowapple 6y ago
Which, relevantly, is something where Zig excels. OOM is just another ordinary error to be handled, and indeed is an error that can be leveraged on a much more fine-grained basis than an OS-level allocation. Being able to gracefully handle OOM conditions is a dramatic improvement over the average C codebase; enforcing that graceful handling, as Zig does by requiring callers to handle errors as part of the return type and by including allocation failures in that category, is a godsend.
And taking this further, since Zig's convention around allocators is for them to be an explicit argument of all functions needing to allocate, it's trivial to write tests specifically to validate correct behavior in OOM conditions. There's even a custom allocator in the standard library for exactly this purpose.
- jorangreef 6y agoYes, and I think the matrix should really include these aspects of Zig's safety to be a fair comparison, because otherwise it's like evaluating Rust's safety but without mentioning the borrow checker.