Re:Bugs that the Rust compiler catches for you
by legalcorrection on Friday May 06, 2022 @01:34AM
(#31281660)
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.
[ Parent
| on HN ]
Re:Bugs that the Rust compiler catches for you
by josephcsible on Friday May 06, 2022 @01:40AM
(#31281679)
Rust 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.
Re:Bugs that the Rust compiler catches for you
by alkonaut on Friday May 06, 2022 @03:46AM
(#31282484)
If 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.
Re:Bugs that the Rust compiler catches for you
by eternityforest on Friday May 06, 2022 @02:21AM
(#31281904)
Why 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.
Re:Bugs that the Rust compiler catches for you
by legalcorrection on Friday May 06, 2022 @02:26AM
(#31281930)
Proven 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.
Re:Bugs that the Rust compiler catches for you
by eternityforest on Saturday May 07, 2022 @04:59PM
(#31298525)
That'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.