Thursday, February 22, 2007

C# As a Game Development Tool

My university course does not teach C#, I know I’ll have to learn it by myself if I want to gain any sort of foothold in the gaming industry, particularly since the Xbox 360 development Kit (XNA) uses the simplicity of C# as a means to increase productivity and reduce overhead costs.

Microsoft is pushing C# as more or less a direct competitor against Java, it shares virtually all the same principles, such as pulling the programmer by the ear telling him what to do and how to do it.

Why would Microsoft want to push C# as a pseudo standard language for games development? No matter how hard they press C# it will never substitute the power C++ gives programmers, it simply isn’t designed in anyway to compare to C++ when it comes to doing what C++ does best, blowing peoples legs off.

Developers will definitely buy into the XNA and C# because it can reduce overhead development costs significantly, C# is easier to use, easier to debug. Sure it can’t squeeze more out of the hardware it’s running on but that never was the point of C#.

Gameplay code, development tools, these things don’t need to be optimized so much, they don’t need to be mapped out onto the hardware in some inane way to get the most out of it.

Think of it this way, when programming a game engine you want to have direct access to as many parts of the hardware as possible, even API’s won’t let you run your software the way you would want to, as such C++ is a necessity, you’ll put up with the complexity because of the performance pay off.

But what if performance was not a factor? Would you want to bother about managing memory first hand? Would you want to go around looking for memory leaks or optimizing the garbage collection process? Well obviously not, which is exactly why C# excels in applications where performance is not the biggest factor. It handles pointers automatically as such you can avoid memory leaks, it runs high level so there won’t be any hardcore debugging happening, it just works.

Lets take a game like Gears of War for instance, based on Unreal Engine 3 which was written in C++. All the gameplay code is in C#, the game itself is built right on top of the XNA, the engine of course is C++ based. My assumption is that the gameplay programmers (whatever their titles are) can directly interact with the engine via the XNA through C#, they won’t need to look any further than that, save for bugs that might be present in the game engine itself. So they won’t be spending precious hours hunting down memory leaks but being productive.

Which is why XNA with the simplicity of C# is a great tool for developer, it not only gives developers an option to reduce workload but also encourages it. This also gives the edge to Xbox 360 developers over Playstation 3 developers. While the Playstation 3 requires C++ compiled programs it can technically support C# too, providing the software is written for it via C++ for it to support C#.

Naturally this won’t happen, the XNA concept is Xbox 360 exclusive, Sony isn’t simplifying game development on their console anytime soon, it really will be giving Xbox 360 developers an edge in terms of overall productivity.

2 comments:

Anonymous said...

Also, if speed was the only thing developers looked at, they would still be using C.

Serious companies, like Blizzard, abandoned C a decade ago, adopting C++.

They didn't need the speed, they needed code reusability through the object oriented model.

C++ was tacked on to C, providing OO.

C# was built for OO from the ground up.

On top of that, C# is immensely faster than Java, and, unlike Java, it is not proprietary.

Lsat, but not least, Microsoft tied XNA to .Net Compact Framework, which runs on Windows Mobile. It doesn't currently do so, but I'm sure they have plans for it.

I think you will see even big companies switch to C#.

Cheers!
Joran
XnaTutorial.com

Ahmed said...

Well I agree in part, however Java is 0.91 the speed of C++ and the reason I believe it is being held back is from a sub par 3D API. Obviously C# is being pushed with the full weight of Microsoft and it has an extremely easy to use 3DAPI in directx.

C++ has found a nice in-between, C# is too restrictively imo because it does a lot of things in the background wherein C++ gives the programmer access to pretty much everything in the hardware.

While big companies should and will start using C# for high level programming I don't see how it can be used for graphics engines where optimizations recquire lots of low end tricks C# is incapable of (lest it's done through an API in which case the API would not be written in C#).