Choosing Embedded Scripting Language For C++
Solution 1:
Lua is intended to be an embedded language and has a simple API. Python and Ruby are much more general purpose and are (for embedding at least) significantly more complicated. This alone would lead me to using Lua.
Solution 2:
Lua is already mentioned and using luabind will give you a more c++ style interface. You could also take a look at chaiscript. It was more designed to fit into c++.
Solution 3:
Save this as test.c:
#include<Python.h>intmain(int argc, char *argv[]){
Py_Initialize();
PyRun_SimpleString("from time import time,ctime\n""print 'Today is',ctime(time())\n");
Py_Finalize();
return0;
}
Run this command (if you have Python 2.7 installed):
gcc test.c -o test -I/usr/include/python2.7 -lpython2.7
Python has now been embedded. This took me under a minute, so I'm having a hard time understanding the claims of the "effort needed to embed it".
The example is from http://docs.python.org/extending/embedding.html.
I would suggest Python over Lua, even though Lua is also nice.
Solution 4:
I've had a lot of success adding embedded scripting to my C++ applications using AngelScript. I've found it very easy to bind and the syntax to be very comfortable, but it depends on your target audience. I found Lua to be very fast and relatively easy to bind, but the syntax was a bit uncomfortable to me. AngelScript is very C/C++ like which I find very easy to understand and maintain, but to someone who spends more of their time working with CSS or HTML, might find it cumbersome and the language idioms might not translate well..
http://www.angelcode.com/angelscript/
http://www.gamedev.net/forum/49-angelcode/
Just realized I had answered a similar question here:
Solution 5:
TCL would be another option for an easy to embed scripting language.
personally I'd go with the scripting language you and/or whoever will be using the scripting language is most familiar with already, especially if end users will be able to run custom scripts, you will need to know what, if any, languages they are familiar with in their business domain e.g. CAD/CAM people may know TCL, gaming people may know Lua etc.
Post a Comment for "Choosing Embedded Scripting Language For C++"