News for hackers. Stuff that matters.
Re:The borrowchecker is what I like the least about Rust by al_fanta on Saturday July 19, 2025 @04:48PM (#44619237)
> makes you a better programmer

If a language is bad, but you must use it, then yes learn it. But, if the borrowchecker is a source of pain in Rust, why not andmit it needs work instead of saying that “it makes you better”?

I’m not going to start writing brainfuck because it makes me a better programmer.

Re:The borrowchecker is what I like the least about Rust by lblume on Saturday July 19, 2025 @04:58PM (#44619338)
I believe that codebases written in Rust, with borrow checking in mind, are often very readable and allow local reasoning better than most other languages. The potential hardness might not stem from "making people better programmers" but from "making programmers write better code, perhaps at the cost of some level of convenience".
Re:The borrowchecker is what I like the least about Rust by IshKebab on Saturday July 19, 2025 @05:09PM (#44619432)
We do admit it needs work. The issues the author highlights can be annoying, a smarter borrow checker could maybe solve them.

The point is the borrow checker has already gone beyond the point where the benefits outweigh those annoyances.

It's like... Static typing. Obviously there are cases where you're like "I know the types are correct! Get out of my way compiler!" but static types are still vastly superior because of all the benefits they convey in spite of those occasional times when they get in the way.

Re:The borrowchecker is what I like the least about Rust by creata on Saturday July 19, 2025 @05:25PM (#44619574)
> The issues the author highlights can be annoying, a smarter borrow checker could maybe solve them

I don't think a smarter borrow checker could solve most of the issues the author raises. The author wants borrow checking to be an interprocedural analysis, but it isn't one by design. Everything the borrow checker knows about a function is in its signature.

Re:The borrowchecker is what I like the least about Rust by estebank on Saturday July 19, 2025 @07:14PM (#44620362)
Making partial borrows to be expressable in method definitions would allow the design pattern to be expressed without breaking the current lifetime evaluation boundary.

Allowing the borrow checker to peek inside of the body of local methods for the purposes of identifying partial borrows would fundamentally break the locality of the borrow checker, but I think that as long as that analysis is only extended to methods on the local trait impl, it could be done without too much fanfare. These two things would be relaxations of the borrow checker rules, making it smarter, if you will.

Re:The borrowchecker is what I like the least about Rust by ameliaquining on Saturday July 19, 2025 @09:12PM (#44621006)
Fixing the get_default example wouldn't require interprocedural analysis. (It requires Polonius, which, yeah, has taken a long time to ship.)
Re:The borrowchecker is what I like the least about Rust by estebank on Saturday July 19, 2025 @10:21PM (#44621393)
The get_default example requires only one to use the stdlib API: https://doc.rust-lang.org/std/collections/hash_map/enum.Entr...