I really dislike how C++ does move semantics. I understand why it is this ugly and difficult (as always: in order not to break existing codebases...), but that doesn't change how mentally taxing it is to write code that avoids unnecessary copies.

I would really love to use Rust instead. There it is trivial, because of the different ownership and lifetime rules. (And in the few cases where move doesn't work, the borrow checker poilitely asks for an explicit clone().)

#cpp #RustLang

@soulsource it’s worse than that. Non-destructive moves, while definitely an improvement on the semantic horror of auto_ptr, force us to have objects with an “empty” state, repeating the billion dollar mistake again and again… Rust is so much better in that respect that it isn’t funny

Self-referential legacy objects could probably even have been made movable by introducing something akin to D’s post-blit operator (but for moves)

#cplusplus #rust #dlang

@JSMuellerRoemer @soulsource The whole "move construction leaves the source value in an undefined but destructible state" thing in C++ is a disaster. It's arguably still better than forcing move-constructible objects to have a more proper null state, e.g. if I recall correctly it's okay to have that post-move "undefined but destructible" state trigger UB if you do anything other than destruction (and assignment?), which at least means you don't have to worry about exposing a "public" null state.
@pervognsen @soulsource I know that destructible and assignable are the only requirements, but I don’t think I agree that this allows us to not have to worry about exposing the null state. Since there are no provisions in the type system to ensure nothing else is done that just leaves us with neither compiletime nor runtime checks, and we can only read/write code carefully which has worked <sarcasm>so well</sarcasm> in the past
@JSMuellerRoemer @soulsource Oh, I agree about the UB footgun potential, but that's C++ writ large so I'd say throwing more gasoline on that ever-burning fire is very in character for C++. :)
@pervognsen @soulsource too true 😅 There’s no language that I love and hate so much at the same time. But even after writing C++ since 1998 (professionally since 2008), I’d still choose Rust first, as no amount of experience can compensate for the sheer amount of footguns in C++
@soulsource the half-arsing of move was such a disappointment. Things could have been so much better.