2 ms·
Zig (another language fit for low level programming, like C and Rust) begs to differ. [1]: https://ziglang.org/learn/why_zig_rust_d_cpp/#no-hidden-allocations
by cies 6y ago
Zig (another language fit for low level programming, like C and Rust) begs to differ.
[1]: https://ziglang.org/learn/why_zig_rust_d_cpp/#no-hidden-allocations https://ziglang.org/learn/why_zig_rust_d_cpp/#no-hidden-allo...
- littlestymaar 6y agoI love how the section about Rust links to a github issue that is more than five years-old, when the fallible allocation story has evolved so much in the past year.
- cies 6y agoSo how has it? I was not aware it has changed (also I dont need the changes, as I use Rust for more highlevel stuff)
- littlestymaar 6y agoThere are new methods returning a Result instead of panicking, slowly being implemented for all allocating collections in the standard library. see https://github.com/rust-lang/rust/issues/48043 https://github.com/rust-lang/rust/issues/48043 and https://github.com/rust-lang/rust/pull/80310 https://github.com/rust-lang/rust/pull/80310
- cies 6y agoLike what was mentioned in the linked thread, the "try_*" functions. This is what Zig has as default behavior.
- prussian 6y agoWhat does this have to do with my comment? If you're out of memory, how can zig know you can just continue on? What if your memory is held in tasks that are effectively dead-locked because a dependent task is incapable of allocating? There are many things that can be happening once memory is effectively maxed out. The more common towards the edge is higher I/O and the system crawls. I'm sure Zig is great, but I don't see from what you linked how that changes what I said.
- cies 6y agoI know Rust much better than Zig. I found that one difference between the two is Zig default behavior on mem alloc: it can fail. All code alloc'ing mem needs to deal with this potential failing: the dev can choose to "panic/die/exit/etc" or possibly a different strategy can be chosen (display smth in the UI, not allocating memory, etc). Rust has this "nicely return a Result, instead of exceptions/panics/etc", in most cases, but not in the case of mem alloc. That a big difference between Zig an Rust. Now Rust has alternative methods for mem alloc that return a Result: but these are not the default and thus hard to discover. This is "unsafe behavior by default" in Rust. This is special, as Rust usually promotes the safe path.