XNA has been around for a while and just recently hit version 2.0 (XNA Game Studio 2.0). It’s now ready for proper use and below is a list of reasons why you should give XNA a try, and even start using it as your primary development environment.
Before I begin, I’ll list a few groups of people who XNA isn’t really designed for so they can move on and go back to C++ and DirectX (C++DX). If you’re a hardcore engine developer or you want to become one (eg. the next Carmack) then XNA isn’t for you. The main reasons for this are that low-level, hardcore engines like id tech 5 and the source engine will have to be written in C++DX (or OpenGL) for the time being. The other group are people wanting to make games for anything other than PC and Xbox. Everyone else (students, small studios, hobbyists) will gain something from at least trying out XNA. Read on to find out exactly what XNA can do for you.
It’s all about RAD baby
Rapid Application Development (RAD) is really where it’s at for games at the moment. We need to get prototypes up and running in no time at all so the “fun factor” can be sorted out before the first million is sunk into the project. XNA has this at a number of levels. Firstly it uses C#, a managed language which takes away a lot of the hassles of software development. I’ve been using C# almost exclusively over the past few months (in ASP.NET and playing with XNA) and I love it. If you’ve been through the gruelling hours of fixing access violations and memory leaks (and weren’t the one causing them) then you obviously know your stuff, and you deserve to move onto the next generation of language. It’s easier to use, cleaner, and feels so much like C++ it’s a breeze to step into.
The second RAD feature of XNA is in the XNA library itself. Rendering a 2D sprite of 3D model can be done in a few lines of code. All the hassle and crap of DX is hidden away, and you just load the model and render it. You still have complete control over how it’s rendered using .fx files (HLSL) however that’s all you need to worry about. Basically, XNA moves us a step higher in the level of abstraction. Instead of worrying about how to get the computer to render a 3D model, you worry about how the 3D model should look. It’s taking a more user focussed view on the problem of rendering a 3D model, rather than a software development view of how to actually get the 3D data onto the screen. This is just one example of how much nicer development is using the XNA libraries.
The third RAD feature is the build process. Most indie’s or hobbyists never worry too much about build processes as they just want to get the basics up and running. With XNA, they still don’t need to worry about it because there’s a build process already there for them. Build processes can take up a lot of development time on a medium to large scale project, having the ground work laid out will make life a lot easier for anyone requiring a more complex build process.
Getting in on the ground floor
Now for the hardcore coders out there, this is probably enough reason to at least try out XNA. However, I’d like to look further into XNA and see why this ease of development is not the biggest reason you should be switching over to it. I have one word for you, Microsoft. When Microsoft gets behind something, you really notice it, and Microsoft are placing themselves firmly behind XNA. Managed DX (MDX) disappeared of the radar a while ago and we’ve since learnt that XNA was its replacement. Anyone who spent any time using MDX may be a little pissed that their time was wasted, however they can rest assured that MS isn’t looking like doing the same thing for XNA.
With the release of XGS 2.0, XNA is now at a point where it can be taken seriously and people can start making “real” games with it. With networking support, and a simpler way of sharing games with others on XBL, it’s becoming a reality for anyone to start making games of the same quality as any XBLA game out there (and actually having them run on the Xbox). The fact that this has only just become the case now means that we are all standing on the ground floor and there’s only so much room in the elevator to the top. I can guarantee you from experience that there’s going to be a LOT of people trying to get into the XBL action when it becomes available and being one of the first is going to be the best way to stand out.
So what is the XBL action? Well, Microsoft is pitching XNA as being the “YouTube for games”. This sounds kinda cool, as it means that anyone can release their small game and have millions of people around the world play it, and possibly pay for it. This is great news for Microsoft as it’s going to encourage great games, and be another area that the Xbox stand out amongst the other consoles. As with YouTube, this will become very crowded quickly, so getting in their first will prove a valuable way of getting noticed.
It’s good for your future!
I’m going to have to put on my cynical hat for this section. The games industry, for many people, isn’t forever. Some people reading this may not want to get into the industry, others may only stay for 5 years (the average at the moment), and others still may find themselves unemployed just before Christmas. While this is part of why the game industry is in trouble at the moment, it’s actually advantageous for people thinking of switching to XNA.
The reason for this is that your skills are transferrable. Working solely on C++ will make it quite hard to find a “real job” out in the business world. Looking over business jobs, very few are looking for straight C++ programmers. C# on the other hand (and .NET in general) is in high demand. Having exposure to C# is going to give you a step up in the event that you find yourself not working in the games industry, for whatever reason.
It’s also inevitable that the games industry will one day move on from C++ into a next generation language. There are two main reasons for this. Firstly, as projects grow larger it becomes increasingly difficult to handle such a complex system without having some of the latest features that languages like C# boast. The second reason is that as we move into a world with crazy numbers of cores to work with (16+), we’re going to have free cores just sitting around with not a lot to do. The speed limitations of newer languages than C# can be offset by this extra processing power. Take garbage collection for example. Would you rather have an extra 100 blades of grass rendered on the horizon, or use a core to do your garbage collection so the performance hit isn’t noticeable? I don’t see this happening just yet, but it is inevitable, and C# is looking like a good contender for the next language.
For the naysayers
I’ve heard quite a bit of opposition to XNA, and C# and I’d like to address some of it now. Up until recently I wasn’t sold on XNA either, and I’ve had a lot of discussions with people about the pros and cons of languages like C# in the past. Below is just a quick list of reasons I’ve heard against XNA/C# and some counter arguments:
.NET/C# is just too slow
Version 1.0 of .NET had some performance problems; however a lot of these have been fixed. I can’t find any specifics of performance comparisons, but I’m hearing it is only 10% slower than C++ in some cases. C# is NOT interpreted; it is complied down to IL code and JIT’ed to machine code before being run.
A lot of people are using scripting languages for parts of their gameplay already. C# is MUCH faster than scripting languages such as python, LUA or game monkey script. Games using the Unreal 3 engine are written almost entirely in unreal script.
As with all coding, it’s more about the algorithms used than just the language. No matter how much faster or slower a language is if you don’t write good, optimized code then you’re never going to hit the 60 fps mark.
Learning XNA will put you at a disadvantage
A big question students will want answered is whether they should learn XNA to get a job in the games industry. The short answer is yes, but with a caveat. Every studio I know uses C++DX and so you’ll need to know this if you want a job with them. If you rock up to an interview knowing on XNA then you’re unlikely to get a job. However, if you turn up with a lot of XNA knowledge, and a few C++DX to show you know your stuff then you are a in a great position. Use XNA for rapid development on larger tech demos or an entire game or two. Just use C++DX for small tech demos to show you understand the tech.
The reason for this is that knowing XNA shows that you know 85% of what’s required for game development. You know all the theory behind it, you can write the shaders, and you can write all the gameplay code. The only thing you’re missing is the last 15% which involves some specific C++ stuff, and the basics of DX. Also, if you don’t want anything to do with graphics you can take the DX part out of the equation as well which means you know about 90% of what is required for game development by using XNA alone.
Many studios have C++ programming tests. If you can pass these then you can show that you’re a competent programmer. Personally, I’d look more favourably on a hardcore C# programmer that can also do really well on a C++ test, it shows they are a versatile programmer.
So, in the short term, learning XNA will put you at a slight disadvantage as you’ll need to learn C++DX as well. However, in the mid to long term, you’ll be at a great advantage. You can rapidly create games and tech in XNA to show off your skills, and you’ll generally pick up “game programming” faster as you won’t get bogged down as much. C++DX has a fairly steep learning curve, so using XNA will free you up to just becoming a better game programmer.
I’d highly recommend you download the XGS 2.0, follow the first couple of tutorials and see how easy it is to get a simple 2D sprite and a 3D model working with full Xbox 360 controller support. My next article will be more focussed on where I think Microsoft should be taking XNA in the coming year.
Big thanks to Shauno for doing the comic for this post.