Good book: C++ for Game Programmers

Posted November 26, 2010

Mike Dickheiser’s book, C++ for Game Programmers is great. It covers everything I was curious about in C++ in a way that relates to game programming.

Like I wrote in my previous post, C++ was the first language formally taught to me. I had learned BASIC (in the form of qbasic, BlitzBasic, and DarkBasic) before, but the classes I took in high school were based around C++. I suppose the C++ courses were good in that it introduced me to curly braces that all of us programmers are addicted to, but most of the code we wrote was in BASIC style using C. We did have to write a single class, but we never learned the difference between instantiating on the stack vs. the heap, or why you even wanted to use classes and objects in the first place.

Coming back to C++ after a couple of years playing with Java and C# feels good though, and Mike Dickheiser’s book is proving to be a great way of translating my way of though from managed, garbage collected languages to C++. The first part covers some of the basics of what C++ adds to C, starting with classes and objects, inheritance, multiple inheritance, templates, and exception handling before going into more advanced topics like memory allocation and the STL.

The parts concerning how objects are stored in memory are most interesting to me. When writing desktop applications in Java or C#, I don’t think I’ve ever thought about how my objects are stored in memory. What I mainly thought of was making sure I didn’t go too crazy creating new objects every frame, or, in the case of XNA, allocating most of my objects up-front to encourage the garbage collector to not run until I’ve release all of those and start allocating the next batch of objects. It’s all pretty loosey-goosey stuff compared to C++. I’m taking Computer Systems Organizations next semester, so I imagine I’ll have even more memory-related things to think about.
Anyway, I definitely recommend Dickheiser’s book. It’s heavy on the concepts rather than code, which is good, since he can explain more in less pages, leaving you to read whatever your favorite programming info sites for syntax-specific questions.