Characteristics of a Scripting Language

A scripting language must have several characteristics.

Productive

Scripting languages increase the productivity of the team in various ways. For example, reducing the time it takes to implement something and see the effect of change made to the game is directly related to productivity. In addition, because scripts are easy to write, more developers can add functionality and tweak the game. Scripts also allow for parallel development where multiple scripts can be worked on at the same time without having any dependencies.

One of the most important advantages of scripting languages with respect to productivity is that they allow applications to have a data-driven workflow. Therefore, when the fundamental functionalities for accomplishing different tasks have been developed, you can easily modify and twiddle with the game. Take a real-time strategy (RTS) game, for example. An RTS game that has many different units with different behaviors needs a lot of tweaking and game balancing. If developers can easily modify the game to try out different variations, the development processes will be much smoother.

Some games require a scripting language more than others. Data-driven games can be looked at in two different ways. Some games may strictly need different sets of data. For example, a racing game can benefit from a data-driven design by describing a car as a list of numbers. Some cars may have different gear ratios, steering radius, power, and so on. Many racing games have one central physics model, and the variation is achieved through different settings for the physics model. In this scenario, a scripting language is not necessary. A simple text file can be used to store the different parameters. If you need to store tables or lists of information, Microsoft Excel files can be useful. If you want a structured text format, you can also use XML files. The popularity of XML files has been growing over the past few years. In fact, many in-house tools made by game studios use XML files as their intermediate and even primary file format.

On the other hand, some games need variation through both data and functionality. For example, the puzzles of a game may require both different data set as well as some new functionality. Unlike the previous example, in which the behavior of different cars could simply be defined by a list of simple data, every puzzle may require its own special code or functionality. The same holds true for a game where the world needs to be populated by triggers that activate unique functionality, such as moving a platform, turning on a light, or controlling the camera. In these scenarios, you need a way to provide different data and define new ways to manipulate the data. In other words, you actually have to write some code as opposed to some simple data.

Easy to Learn

Scripting languages typically are and should be easy to learn. By being so, novice programmers such as artists and level designers can learn the language and experiment with the game without having to go to the programmers. As a result, the programmers can spend more time on tools and technologies rather than writing the game logic. In addition, level designers can be even more creative and get a better feel for what is possible with the technologies provided by the game engine.

The simpler the language, the less time is needed to learn enough to accomplish different tasks. If a language contains a lot of difficult-to-understand concepts, it can be overwhelming for developers. For example, the more features the language has, the more complicated it tends to be. Another reason why scripting languages are easy to learn is that they are more forgiving when the developer makes a mistake.

Development support such as documentation, tutorials, existing libraries, and debugging tools can significantly reduce the learning curve. They allow novice developers to get started, learn proper practices, and accomplish tasks in a shorter amount of time. Inadequate documentation is a serious problem. Regardless of how easy a language is, if a developer cannot easily find out how to use the language constructs, the learning process will still take a long time.

Existing libraries are also an important factor in making a language easy to learn as well as increasing productivity. A language that is simple but does not have enough libraries can still be challenging to use. In fact, not having a sufficient amount of libraries can cause novice developers to replicate a lot of functionality in their code, which can increase bugs, bloat the code, and lead to unnecessary inefficiencies. If a programmer is responsible for writing the libraries, that person should also be responsible for providing adequate documentation and code sample to demonstrate how the libraries should be used.

If a game needs to be extensible by the user community, using a scripting language that is easy to learn becomes even more important. Modifying an existing game to make different games has been proven essential to the longevity of several games. If the language is difficult or requires a lot of preparation and setting up, far fewer users will be able to modify the game. For example, Quake III required a more substantial amount of expertise and commitment to modify than Unreal Tournament or even WarCraft III. The number of custom games implemented with WarCraft III is substantially higher than those that use Quake III, even though the latter has been around for quite some time and has been used for making numerous commercial games.

Flexible, Powerful, and Extensible

A scripting language should be powerful enough so that the necessary tasks can be accomplished in the scripts. The simplicity and power of a language tend to work against each other. The more powerful a language, the more sophisticated it tends to be. For example, scripting languages that have objects are more powerful but also have a higher learning curve.

The flexibility of a scripting language is also important. Many games use scripting languages for a wide variety of tasks. The game code, menus, and cut scenes are just a few examples of tasks that have been accomplished in scripts.

If a language is too limited, it is critical to have a way to extend the language because certain features may not be necessary until you actually realize they are needed. The language must be extensible, especially if the scope is extremely limited. Languages that are powerful enough and have already been used for the tasks you need to perform do not need to be as extensible.

Stable and Efficient

The stability of an interpreter or the virtual machine is vital. The last thing any game needs is a scripting language that fails internally for reasons beyond the control of the developers. An interpreter or virtual machine has various components that can be rather complicated. An unstable interpreter will cause problems that can undo any benefits that scripting language provides.

The efficiency of the interpreter can be important but can also be irrelevant if the number of scripts used in a game is trivial. This is in part because all performance-critical tasks are typically handled in native code. If the scripting language is efficient, more code can be handled on the script side. If scripts are used only for tasks such as the menus, efficiency may not be as big of a concern as it would be if the entire game logic or opponent AI were written in scripts. Generally, the more scripts and the longer the scripts, the more efficient the interpreter must be. Note that memory management must also be efficient enough not to cause noticeable problems. Memory management is easy to do but hard to do efficiently.

Safe and Secure

The safety and security of a scripting language is a characteristic that should not be overlooked. A script should not be able to crash the entire game. It is hard to describe the enormous bottleneck that an unsafe scripting language can cause. Consider trying to tweak the game, and mistakes in a script crash the entire game. Let’s say the game is being tested and halfway through a level, the game crashes. As you can imagine, for a novice programmer, debugging the scripts can become as difficult as debugging a C/C++ project. If the game crashes, it needs to be rerun many times just to get a feel for what may be causing the problem. Keep in mind that unlike debugging a small stand-alone project, just to test whether a bug has been fixed you may have to play through part of a level, which can be very time consuming.

What can crash the entire game? Any direct memory access from scripts is dangerous. Even if direct memory access does not exist, arrays should be indexed within the valid bounds. Any improper array access should be caught and disallowed, because if some array overflows, it can corrupt data used by other scripts or components of the game. As a result, another component whose data has been corrupted may crash first. These types of problems are unwelcome and should not be possible in a script. Even if an illegal operation is performed, the interpreter should handle it gracefully.

The interpreter should not execute invalid code. For languages that allow precompiling of the scripts, the compiled representation may have to be checked to make sure it does not contain invalid compiled code. For example, a branch statement may be trying to jump to an invalid line. This step is especially important if scripts or modules can be downloaded in compiled form.

A secure scripting language is one that does not allow for cheating, does not allow any illegal operation to occur from the script, and even prevents information stored in a script from being accessed from native code. Not all games need to be concerned with security, but those that do need to guarantee secure scripts have a tremendous task before them. For a language to be as secure as possible, it has to be designed with security in mind.

Runtime Code Execution

A system that allows code to be executed during runtime can be used to configure and tweak an application while it is running. In fact, this ability is the most important characteristic that makes scripting languages vital to most applications. Runtime code execution is useful for debugging and allowing for a comprehensive in-game console. If a game or application has a console that allows the user to execute code, values that are used by the game can be tweaked to get immediate feedback about minor changes without having to restart the game. This characteristic is especially important for configuring and manipulating programs that run for a long period or are costly to restart. For example, a game server must be manipulated without shutting down a game in progress. Because testing a game can be very time consuming—because it takes some time to launch the game and reach the point in the level where things need to be tweaked—being able to run code at runtime can be a handy feature.



Practical Java Game Programming
Practical Java Game Programming (Charles River Media Game Development)
ISBN: 1584503262
EAN: 2147483647
Year: 2003
Pages: 171

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net