| ▲ | smj-edison 15 hours ago | ||||||||||||||||
I think this is fair the majority of time, but I'd like to mention Zig, since Zig has a convention of all allocations being fallible and handled. It's a pain at first to handle error.OutOfMemory at each allocating site, but I feel like I'm much more conscious of where allocation can fail and how to gracefully handle it. I've also gotten a lot better at transactions since pretty much every operation has failure points now. In fact I've written a whole interpreter that can recover from OOM by raising a recoverable exception to the user. It's really only because Zig made recovering idiomatic, and I'm not sure I could've done it in another language (maybe Rust but I'd have to rewrite large parts of stdlib to both return an error and take a custom allocator). | |||||||||||||||||
| ▲ | steveklabnik 11 hours ago | parent | next [-] | ||||||||||||||||
The Rust stdlib has added those functions that return errors, and the types are parameterized by the allocator trait. The trait is coming to stable in the next release! | |||||||||||||||||
| |||||||||||||||||
| ▲ | mappu 7 hours ago | parent | prev [-] | ||||||||||||||||
In userspace/application code this isn't giving you all the value you hope for - because of overcommit and fork/exec, you can OOM on simply modifying a variable (in a non-file-backed page). What Zig does is great, but it is not actually comprehensively checking that all allocations are fallible and handled. That's not possible on Linux. | |||||||||||||||||
| |||||||||||||||||