3 ms·
> if you spend a dozen lines marshalling unsafe code around and ultimately writing the equivalent C code in Rust, and slightly slower (perhaps the compiler opti
by xondono 5y ago
> if you spend a dozen lines marshalling unsafe code around and ultimately writing the equivalent C code in Rust, and slightly slower (perhaps the compiler optimizes anyway?), is it worth the effort?
The thing is, that's not generally where most of the bugs and development blockers lie here. When embedded development gets stuck, is generally because:
a) A part of the hardware doesn't work like you think it works.
b) Two or more independent parts of code (think ISRs) are conflicting in some non trivial way.
Having well structured HALs helps with (a), while memory safety can prevent some errors on (b).
One of the nice things I've seen with Rust is how high quality the HALs look, even if some of the tooling looks a little shaky for my taste. Of course part of that is that manufacturer provided HALs are generally quite bad...
Also having lots of people share the same unsafe blocks is the best way to keep the bugs away, and sharing libraries with cargo beats the real way C code gets shared in embedded development (mostly through copy/paste from StackOverflow...).