3 ms·
> You still have to fight with borrow checking in Rust as in C++, it’s just not automated. This is so misleading. Sure you still have to think about borrowing
by IshKebab 8y ago
> You still have to fight with borrow checking in Rust as in C++, it’s just not automated.
This is so misleading. Sure you still have to think about borrowing in C++ but in C++ you only have to convince yourself that you got it right. You don't have to convince a dumb child that barely understands variable scopes.
The benefit is of course that the dumb child is 100% reliable so if you can convince him then you are 100% sure you got it right...
But please can we stop pretending that it isn't a massive pain in the arse to convince the borrow checker that your code is ok.
Also as someone else pointed out, if you are only writing single threaded code the mutable borrowing rules are needlessly restrictive.
I like Rust but it really irks me when people pretend it is as easy as C++. It isn't. It is much harder - it's just that when you're done you have (probably) a better result.
- jamwt 8y ago> I like Rust but it really irks me when people pretend it is as easy as C++. It isn't. It is much harder No it's not. "hard" is not single dimensional. "hard" to write your first hello world? No, both are easy. "harder" to write your first moderately-sized program that basically works? Yes, for almost everyone. You'll fight the borrow checker. The learning curve is real. "harder" to write your first large/medium, correct program? Definitely not. The safety will save you, here. It's not just memory. It's no nulls, it's no exceptions, pattern matching exhaustion enforcement, baton-passing session type patterns, race-freedom, and so on. The "it compiles, it works" dynamic is akin to OCaml/SML, if you've used those at all. Except it's even better because you get prompt resource finalization. "harder" to write your nth program after ~6 months of usage? Not by a long shot. Rust is actually an incredibly expressive language. Once you learn to shape code the way the language expects, you'd be shocked at how productive you are. It's in the same ballpark as go, perhaps a little better if you're doing something nontrivial due to the power of generic libraries. I spend almost no time "fighting" the borrow checker, as do most ramped-up Rust programmers. It's pretty much all win at this point. It's a different category of language than C(++). It actually gets a little exhausting hearing people talk about how hard the borrow checker when folks have barely used the language. These days, the only time I'll use a GC is if I'm writing something _very_ fast and short in Python. An experiment, a prototype, or a tool. A short REPL session. I really do not miss GCs otherwise. But yes, compile times are somewhat slow. If you go template crazy in C++, you'll be in the same ballpark. But the "equivalent" C codebase will smoke it.