logoalt Hacker News

GardenLetter27yesterday at 10:58 AM2 repliesview on HN

Rust gives you no guarantees that a function won't allocate or panic though.


Replies

VorpalWayyesterday at 11:46 AM

Yes that is annoying, but I don't know of any mainstream systems language that does. C and C++ can also have allocations anywhere, and C++ have exceptions. And those are really the only competitors to Rust for what I do (hard realtime embedded).

Zig might be an option in the future, and it does give more control over allocations. I don't know what the exception story is there, and it isn't memory safe and doesn't have RAII so I'm not that interested myself at this point.

I guess Ada could be an option too, but I don't know nearly enough about it to say much.

show 3 replies
MaulingMonkeyyesterday at 11:05 AM

This is something I do wish Rust could better support. A `#![no_std]` library crate can at least discourage allocation (although it can always `extern crate alloc;` in lib.rs or invoke malloc via FFI...)

show 1 reply