Use scripting languages in gamedev? It depends

What does the game or game developers gain (or lose) when having scripting language in the game?

Some games use scripting language to build gameplay code but some do not.

By scripting language I mean dynamically loaded bytecode or code that is compiled during runtime through interpreter or JIT engine. I go through some of the pros that first came to my mind.

Fast gameplay code iterations. It’s quite easy to implement script code reloading to enable much faster turnaround for code change. That can be also done remotely for example to a game running on a phone.

Modding and sandboxing. By giving end users possibility to easily change gameplay code, it can generate strong community around it. Scripting language also gives possibility to sandbox execution context for improved security and prevent crashes. For example Roblox combines these two and sends user created mods through the netcode.

Coding is easier. Often scripting languages such as lua implement memory management through garbage collection, this combined to the fact that scripting language is simpler than C++ can make gameplay coding more pleasant and productive.

What about the downsides of scripting language?

Need to implement a bridge between engine and gameplay code. That also means thinking how to send and receive messages between the layers or deciding how much of the game is implemented in the scripting language.

Another language to think about. A context switch has to be made when jumping across engine and gameplay code.

Poor debugging support and development experience. All big languages have lot’s of tools like IDEs and debuggers build around them. Those are probably lacking for the scripting language.

Low performance. Scripting languages are slow and they need to be interpreted on consoles and on iPhone, so performance is at least an order of magnitude slower compared to native code.

Thinking about my own gamedev projects, I would only implement scripting language when your main language doesn’t support hot reload during runtime. And/or when I want the game to be as moddable as possible. And maybe I would only choose little parts of the code that I want to be dynamically modified instead of trying to force generic scripting implementation on top of game engine.

Leave a Comment