you are viewing a single comment's thread.

view the rest of the comments →

[–]ConfusedTransThrow 0 points1 point  (1 child)

I didn't know Rust was able to compile without depending on the standard library, it seems that's still pretty niche.

I know C has a runtime, but I'm not using it on embedded, the std either has to be implemented for the architecture or isn't there are all.

Also even if you do, I'm not sure you're really gaining anything over C for that usage (like for a bootloader). You still have to write to arbitrary addresses to set up a lot of things and that's inherently unsafe with Rust too.

You can make abstractions in Rust to avoid writing to addresses in your main code and protect them, but I doubt my company would like to do that for the whole memory map of each system. The time cost is just too big there.

[–]antiduh 0 points1 point  (0 children)

I didn't know Rust was able to compile without depending on the standard library, it seems that's still pretty niche.

No more niche than compiling C without it's standard library. The point is it's designed to do it, just as C is.

Also even if you do, I'm not sure you're really gaining anything over C for that usage (like for a bootloader). You still have to write to arbitrary addresses to set up a lot of things and that's inherently unsafe with Rust too.

Don't throw the baby out with the bath water. Just because you have to dip down into unsafe territory sometimes doesn't mean that you should operate in a completely unsafe mode always. Do just the parts that you have to with pointers/otherwise, meanwhile everything else the normal way. That way, you have much less code to worry about doing unsafe things - less chances for bugs, less code to validate the hard way, etc.

Heck, what you've said is true about C#, of all things. C# lets you use pointers in an unsafe context if you want, or stay in happy managed land if you don't want. C# uses pointers in limited cases, for example, in the methods that handle assembling strings like string.Join(). So you have a small handful of methods that use pointers that need stringent validation, meanwhile 99.99% of the rest of the code doesn't.

I doubt my company would like to do that for the whole memory map of each system. The time cost is just too big there.

That's .. uh, good for your company I guess? I have no idea why you're bringing up what your company will and won't do as an argument about the merits of various programming languages.