0
\$\begingroup\$

I'm making a very simple game that revolves mostly around user-created mods. So far I've seen most games using Lua or something like Lua to enable user scripting, but recently I've seen people using dynamically loaded, AOT'd libraries to increase performance. When would I use one over the other?

The only advantages I can find are that scripting languages are easier to approach by non-programmers (particularly Lua), or that dynamic loading will improve performance and will be more lightweight (no need for an embedded interpreter).

\$\endgroup\$
  • \$\begingroup\$ In this case, the questions boils down to: what are your needs and what do you want to offer to your users? Ease of use, or performance? \$\endgroup\$ – Alexandre Vaillancourt Mar 12 '15 at 14:17
1
\$\begingroup\$

Compiled: Code gets converted into a binary format that can run directly on hardware, or through a VM. (Virtual Machine) Executing the compiled code is specific to the binary format, and if it's not for a VM, then it can only run on specific hardware. (eg. a dll compiled for x86_64 will not run on an ARM processor. You would have to recompile the code to do that, and possibly modify it.

Interpreted: Code that gets executed from text. This avoids binary conversion, so it is cross-architecture (not dependent on any hardware), offers many debugging features unavailable to compiled code, and can (with a little extra effort) be edited in real-time (the script can be edited while the code is running, and have the code-changes represented immediately.)

Compiled:

  • Fast
  • Hardware dependent (x86, x86_64, Arm, PowerPC, etc)
  • The avarage user will be lost entirely

VM (Virtual Machine):

  • Faster than interpreted
  • Slower than compiled
  • Hard to implement
  • Hardware independent (it can run anywhere your game can)
  • Not commonly available. (Java and .net (C#) are the only common languages that I know of. And .net is only cross-platform because of Mono.)

Interpreted:

  • Slow
  • Easy to use
  • Hardware independent (it can run anywhere your game can)

As pointed out by akaltar, none of these are particularly slow. If your application is really performance intensive, then it might come into play. That would be your primary reason for using a compiled plugin interface. For basically any other reason, especially if you want your game to easily go across many platforms, you would want a VM or scripting language. The choice between those being dependent on what features you need.

If you want to see some benchmarks, Debian.org allows you to compare every language mentioned here and then some. You can select your two languages at the top and scroll through data and measurements on how fast the equivalent programs executed in each language, along with how much memory they used, and how CPU intensive they where.

Other Notes: Creating your own scripting/VM language would not be ideal. If your aiming for something that many people will be using, you would have to create and maintain a specification for that language, and handling every user problem as they learned a language never before used. Something like Lua is well documented, and many people already know how to use it.

\$\endgroup\$
  • 1
    \$\begingroup\$ I would add that Interpreted languages like Lua are not that slow(but obviously slower than VM or compiled). It would be nice to include some actual benchmarks. \$\endgroup\$ – akaltar Mar 12 '15 at 18:03

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.