Why Using C# and XNA?

There are tones of discussion threads on development websites’ forum, such as www.GameDev.net. Lots of C++ programmers are wondering if C# is good and efficient enough for developing games. I myself has been working on C++ and DirectX for many years, but until one day I picked up C# and XNA, I found a brand new world for game developers. People arguing about C++ and C# always have their own bias and concerns, performance issues for example, but from my opinion, we should consider more than that:

-         Game development cost

-         Project scale and development life cycle

-         Game features

-         Ease of finding or training developers

-         Performance

If a project's scale is relatively big and the schedule for completing the project is tight, C++ will for sure need much more time than C#. From our experience on developing the demo game CityRacer, C++ may need at least triple more time than C#. For C#, One typical example is that managed memory with garbage collector helps to avoid almost all memory related problems. In C++, sometimes, it is really hard to find memory problems. XNA Framework also provides lots of fundamental elements and frameworks for you, and that means you don’t waste time on building them by yourself. The trade off is that you may sacrifice the program performance. If the difference of performances is not noticeable and does not affect the quality of your product, why don’t we choose a cheaper way? By now, modern computers have high performance CPUs and GPUs. That makes just little difference between C# and C++ programs under most of situations.

Yes, some C++ game developers already have millions lines of C++ codes (tested and qualified codes) and do not want to give up them, but new games are expected to have more powerful and attractive features. For example, fancy and realistic graphics, physics simulated motions, more game options, and so on. All these new requirements may cause game programs to be much more complicated. That means we need to minimize project complexity. Definitely, using C# and XNA can lower game development cost and speed up development life cycle. In the mean time, finding and training C# developers needs less effort.   

Some people may think that C++ is professional programming language, where as C# is for beginners. I personally don’t agree. In computer programming realm, there is always a right way rather than a professional way. Benjamin Nitschke said in his book “Always remember this when you run into guys that might tell you C++ is superior and that C# is only for newbies. The same thing happened with Assembler and C++ few years ago, and in the future there will be new languages that make our life easier and there will still be people hesitant to adopt them right away. ”

Some people may say that I can use an existing game engine (no mater it is off-shelf or self-developed game engine) to develop new games, but I personally think that new games vary all the time, otherwise, there is no new games, so there is no such thing, a game engine, that can be used for all purposes and adapt to all games. Yes, you can use a tool to rapidly mock up a racing game (maybe couple of days), but you are limited and bounded by the tool. Your game program has lots of unnecessary codes in it (80% codes could be packed up in your program are unnecessary). In the mean time, you can not add specific features and optimizations to your game program to increase performance.  The result is that your game will always be in small scale and can never be a commercial product. If you visit some game engine websites, you can see their demos are either small games or specific type games (Shooters). I guess that is the reason why Microsoft only provides DirectX and XNA Framework rather than a game engine.

Learning C# and XNA Framework is not as easy as what people think it is (a piece of cake), but you can easily pick it up and do something in a short time (Using C++ and DirectX to start a new project from scratch may need couple of weeks or more time for beginners to render a model on screen. Most time it frustrates beginers and causes them to give up in the middle. For the same requirement, using C# and XNA may need only 10 to 30 minutes). The problem is if you want to be a game developer (no matter a programmer, an artist, or a designer), you need lots of fundamental knowledge, concepts, and practical experiences. For example, you need to know what these things are before you start working on them: ambient color, diffuse color, and specular color, LOD and mipmap, portal, BSP tree, and Octree, skinned mesh and bone animation, alpha blending and alpha testing, normal map,height map, view frustum culling, force feedback controller, sound frequency and volume control, and on and on. This is the most difficult part for beginners. Most of experienced developers may only know partially of them. That is also the reason why training new developers is so difficult (Most training institutes do not have mature curriculum and enough instructors to train students to match real industrial requirement).

When you find that it is hard to deal with the following situations:

-         Using C# and XNA instead of C++ and DirectX has not too much affect to your project’s performance.

-         Your project schedule and budget is tight

-         You want your game to be running on both PC and Xbox360

-         You need to train more developers to join your team and help to complete your project in schedule.

-         Your project is too complex and might need a long term to be accomplished.

You can consider using C# and XNA