Datasheet

http://XnaProjects.net — Another website created by the author just for hosting XNA
games like the ones in this book. It is a completely open website for everyone to use, upload games,
and to add your own links to, but there are no articles or tutorials on this site, just the games with
installers, source code, screenshots, and videos.
Is C# Good for Game Development?
There are constantly forum threads on sites like www.GameDev.net discussing the differences between
C++ and C#. Usually after a few posts, they all end in a senseless language war. Back in the early days of
.NET (2002) I discussed quite a lot in those threads, but it was way too depressing when 99.9 percent of
the programmers were on the C++ side and there was no way to convince anyone because they didn’t
even take you seriously. The language war does not really have anything to do with C# as a language,
but the constant language battles gave newer languages like Java or C# a bad start. For example Java
failed as a game programming platform except for cell phone games. But if you think about it, the same
kind of wars happened in the days when C replaced Assembler and C++ replaced C. Even to this day,
more than 20 years after C++ was developed by Bjarne Stroustrup, some game programmers still use C
and do not really take full advantage of C++. If you take a look at the source code for popular game
engines such as Quake or Half-Life, it looks more like C than C++.
This is something really strange in the game programming world; everyone is afraid of losing too much
performance by switching to a new language, and additionally, they fear that they might also lose their
old code base or have a lot of work converting it to a new language. However, game programmers
quickly adopt new techniques and scripting languages, and are always on the very latest hardware
developments. One year before Shader Model 4 cards were even available, we game developers had
Direct3D 10 available and many people checked this out without even having the hardware to run it.
I adopted .NET and C# pretty quickly in the beginning of 2002 after checking out the early betas at the
end of 2001. I had just started a new game engine and our team had a new project we wanted to do.
There were absolutely no graphic engines or anything but some simple 2D games around in the early
years of .NET. This made it very hard to use OpenGL or DirectX directly in C#. It required a lot of calls to
unmanaged dlls and involved a lot of nasty pointer logic, which is available only in the unsafe mode of
C#. In 2003, Microsoft finally released the first beta of Managed DirectX, which made it possible to pro-
gram new DirectX applications quite easily in .NET. It proved that using Managed DirectX instead
of the native DirectX dlls has only a performance impact of 1–2 percent, which is really not important
if you think about it (just the CPU has a little more work; most games are GPU bound anyway).
However, this did not mean that game developers were jumping on C#; everyone was still very skeptical
and even after I released the first commercial .NET game ever, Arena Wars, in 2004, it took another year
until more and more developers finally gave .NET another chance. Students and beginners especially really
appreciate the simplicity of C#, and more and more people started to develop games in .NET. C++ versus
C# discussions still exist and the discussion points are still the same, but the result is more balanced right
now. (I stopped looking at any topic that has “vs” in the name a long time ago; it is just a waste of time
reading the same arguments over and over again.)
Always remember this when you run into someone who tells you that C++ is superior and that C# is
only for newbies. The same thing happened with Assembler and C++ a few years ago. In the future, there
will be new languages that make our life easier and there will still be people hesitant to adopt them right
22
Part I: XNA Framework Basics
61286c01.qxd:WroxPro 1/21/08 3:44 PM Page 22