Thursday, November 01, 2012

C# for Game Development

I recently had an email asking how C# stands up as a game development language these days. I thought that was quite an interesting question; I'm very optimistic for the future of C# as a game dev language. Here's a cleaned-up version of my full reply.

Since I wrote the book C# Game Programming; the the landscape has changed; Tao has been renamed http://www.opentk.com/ now and XNA support has been dropped by Microsoft (just like they dropped the original C# bindings for DirectX, I can imagine it being deeply frustrating for people who have spent time learning the API. There's a story here: http://www.wpcentral.com/xna-dead-long-live-xna . Though, of course, XNA games will still work for sometime yet, just there will be no updates.)


On the growth side; game engines like Unity use C# and have become
really prominent in the games industry. Sony has recently released the PlayStation Mobile Suite for indies to develop on Vita (and other mobile devices), that's also C#. It's great to see that C# has now become quite a viable language for console and mobile development. 

Unity games are released on all sorts of platforms - the games can definitely be competitive with handcrafted C engines ( http://www.interstellarmarines.com/media-section/ ). It has excellent support and resources but it's a closed platform, it too could go the way of XNA one day (though I don't think that's particularly likely anytime soon). There's monogame, an opensource version of XNA, as well but I haven't looked at it. Overall since a year ago C# has become a more popular language for game development.

C# is very fast, enough for a blockbuster type game. The code that really needs - down to the hardware fast - has slowly been migrating from the CPU to the GPU and is all handled through shaders. The language used for the gameplay code is becoming less about speed and more about ease of expression for the developer. A lot of big name games use scripting languages to run the game logic - Lua is popular and that's much slower than C# (but far easier to embed in C programs and very portable) 


If I was starting a new game project today - I'd use Unity, unless it was 2d, then I might have a look around and see if there's anything more suitable - moai? The general way 2d games are made in Unity involves setting everything up in 3d space and it seems a bit of a faff to me, though it can allow for some nice effects.

My main issue with C# and Tao/OpenTK is deployment - it's fine if you write an installer but if you just want to throw someone an exe to try it out - then you need to make sure they have the correct version of C# installed and send them all the relevant dlls. It wasn't particularly easy for a non-technical user to get everything running.  In my current projects deployment is something I try and make as smooth as possible. Unity does this very well because of it's webplayer - there's no barrier to overcome for the player, they just have to click a link and they're in the game!


Overall I think the future is looking quite bright for C#, it's not the perfect language but it's pretty good. I think it suffers the same disease as C++, each release adds some more features, more keywords and it makes the language less elegant, clean and easier to intuit. Despite growing in complexity I think it has quite a good future in games until multicores CPU's become more and more prevalent and we need something that can handle parallel programming better.
Post a Comment