Why use C++? Why not C, ASM, or Java?

I had a few other language choices that I was kicking around when planning this book. Although there are acolytes out there for Delphi, VB, and even C#, the only languages I seriously considered were C++, Java, and C. Java is designed by Sun Microsystems and an inherently object-oriented language, with some high-level language features like garbage collection. C is about as low level as programming gets without dipping into assembly. It has very few if any high-level constructs and doesn't abstract anything away from the programmer.
C++ is an interesting language because it essentially sits directly between the functionality of the other two languages. C++ supports COM better than C does (this is more thoroughly discussed in Chapter 1). Also, class systems and operator overloading generally make code easier to read (although, of course, any good thing can and will be abused). Java, although very cool, is an interpreted language. Every year this seems to be less important: JIT compilation gets faster and more grunt work is handed off to the APIs. However, I felt C++ would be a better fit for the book. Java is still a very young language and is still going through a lot of change.

Do I need a 3D accelerator?
That depends. Technically, no, you can get by without any accelerator at all, using Direct3D's software rasterizer. However, it's extremely slow, far from real time for anything but trivially simple scenes. It's almost impossible to buy a computer these days without some sort of 3D acceleration, and an accelerator capable of handling all the code in this book can be purchased for under $100.
How hardcore is the C++ in this book?
Some people see C++ as a divine blade to smite the wicked. They take control of template classes the likes of which you have never seen. They overload the iostream operators for all of their classes. They see multiple inheritance as a hellspawn of Satan himself. I see C++ as a tool. The more esoteric features of the language (such as the iostream library) I don't use at all. Less esoteric features (like multiple inheritance) I use when it makes sense. Having a coding style you stick to is invaluable. The code for this book was written over an eleven-month period, plus another three for the revision, but I can pick up the code I wrote at the beginning and still grok it because I commented and used some good conventions. If I can understand it, hopefully you can too.

Post a comment