I chose C++ because it lets me do real men's coding while also being able to target real men's type "of modern" games.
C++ has issues with boilerplate setup, having to do header include guards, and much of STL seems like a big red herring whenever I code. Hey I wonder if the STL was meant to address the boilerplate issue?
Anyway I view it as superior to C for modern development, but inferior for older development.
Let's talk Memory Management though.
Boilerplate wise: often the need for a custom allocator or manager of heap allocated objects comes up. I don't mean a garbage collector, I mean a custom interface for tracking and removing what you no longer need on the fly.
To be resorting to heap allocation of objects is usually because passing around a pointer to an object has superior flexibility. Not in every case, but it comes up super often if you given any thought to performance
or to what happens if your vector stores non-pointers. Also you can set pointers to nullptr, references you have to set to a dummy object, which would need some indication that it's the dummy object making for annoying extra state definition.
To elaborate on choices:
You may say you can just global declare some non-heap allocated objects or create them intitially on a stack within some factory function which you then pass to a vector to hold them as pointers.
Having two buffers buys you the effect that if you erase an element it's you can avoid pointers to members changing.
This may work but it includes an extra layer of bullshit just to setup managing one group of objects (assuming templates aren't involved). This also has the inflexiblity that you must know how many objects ahead of time
you might need. And if you can know that, you probably don't need memory management at all.
Anyway the gain of not using new, and instead this extra layers of trickery, you avoid having to call delete[].
But to pull it off it's worse than having two buffers actually, because you want reusability. Meaning the buffer that stores the pointers is going to change even if the other doesn't. Else you're admitting pointers are all the same and even the object they point to never change when reused.
One wonders why not just do one big heap allocation? Well that's not memory management, that's just having memory allocated.
TL;DR There's usually a guaranteed boiler plate if you want real memory management. It's not fun. You'll need to make your own containers which probably uses templates or worse STL.
So how does a C programmer avoid that? First objects are far less important. There's no things with member functions. What you really have is just bundles of data that live somewhere. That's not to say abstraction isn't used,
it's just not a construct of the language.
All this leads to the following statement:
“C makes it easy to shoot yourself in the foot; C++ makes it harder, but when you do it blows your whole leg off.”
― Bjarne Stroustrup
To translate in C you deal with the issues you cause as you cause them. In C++ you can pickup some gains but you also can abstract yourself through the language to not see a fatal issue.
Well big fucking deal right? Life goes on? I guess.
Getting away from debug issues, consider if classes (abstract objects) are actually abstracting too much. What if focusing on how to setup classes takes away from actually tackling your problem directly?
The claim here is obsessing over what tools you have or don't have in object form, gets in a way of much simpler solution. "I have a this task I need a this object." That kind of problem.
From an engineering point of view it makes sense to ponder what tools are right for the job. But the job and the tool are far less risky to become synonymous when things are less abstract.
TBH C++ is dangerous because you can drink your own koolaid and enlist in an class-object ecosystem that just makes things harder to design and not a superior product that it might otherwise be.
TBF, there is a time and a place for one to take seriously their own eco-system. i give you this url for what iD did:
https://cppdepend.com/blog/?p=744
"1 – Provides a common base class with useful services.
Many classes
inherit from the idClass"
Having excess ways of doing things leads to another common criticism of C++. Too many ways to do things. Apparently every facet has universal turing machine property about it.
Including the generic stuff like templates.