this post was submitted on 02 Aug 2024
78 points (94.3% liked)
Technology
59389 readers
4423 users here now
This is a most excellent place for technology news and articles.
Our Rules
- Follow the lemmy.world rules.
- Only tech related content.
- Be excellent to each another!
- Mod approved content bots can post up to 10 articles per day.
- Threads asking for personal tech support may be deleted.
- Politics threads may be removed.
- No memes allowed as posts, OK to post as comments.
- Only approved bots from the list below, to ask if your bot can be added please contact us.
- Check for duplicates before posting, duplicates may be removed
Approved Bots
founded 1 year ago
MODERATORS
you are viewing a single comment's thread
view the rest of the comments
view the rest of the comments
Maybe it would be easier to translate to Ada? That is for C code that doesn't make heavy use of malloc/free. The idea of Rust's borrow checker as I understand it is to statically track the references to malloc'd memory to make sure that you never use-after-free or double-free. If your C code uses malloc in uncontrolled ways, then massaging it to satisfy a borrow checker sounds horribly difficult and you should either give up, or run it under a very managed environment like valgrind. If (as is typical of embedded code) it just does stuff with some fixed memory buffers and doesn't do much runtime allocation, then there isn't anything for a borrow checker to look after, so you can use a safe language (Ada) that doesn't have borrow checking.
Disclaimer: I don't use Rust at the moment. Someday. I do like Ada despite its verbosity, but it's not that great at managing dynamic memory. It is starting to take on Rust influences to help with that.
AFAIK you can get around this by using raw pointers / unsafe blocks in Rust, then have a human target those to rewrite it in a safe, structured way.