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.

No comments: