3 ms·
I reacted like that at first, and then later on I realized that in order to use containers on classes, I either have to use pointers and manual allocation or ac
by Iv 10y ago
I reacted like that at first, and then later on I realized that in order to use containers on classes, I either have to use pointers and manual allocation or accept wasteful copies. The move semantics simply allows to mimic a copy without actually doing it, when you plan to discard your initial object. A common situation when populating a container with class instances.
I had a long back and forth relationship with C++. I have the same criticism everyone has: it is hard to use, hard to understand, there are tons of possibilities and concepts that overlap each others, many ways to do the same things that are sometimes incompatible...
But reading more about it, getting updated on the more recent iterations, I understood that C++ is more than a programming language: it is actually a quest. It is a search for a language that can both manipulate high-level concepts and also descend to the very low level required for software living close to the hardware (you'll do mostly C there but a few C++ constructs can be surprisingly useful)
Most other languages will specialize in a niche. C++ developers want to be able to express the most abstract concepts in the best possible implementation. That's a quest for the grail. Few other languages dare to dream that big. And of course C++ stumbled sometime along the way, still limping from backward compatibility, but it is so far the most advanced in this quest.