3 ms·
Every function in the C++ standard library reliably communicates allocation failure to the application without relying on aborting the whole program. If Rust ca
by quotemstr 11y ago
Every function in the C++ standard library reliably communicates allocation failure to the application without relying on aborting the whole program. If Rust can do it, C++ can do it too. Rust got itself into this trap by eschewing exceptions.
- tatterdemalion 11y agoMaybe avoid using judgmental language like calling a standard allocator that aborts on oom a "trap." The Rust team made conscious design choices in full awareness of the trade-offs. Moreover, Rust actually does have thread unwinding, and even the ability to catch an unwinding thread, so it is not true that the Rust standard library could not have unwound on oom. Rust's standard library just isn't designed for writing applications that need to survive oom errors. That's fine, its not designed for a number of other applications which Rust the language is well-suited for either (operating systems, for example). Its designed for the majority use case, because life is full of trade offs.
- quotemstr 11y agoIf Rust isn't suitable for C's niche, Rust's proponents should stop pitching Rust as a replacement for C. > The Rust team made conscious design choices in full awareness of the trade-offs I don't think that anyone who isn't already predisposed to avoid exceptions would consider the tradeoff the Rust people made to be the correct one.
- tatterdemalion 11y agoThis is absurd. Most C applications do not need to persist through OOM errors, and has people have repeatedly reiterated, it is totally possible to write a Rust program that persists through OOM errors.