Why use .NET for Game Programming?

This is clearly the first question that you should ask youself before embarking on the road to learn a .NET programming language!

In conventional programming languages you often have to wrestle with platform and even compiler/IDE-specific idiosyncrasies, like placing an external DLL into the right directory, then including the matching headers and finally reference the right import library just to use some external functions.

.NET provides a much more sane environment to work in. Any .NET program on any system has the .NET framework available, a set of well organized classes that allow you to do common things like accessing files, connecting to other computers and interfacing with the user. Using other class libraries is just a matter of adding the .NET assembly (in other words, a .NET-enabled .dll) into your project. A .NET assembly carries all the informations needed by the compiler with it.

So, in short, it is all about getting more done in less time, and having more fun at the same time.




Myth: .NET is not portable

As explained in What is .NET?, .NET programs are compiled into a platform neutral intermediate language called CIL. Just like Java Bytecode, this language has no connection to the underlying platform and thus, can be executed on any platform of your choice -- given that someone has undertaken the effort of implementing the .NET runtime and .NET framework there.

Linux users can already choose between two implementations of .NET that can be used to run almost any .NET application on their systems: Mono and DotGnu. Unless the programmer has explicitly imported platform specific external functions that are not available on other platforms, you can run a .NET application anymore, unmodified. Usage of external functions is rarely required and we will show you how to solve your problems in a portable manner so your games run windows and linux alike!

The main programming language of .NET, C#, has been standardized with the ECMA. Other languages, like Eiffel.NET or Boo aren't even connected with Microsoft at all.




Myth: .NET is slow

Another myth is that since .NET programs are not compiled to machine code right away, they have to be slow.

See, normally the .NET runtime compiles a .NET program to machine code just at the moment the user launches it, and even then it only compiles those parts that are immediately needed. This is called just-in-time compilation (JIT). As a result, the compiler has very little time to analyze and optimize the program, so it runs a lot slower than a normal compiled C++ program, right?

Not at all. Read C# vs C++ Performance to see that the typical performance of a C# program isn't much different from that of a C++ program. CIL code already contains many of the hints a C++ compiler has to painstakingly extract from the source code.