Wednesday, January 31, 2007

Scripting Languages – The Bad News

Last time I introduced what scripting languages such as LUA and Python are used for in games, and some of the positive aspects of using them. This time we’ll go through some of the negatives generally found with scripting languages. Note that each scripting language is different, and may not suffer from all the problems listed.
  • Non-programmers don’t make great programmers. As you often ask non-programmers to do the scripting, they will often make novice mistakes, need help writing simple code, or make really nasty code (spaghetti code, bad naming of variables and functions, heavy use of global variables, etc). This can result in a buggy game, and end up using programmer time as the programmers are called in to fix things.
  • Scripting languages often lack a sophisticated debugger, like the one the C programmers will be using. This makes things very tough for the scripter, as they have to resort to inefficient debugging methods such as doing ‘printf’s to show how far the script ran, and what values specific variables have.
  • Fixing warnings from the script compiler can be difficult for a non-programmer.
  • Though you might start off thinking that you’re only going to write a little code in the scripting language, you often end up writing more than you intended (e.g. enemy AI), and script execution (which is usually a lot slower than the execution of C code) becomes a performance bottleneck for your game.
  • As with any piece of middleware, you’re bringing in a large block of someone elses code. At some point you’ll likely need to track down a memory leak or otherwise debug inside the code. For example, you might be calling the scripting API incorrectly, which is causing a memory leak, so you discover that memory is leaking inside the scripting system, and start stepping in to it, to track down why. This can be difficult if the code is not written in an easy to understand manner.

It’s not a long list of negatives, but in combination, by the end of a project, these problems can cause a lot of headaches.

As you might expect, it’s too simple to just give scripting languages an overall thumbs up or down. The choice of whether to use them needs to be carefully made for each game. The particular scripting language, what it will be used for, and who will be using it all play big factors in making a decision.

Next time I’ll present a common alternative to using scripting languages.

Console comparison

I'm forever forgetting the differences in specs between PS3, Xbox360 and Wii. I've been meaning to write a comparison for a while, but thankfully found someone else has written one.

A couple of the most fun parts of the comparison are the CPU and Memory. Wii has about 1/8 of the memory of the other plats, and the Wii has a single core which is less than 1 GHz (as opposed to 6+ cores at 3.2 GHz). I still want a Wii mind you.

Monday, January 22, 2007


I just upgraded to 'new blogger', and have managed to lose my template.

I have a copy of my old template, but it doesn't work with the new system, so it'll take me some time to track down what has changed...

If there's one thing I like about blogging, it's writing template html :( 

Scripting Languages - The Good News

 Many commercial games use scripting languages such as LUA or Python as part of their engine. Here’s a run down of what they’re used for, and some of the good points of using them.

  • Scripting languages are generally used for making ‘things happen’ in the game world. For example “when the player walks here, make the enemy appear”, “after this much time has passed, play this sound”, “if the enemy loses 50% of his health, tell him to start using his special attack move”.
  • Looking at these types of needs, you can see how they’d fit quite nicely into code. They read like if..then statements, followed by function calls. But it’s also pretty simple, it seems we could live without templates, intrinsics, header files, operator overloading, and other advanced language features.
  • To integrate the scripting engine into the game, and have the scripts be capable of doing useful things, the programmers have to wrap C/C++ functions in a way which makes them callable from the script. Also the programmers have to provide a way of launching scripts when certain events happen. To take the first example above, when the player enters a trigger volume, it must be capable of launching a script. In that script, the script would then make a call on the engine to tell a specific enemy (perhaps by a name in a string) to appear. A pseudo code script could look like this:
On_PlayerEnter_Volume44 ( )
EnemyAppear ( “Enemy62_Soldier” )

  • As the game is going to have lots of this type of game logic by the time it ships, it would be nice if we kept all this game specific hackery away from our nice clean game engine. Putting it into script files separate from the engine code makes the division nice and clear.
  • If you use a simple language, someone who’s not a programmer could write the scripts. This can save valuable programming time, and give the game designers greater control.
  • The scripting languages can either be interpreted at run time, or recompiled without the game engine stopping. This means that you could run the game once, and then repeatedly iterate on the scripts without having to restart the game. This can give a big saving on iteration time, compared with stopping the game, recompiling, and re-running.
  • As open source scripting languages have already been developed and used on many other products and platforms, you can very quickly integrate a feature rich scripting language into your game, without having to build and debug your own.
  • Scripting languages give you a bunch of basic features like variables, math functions, and string handling functions. These might sound like trivial features, but a common alternative to scripting languages struggles to replace these pieces of functionality.

Well that sounds great! You’d be crazy not to use them :)
Next time I’ll go through some of the down sides of using a scripting language.

I'm back!

Sorry for the infrequent posts over the last couple of months. I got married, my folks were in town for several weeks, and generally there was lots of stuff going on...

Now things have calmed down a bit, and I'm hoping to make more regular posts.


Monday, January 01, 2007

How to Pick a Games Console

So which console is the one to get? Xbox 360, PS3 or Wii?

Someone (I can’t remember who) once gave me the following simple piece of advice about how to pick which console to buy.

Work out which games you really want to play, and base your choice on that.

You inevitably end up wanting all consoles for different games, but if you think of a good number of games, you’ll hopefully start to see a pattern.