Categories
Game Development

Scripting vs. Coding

I’ve been looking at a lot of 3D engines lately for my new game. Some of them rely heavy on scripting, most of them have some scripting, and a few are raw C++. I want to address the pros and cons of scripting, and why one should or should not script. On the positive end, […]

I’ve been looking at a lot of 3D engines lately for my new game. Some of them rely heavy on scripting, most of them have some scripting, and a few are raw C++. I want to address the pros and cons of scripting, and why one should or should not script.

On the positive end, scripting allows you to design a system that is more flexible and easy to use than coding. With a script system you can abstract away a lot of the heavy or burdensome parts of programming. This is especially true of variable declarations, scoping, and interfaces to both code and data. For example, when I modified the interface in the Torque engine I was able to map the button to an action with one simple line of script. I was even able to put script into the interface engine itself. It wouldn’t have been as easy in a straight C++ implementation and in all probability no attempt would have been made to provide such an interface.

On the negative end, scripting brings with it a learning curve and, unless you base your script on code or well-known tools (C#) you also give up all the tools at your disposal. Both of these are significant. When I had to learn to script in Lua it took me a week to really get productive. While that may not be an issue at work, it is a very significant issue if you make a competitive public engine. Anyone would rather use an engine they can use right away rather than one they have to spend a week learning, especially if that learning is not applicable to anything else. The lack of tools can be far worse, depending on the situation, typically the worse the closer you are to doing programming. FarCry does not use Lua for scripting. It uses it for programming. What happens to the productivity of a programmer when no debugging tools are available? Try writing a program without breakpoints, debug windows, or error messages sometime.

Script should be for level designers. Level designers don’t know how to program. If your level designers can’t figure out how to use your scripts, then you need to hire programmers. If you need to hire programmers, you might as well let them use C++, where they will be the most productive. Otherwise, just like programming without a debugger (i.e. javascript), you’re throwing a lot of effort and money into a hole for no good reason.

The last point I’ll make is on good script design.
Script, properly designed, is designed for level designers to use. Conversely, it should not be designed for programmers. Your script design should, and this is worth saying in bold, assume people are fallible. This means that people make mistakes. If you create variables implicitly, people WILL do this by accident. If you require an obscure syntax, people WILL forget to abide by it. If you use NULL as a valid value, people WILL pass this by accident. Each time these “WILLs” happen, that is wasted time and money down the hole.

One reply on “Scripting vs. Coding”

Leave a Reply

Your email address will not be published. Required fields are marked *