16 ms·
Doesn’t Rust place too many limits on what programs you can express to be a viable replacement for C? The premise of C is that you can more or less write any pr
by legalcorrection 4y ago
Doesn’t Rust place too many limits on what programs you can express to be a viable replacement for C? The premise of C is that you can more or less write any program. Not in the Turing complete sense that is always true, but in the sense that you can make any sequence of memory modifications and control flow decisions and the compiler will produce the corresponding machine code. With Rust, the compiler will only accept a subset of possible and safe programs, the subset that fit in the patterns that the Rust borrow checker can prove are safe.
- josephcsible 4y agoRust has unsafe blocks, which let you dereference raw pointers. Also, remember that even in C, if you do something that's Undefined Behavior, the compiler doesn't have to emit instructions that do what you wanted.
- eternityforest 4y agoWhy would you ever want to wrote something that isn't provable, when you could write something that is? You always have unsafe blocks for tiny bits of performance critical hardware interaction stuff, but in general, I don't see why we need to be able to access the whole program space in 99% of cases.
- legalcorrection 4y agoProven by Rust’s borrow checker. That’s not the same as the world of all provably safe programs, which is probably infinitely larger than what Rust will allow.
- eternityforest 4y agoThat's perfectly fine, as long as you can still get the majority of things done in a way Rust can prove. If removing a large number of possible programs reduces bugs without limiting features, that seems like a win.
- alkonaut 4y agoIf 99% of the time I'm helped by those checks and there is an escape hatch for the remaining 1%, then it's a clear win to have that limit in as many places as possible.