Search code examples
scriptingdata-driven

Which scripting language to support in an existing codebase?


I'm looking at adding scripting functionality to an existing codebase and am weighing up the pros/cons of various packages. Lua is probably the most obvious choice, but I was wondering if people have any other suggestions based on their experience.

Scripts will be triggered upon certain events and may stay resident for a period of time. For example upon startup a script may define several options which the program presents to the user as a number of buttons. Upon selecting one of these buttons the program will notify the script where further events may occur.

These are the only real requirements;

  1. Must be a cross-platform library that is compilable from source
  2. Scripts must be able to call registered code-side functions
  3. Code must be able to call script-side functions
  4. Be used within a C/C++ codebase.

Solution

  • Based on my own experience:

    • Python. IMHO this is a good choice. We have a pretty big code base with a lot of users and they like it a lot.
    • Ruby. There are some really nice apps such as Google Sketchup that use this. I wrote a Sketchup plugin and thought it was pretty nice.
    • Tcl. This is the old-school embeddable scripting language of choice, but it doesn't have a lot of momentum these days. It's high quality though, they use it on the Hubble Space Telescope!
    • Lua. I've only done baby stuff with it but IIRC it only has a floating point numeric type, so make sure that's not a problem for the data you will be working with.

    We're lucky to be living in the golden age of scripting, so it's hard to make a bad choice if you choose from any of the popular ones.