4 ms·
> If the language has the problem that people are fighting with the language in order to become productive with it, perhaps something is wrong with the language
by rapsey 8y ago
> If the language has the problem that people are fighting with the language in order to become productive with it, perhaps something is wrong with the language, and not the programmers?
Or maybe writing correct (i.e. safe) code is more difficult then most programmers realize and they lack the humility to admit it.
- garmaine 8y agoThat’s true, but not what that quote is about.
- rapsey 8y agoThere are two sides to any coin. The complexity of the language is a consequence of the complexity of the problem it is trying to solve and the constraints it is operating under. The borrow checker is not just some crazy torture device that exists for no reason. Criticizing the difficulty of the borrow checker without considering why it exists in the first place is completely misguided.
- garmaine 8y agoFalse dichotomy -- there are always more than two sides to any issue. People find themselves fighting with the borrow checker because their mental model of what they're writing is not what Rust is interpreting. This is probably indicative of two things: (1) their mental model is incorrect in some ways, and (2) Rust's semantics don't map that well onto how we think about systems programming problems. If satisfying the borrow checker makes you think "whoops, that was dumb" then you're in category 1. If it makes you think "aargh, how do I express this in a way Rust will accept?!?" then you're in category 2. With an ideal language category 2 wouldn't exist.
- AnimalMuppet 8y agoOf course, it's very easy to think you're in category 2 when you're really in category 1 but don't see how you're wrong...
- garmaine 8y agoBut are all instances of category 2 actually category 1? That’s a strong claim.
- AnimalMuppet 8y agoIt is, and it's a claim that I didn't make. But even if it were true, I think people won't believe that it's true, because there will be instances where they won't understand the borrow checker's reasoning.
- garmaine 8y agoI think you can understand what the borrow checker is doing and still think it is being too stringent.
- k__ 8y agoWriting correct code that has all edge-cases in mind is not very intuitive. Teaching people to keep this in mind is a hard problem.
- macintux 8y agoI believe that reinforces Sargun’s point. One of the reasons I love functional programming is it allows me to think less about edge cases, because values are passed as values. If Rust passed copies instead of references by default, people who wanted performance could fight (or embrace, whatever your preferred term/level of experience is) the borrow checker, while everyone else could enjoy the fundamental safety of not sharing data.
- burntsushi 8y agoRust doesn't pass references by default, so I'm not really sure what kind of dichotomy you're trying to draw here. Also, such fundamental changes likely have far reaching effects that would likely change Rust itself in ways you can't anticipate.
- macintux 8y agoI'm relying on his description: > The biggest issue I have with the defaults, and the borrow checker is that places in FP where you would normally pass by copy — pass by value, in Rust instead it assumes you want to pass by reference. Therefore, you need to clone things by hand and pass the cloned versions instead. Although it has a mechanism to do this automatically, it’s far from ergonomic.
- burntsushi 8y agoYeah, I don't really understand what the OP is trying to say there other than "I'm frustrated." The lack of examples makes it hard to know. Passing by value works just fine in Rust, so it's hard to unpack what the author was getting at.
- capdeck 8y agoThe question here is -- are you "productive" because you write _good_ code faster, or because the language allows you to _not think_ about certain aspects of design and just postpone issues to the future (or GC). OP wants to be fast and "productive", but forgets that in systems programming your first priority is good design and solid implementation. This is because _other_ components will be relying on your code to do their job. It pays to go extra step and make sure your component is properly written. Rust offers more than any other systems language to help with that.