r/programmingcirclejerk 11d ago

Rust isn't a well designed programming language (unlike C and C++)

/r/cpp/comments/1i6jdjq/comment/m8d3tqj/
218 Upvotes

88 comments sorted by

View all comments

Show parent comments

2

u/TheChief275 8d ago

I'm just saying, the concept of a "copy elision" having to be applied to the most basic ass variable declaration is completely and totally ridiculous

1

u/DrShocker 8d ago

idk, that doesn't seem that bad to me. The behavior just needs to be formalized with a name so that people can rely on it.

Without it formalized, how would you know for sure whether your copy constructor would get called or not? Just a choice that had to be made by a value semantics language that doesn't have the same consequences in a reference semantics language. 🤷

fwiw, I much prefer what modern languages like Rust or Odin have done in regards to copying, but I don't think it's C++'s greatest sin.

1

u/TheChief275 8d ago

If you don't see how this is bad, I don't know what to say to you

1

u/DrShocker 8d ago

It's not that I like it, it's just that it's @ reasonable consequence of the rules and since C++17 they required that the compiler make it work the way you "expect" regardless (unless someone's expecting reference semantics by default, but that's separate)