Re:Mrustc: a Rust compiler written in C++
by banachtarski on Friday September 22, 2017 @02:33AM
(#15309856)
(note, not the OP) Yea but by the same token, the borrow checker prevents me from doing perfectly valid logic and is frustrating in its own right.
[ Parent
| on HN ]
Re:Mrustc: a Rust compiler written in C++
by moomin on Friday September 22, 2017 @03:28AM
(#15310083)
That's true of literally all compile time validation.
Re:Mrustc: a Rust compiler written in C++
by banachtarski on Saturday September 23, 2017 @05:22AM
(#15318933)
No I'm not saying I have an issue with compile time validation. Far from it.
My point is that the borrow checker is explicitly meant to protect against data races and such. There are situations where I write code I can prove does not violate any hazards but Rust's "validation" is overly-zealous.
Re:Mrustc: a Rust compiler written in C++
by steveklabnik on Saturday September 23, 2017 @12:49PM
(#15320530)
Which ones do you run into most often?
Re:Mrustc: a Rust compiler written in C++
by weberc2 on Friday September 22, 2017 @10:53AM
(#15312696)
But its more true of some than others.
Re:Mrustc: a Rust compiler written in C++
by keeperofdakeys on Friday September 22, 2017 @06:33AM
(#15310810)
Yes, some valid code won't pass the borrow checker. But at the same time, far more invalid code doesn't pass it. Personally I see it as a tool to help me reduce possible runtime errors, and instead have them as compile time errors. This does mean that I often need to design my program around it, but that's try of basically every other language.
The few times I do have an issue I'm usually writing FFI code to interact with C, and I try to minimise that code as much as possible.
And of course in Rust, if you Try you might get an Ok Result, or you may just return in Err.
It's often a good exercise to craft your program to the language you're targetting, to take advantage of it's strengths or embrace it's traditions.