Tuesday, May 10, 2005

Why Are Games Written In C++?

Most computer games are written in C++ partly because the industry is slow to adopt new languages, but developers like C++ because the more performance a developer can get out of a system, the more power they can use for graphics, AI or something else. C++ is a language that trades performance over safety.

For example in Visual Basic data is checked before it is stored in memory to see if it is safe, but C++ will do anything that the code tells it to without checking because checking would require CPU cycles. Think of it like crossing the road. Most languages look both ways to check for cars, but C++ will walk straight across the road without checking because it is faster, and so it is upto the programmer to make sure that at that point there are no cars coming.

There is a move by Microsoft to get developers programming in managed code so we will probably see that with XNA.