Earlier quoted context omitted.
To be a bit more precise: the borrow checker does not change the code generation part of the compiler. If you modified rustc to skip borrow checking, and you passed it a valid Rust program, you would get identical output. However, that doesn't mean that you can disregard the semantic rules that it enforces. It is "involved in compilation" in that sense. Even when writing unsafe code, you are expected to keep up the i…
Yes thank you. That was my underlying point without explicitly saying it. That the borrow checker does not influence compilation and just determines if a program is valid or not. Just like you can ignore the syntax checker of languages as long as you never give it incorrect syntax. I guess my core concept is that you wouldn't do these things because they provide value. And that removing the rust borrow checker withou…
Turning off Rust's borrow checker completely (2022)
11–20 of 63 posts
Re: Turning off Rust's borrow checker completely (2022)
#12Earlier quoted context omitted.
Yes thank you. That was my underlying point without explicitly saying it. That the borrow checker does not influence compilation and just determines if a program is valid or not. Just like you can ignore the syntax checker of languages as long as you never give it incorrect syntax. I guess my core concept is that you wouldn't do these things because they provide value. And that removing the rust borrow checker withou…
Sometimes, especially when debugging, you don’t care about being “correct,” freeing memory properly, or any other safeties. You just want to narrow down where a bug is in the code so you can start stepping through the right parts and see what is going on.
Rust as a language aims to move bugs "to the left" through a stricter compiler. The promise is an environment where building things takes longer, but the things you build are more reliable and the net amount of time debugging (and being exposed to production bugs) is lower.
Re: Turning off Rust's borrow checker completely (2022)
#13Earlier quoted context omitted.
Sometimes, especially when debugging, you don’t care about being “correct,” freeing memory properly, or any other safeties. You just want to narrow down where a bug is in the code so you can start stepping through the right parts and see what is going on.
You're putting "correctness" in quotes as though it is a matter of being polite to the machine. The Rust compilation process depends on these invariants so that the code actually executes as written (specifically, has no undefined behavior). I'd argue there is never a very good time to expose your program to undefined behavior, but when you're trying to debug an issue is a particularly bad time. Rust as a language ai…
I guess that makes sense, now that I think about it. I see lots of “rewrite in rust!” But not a lot of new (from whole cloth, innovative) projects from rust. Then again, I’m not really in the rust community or do much in rust except a PR every year or so.
Re: Turning off Rust's borrow checker completely (2022)
#14Earlier quoted context omitted.
To be a bit more precise: the borrow checker does not change the code generation part of the compiler. If you modified rustc to skip borrow checking, and you passed it a valid Rust program, you would get identical output. However, that doesn't mean that you can disregard the semantic rules that it enforces. It is "involved in compilation" in that sense. Even when writing unsafe code, you are expected to keep up the i…
Yes thank you. That was my underlying point without explicitly saying it. That the borrow checker does not influence compilation and just determines if a program is valid or not. Just like you can ignore the syntax checker of languages as long as you never give it incorrect syntax. I guess my core concept is that you wouldn't do these things because they provide value. And that removing the rust borrow checker withou…
The point is that you, the programmer, has intelligence and creativity and can prove that some programs are valid, while the borrow checker wouldn't be able to. So the set of rules you'd follow might be different. This is true, in theory, of many programmers in C++ for example, with the drawback that you might have made a mistake in your proof to yourself.
Re: Turning off Rust's borrow checker completely (2022)
#15Re: Turning off Rust's borrow checker completely (2022)
#16Earlier quoted context omitted.
You're putting "correctness" in quotes as though it is a matter of being polite to the machine. The Rust compilation process depends on these invariants so that the code actually executes as written (specifically, has no undefined behavior). I'd argue there is never a very good time to expose your program to undefined behavior, but when you're trying to debug an issue is a particularly bad time. Rust as a language ai…
It is a matter of being polite when it comes to semantics. Weird is English written in obtuse grammar, but it is still legible. Undefined behavior still compiles into _something_, and if it’s after the code I care about observing, it doesn’t matter. The very first C++ templates compilation was observed through undefined behavior and errors. If you don’t have some way to “escape” from proper semantics, just to experim…
That's not how undefined behavior works, though. Undefined behavior doesn't have an "after." By definition it leaves your entire program in an undefined state, which means its behavior cannot be reasoned about temporally or spatially in this way. Sure, in a simple or trivial case you might "get lucky", but merely by introducing undefined behavior you are no longer capable of observing the code you care about correctly.
Re: Turning off Rust's borrow checker completely (2022)
#17[1] https://docs.rs/you-can-build-macros/0.0.14/src/you_can_buil...
[2] https://docs.rs/you-can/latest/src/you_can/lib.rs.html#17-25
Re: Turning off Rust's borrow checker completely (2022)
#18[flagged]
You can’t really hate something that you profess to not deeply understand.
But in this case, the GP was describing their experience programming with the borrow checker as a new rust programmer. Hatred is an emotion. It’s not up to you or me to decide if that feeling is present in someone else’s brain.
Re: Turning off Rust's borrow checker completely (2022)
#19Re: Turning off Rust's borrow checker completely (2022)
#20Rust really made me appreciate garbage collection after the number of times I resorted to things like Arc>.