Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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.
like image 533
Andrew Grant Avatar asked Aug 18 '08 23:08

Andrew Grant


2 Answers

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.

like image 165
Mark Harrison Avatar answered Sep 22 '22 21:09

Mark Harrison


I have played around a little bit with Spidermonkey. It seems like it would at least be worth a look at in your situation. I have heard good things about Lua as well. The big argument for using a javascript scripting language is that a lot of developers know it already and would probably be more comfortable from the get go, whereas Lua most likely would have a bit of a learning curve.

I'm not completely positive but I think that spidermonkey your 4 requirements.

like image 45
mk. Avatar answered Sep 21 '22 21:09

mk.