views:

129

answers:

3

I'm looking at game dev., primarily for *nix and thought I'd go through learning C before I go through learning C++. When I go look up info on game development on youtube and google a lot of the results are C++ game development tutorials.

I've found that most/all(?) game consoles use C++ for development and know that C# probably helps for windows game development, and even MS pushes C++ for that anyway. But why isn't C given as much attention in regards to game development as C++?

Why is C++ favored, given more attention, over C in game development?

+7  A: 

Several features of C++ made it popular for game programming.

  • Strong language level support for OOP. Object oriented programming maps itself really well to most game logic.
  • Good interop with C and external libraries. Most external libraries are written as C/C++ good (legacy, graphics, many APIs) and it's easier to link to them with C++.
  • Speed, much of the game programming business started before C# was a realistic choice for high speed programming. C++ properly coded can provide very high speed along with nice abstractions.

C++ has many downsides as a game programming language, see Tim Sweeneys article on the subject and many games are written in higher level languages embedded into a C++ engine, Unreal Engine being a great example of this, and pretty much any complex RPG contains a scripting language embedded in the game.

Daniel Goldberg
+1 for OOP and interop.
PeterK
A: 

C++ is object-orintated, C is not. Object orientation is important for 3D games.

Josh
A: 

There's next to no reason to use C on a platform that has C++ available. The latter has almost all the functionality of the former plus more besides. It has little to do with games and more to do with using a more expressive language with a better standard library.

Kylotan
Strongly disagree. C provides many things C++ does not, such as interop with languages that are not C++ (C++ has no ABI), a clean programming interface, strong readability and a clear translation from code to binary. All things that C++ lacks.
Daniel Goldberg
You're contradicting your own answer here. These are all features of C which C++ can employ, except for readability which is subjective (verbose and explicit vs brief and implicit).
Kylotan
Wrong, C++ classes neccesarily prevent interop. The C++ standard never set an ABI and therfor linking externally to your classes is a pain.Also, readability may be subjective, but the 100 character definitions of most C++ templates is rather strongly against readability.
Daniel Goldberg
A feature that doesn't work with interop doesn't mean "C++ doesn't provide interop". And I have no idea what you're trying to claim there about templates.
Kylotan