I'm desperately looking for a fast, C-like syntax, easy to embed, easy to wrap scripting language to embed in my C++ games.
So far I've tried:
I've also investigated:
So:
For C-like syntax, checkout
Probably not for you, but as this question might turn up a list of alternatives others would find interesting, I offer you QtScript which gives you a Javascript-like syntax. Wrapping can be straightforward, but you need to adopt the Qt framework to do it, particularly concept of signals and slots.
There's also SpiderMonkey, the JS engine from Firefox.
You might look at using JavaScript. The V8 scripting engine can be embedded in your program and there is documentation on how to expose your types.
You might be interested in Dao (http://daoscript.org/, https://github.com/daokoder/dao).
Dao is implemented in standard C with minimum dependency (if you exclude the optional modules and tools). It is lightweight and efficient with good support for embedding and extending. Its interface for calling C functions is not based on stack. Here is a simple example:
#include "stdio.h"
#include "daoValue.h"
static void Square( DaoProcess *proc, DaoValue *param[], int nparam )
{
daoint num = param[0]->xInteger.value;
DaoProcess_PutInteger( proc, num*num );
}
int DaoOnLoad( DaoVmSpace *vmspace, DaoNamespace *nspace )
{
DaoNamespace_WrapFunction( nspace, Square, "Square( num : int ) => int" );
return 0;
}
You may noticed that there is NO boilerplate code for checking the parameter types in the wrapped function. This is because this function is registered as Square(num:int)=>int
, which means this function can only accept an integer as parameter, and is guaranteed by the Dao runtime.
You may also be interested to know that it also has a tool based on Clang for automatic/semiautomatic generation of C/C++ bindings.
Disclaimer: I am the author of this language.
You could just use C++, via something like Cling.
You get familiar syntax and easy integration with your static C++ program.
Qt + Cling, the LLVM based C++ interpreter (2:05)
I seconded using python as scripting language, I used boost python before in my program (not a game) and quite satisfied with it. If you want to try creating you own script, you may want to try boost spirit
Aside from what others have suggested, there's also Cling which is deemed experimental. Writing a scripting language is not easy, but nowadays you can resort to LLVM, at least for the back-end. Programming language design is discussed briefly in the old "Algorithms+Data Structure=Programs" by N. Wirth (but do check the content topic, in the latest edition that chapter was removed) and if you search for the author on Google, you'll end up surely with some other publication about the topic.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With