r/cpp • u/HolidayNo84 • Jul 02 '26
Why use c++ over c for game development?
Isn't c++ overkill for most games? I think with good architectural decisions you can make decent 2d and 3d games using only what's available in c without the higher level concepts introduced in c++? Do you think I'm being stupid here? Am I missing something? I'm only just starting to learn c making simple games leaning heavily on Raylib and ECS architecture.
0
Upvotes
View all comments
Show parent comment
1
u/oracleoftroy Sep 06 '26
What exactly do you mean by this? Because frankly, a lot of the time when I hear the anti-OO crowd say stuff like this, I picture the following meme:
A rather long-standing bit of C++ advice for good class design is: "Prefer non-member non-friend functions to member functions." That's item 23 in Effective C++, 3rd edition, 2005 (Meyers) and item 44 from C++ Coding Standards, 2004 (Sutter, Alexandrescu). I think this originates from Meyer's Dr. Dobbs article "How Non-Member Functions Improve Encapsulation" from 2000. All are very good reads.
So in short, it's been a C++ OOP best practice to not make everything a member function for about 26 years at least. C++ is not like Java or C#, it doesn't force you to put everything in classes. And that's a good thing. Free functions are great.
Moreover, most objects won't have virtual methods, and most should behave like value types and avoid pointer indirections where possible. Objects can encapsulate SoA style data.
To be honest, a lot of the anti-OOP arguments are based on things OOP programmers already recognize as bad practice. But for some reason they seem to think all OOP amounts to deep inheritance hierarchies, run time pointer chasing graphs of data, and all sorts of other things that are simply bad design and independent of OOP or Procedural or Functional, etc. Bad practice doesn't become good because the slow pointer chasing isn't done in a OOP paradigm.