Comment by locknitpicker
3 days ago
> Unfortunately, I don't think there's getting away from just understanding value semantics to get the correct and/or performant behavior.
This is not specific to C++ though. It just so happens that C++ developers who feel this topic is important are those invested in performance optimization. For them, C++ offers them these types of tools.
Meanwhile, those who don't have a pressing need to go through great extents to optimize performance can simply fall back to the compiler generating most special member functions and then pay the performance tax of doing deep copies by default. For these cases, which I'd say corresponds to most C++ floating around, it's far more important to know the rules of when to define our own custom constructors and assignment operators.
> pay the performance tax of doing deep copies by default.
For most code that performance tax is not worth worrying about. There are almost high performance priorities. It is almost always the case that your code runs "fast enough" long before you start worrying about the few nanoseconds a deep copy of a few bytes costs.
> For most code that performance tax is not worth worrying about.
Indeed, I agree. It's possible to go a long way in terms of performance with a basic understanding of passing by reference, without even having ro bother with move semantics. So these topics end up being dominated by language lawyers and the types that enjoy debating "aktualy" topics, who also contribute to making things sound far harder than what they actually are by pretending that this sort of trivia is very important stuff.
> So these topics end up being dominated by language lawyers and the types that enjoy debating "aktualy" topics,
I'm not sure about that.
Even though most people never need it, a small minority really do, and those types have to become expert in those weird details. Well you pretty much have to be a language lawyer to get these optimizations right, but the goal really is the ultimate performance in some place where it really matters.