3 ms·
I personally don't see Rust as a good replacement for C - it's too complex a language, and it is especially easy to loose sight of what is happening at a low le
by falcolas 12y ago
I personally don't see Rust as a good replacement for C - it's too complex a language, and it is especially easy to loose sight of what is happening at a low level due to all of the abstractions.
Even if you did decide to use Rust instead of C in C's typical domain - operating systems, drivers, and constrained resource devices - you would be forced into using "unsafe" blocks anytime you had to interact directly with the hardware, manually manage memory, or issue ASM commands; at which point you're as vulnerable to programming mistakes as C.
- neikos 12y agoNot necessarily as the idea is to isolate those components into the unsafe blocks, and having locality on a bug is a pretty big component of fixing it.
- hga 12y agoWell, that's locality on what in theory could be causing a bug, but not on where it might manifest, i.e. a wild pointer trashing data maintained by purely safe code. Still, in theory isolating the possible causes is a fantastic advantage.
- wyldfire 12y ago> at which point you're as vulnerable to programming mistakes as C. Yes, but if you start off in C's typical domain, then you cannot decompose your problem set into safe and unsafe bins using C. So you're stuck with unsafe-lowest-common-denominator everywhere you go.
- sharpercoder 12y agoThis is okay. The point is that the majority of time, compiler checks/errors warn you from mistakes in safe code blocks. As such, you can put more focus on the actual unsafe parts. It is not about completely removing unsafe stuff. It is about reducing the possible mistakes as much as possible.
- rhodysurf 12y agoI agree. One of the best parts of C is how simple it is.
- gnuvince 12y agoThe unsafe code is neatly delimited, so you can write 95% of your application in safe code, and the remaining 5% in unsafe code and offer a safe interface to the programmer. This is the real strength of Rust IMO, you don't need to be hyper alert in every single function you write.
- vbezhenar 12y agoThose times when C compilers did obvious translation to machine code are long gone. Now compilers are super-smart and can inline functions, throw away code _they_ think is not needed, replace loops with vector instructions and list goes on. It's really hard to tell what's happening at a low level for a given C code.
- Solarsail 12y agoEven in C's own domain it still faces issues with undefined behavior. AFIAK, this is a problem Rust still doesn't face even while issuing ASM commands.