News for hackers. Stuff that matters.
Re:A Rust Shaped Hole by jcranmer on Thursday July 17, 2025 @01:06AM (#44589857)
Having developed a fair amount of expertise with both C++ and Rust, C++ is on a completely different level of complexity from Rust.

In Rust, for most users, the main source of complexity is struggling with the borrow checker, especially because you're likely to go through a phase where you're yelling at the borrow checker for complaining that your code violates lifetime rules when it clearly doesn't (only to work it out yourself and realize that, in fact, the compiler was right and you were wrong) [1]. Beyond this, the main issues I run into are Rust's auto-Deref seeming to kick in somewhat at random making me unsure of where I need to be explicit (but at least the error messages basically always tell you what the right answer is when you get it wrong) and to a much lesser degree issues around getting dyn traits working correctly.

By contrast C++ has just so much weird stuff. There's three or four subtly different kinds of initialization going on, and three or four subtly different kinds of type inference going on. You get things like `friend X;` and `friend class X;` having different meanings. Move semantics via rvalue references are clearly bolted on after the fact, and it's somewhat hard to reason about the right things to do. It has things like most-vexing parse. Understanding C++ better doesn't give you more confidence that things are correct; it gives you more trepidation as you know better how things can go awry.

[1] And the commonality of people going through this phase makes me skeptical of people who argue that you don't need the compiler bonking you on the head because the rules are easy to follow.

Re:A Rust Shaped Hole by tialaramex on Thursday July 17, 2025 @03:08AM (#44590582)
The C++ 11 move semantic is definitely an example of C++ programmers being sold a "pig in a poke"† The claim in the proposal document was that although this isn't the "destructive move" which programmers wanted (and which Rust had by 2015), the C++ 11 move feature can be realised with less disruption and is just as good. In reality it left significant performance on the table and you can't get it back without significant further language change.

† This phrase would have been idiomatic many years ago but it is still used with the same intent today even though its meaning is no longer obvious, the idea is that a farmer at market told you this sack you can't see inside ("poke") has a piglet in it, so you purchase the item for a good price, but it turns out there was only a kitten in the bag, which (compared to the piglet) is worthless.

Re:A Rust Shaped Hole by blub on Thursday July 17, 2025 @04:52AM (#44591180)
Copy by default is the right way to go. Even if less performant, it’s safe and super-easy to understand. Let the people that want to squeeze the last drop of performance worry about moves…

Move by default is the thing which complicates Rust so much.

Re:A Rust Shaped Hole by Expurple on Thursday July 17, 2025 @05:20AM (#44591351)
Copy by default wouldn't be so bad if the move was destructive
Re:A Rust Shaped Hole by troad on Thursday July 17, 2025 @07:22AM (#44592035)
I think the focus on the borrow checker or lifetimes as the source of Rust's complexity is a bit of a distraction from the real problems. Neither is a concept that would be too difficult for a well-rounded programmer: C and C++ programmers should certainly understand lifetimes, and the slightest bit of FP experience makes the borrow checker pretty straight-forward too.

Instead, the complexity of Rust is most acute when one is trying to read some overly excited programmer's sigil soup of higher-order functions operating on some boxed dynamic traits, in a struct that casually #derives thirty-seven inscrutable things from a hundred libraries, none past v 0.1, which are themselves a mess of overly clever macros... The C++ comparison is apt, because the closest experience I ever had to the above is when trying to disentangle some template-apocalypse-era C++ code.

C++ is still objectively worse, and lacks the many very real improvements present in Rust.[0] But ultimately I do think the problem with Rust is that - above a certain level of complexity - its terseness veers sharply into incomprehensibility. I honestly think that's part of the reason so many OSS or hobby projects in Rust end up abandoned - it becomes a chore to even understand what existing code does, and it sucks all the joy out of writing new code.

[0] Though it boasts a much more mature ecosystem than Rust does, which is way more of a killer feature than people give it credit for.