I’m very interested in ChaiScript. I noted it has been around since 2009, and I don’t know how I’ve missed it this entire time. In fact, I’ve been looking for the “right” embeddable language for quite some time for a tool we use at work (in the past, I’ve used AngelScript and most recently Python). The issue is difficulty extending or crossing the script/C/C++ boundary or complaints abound the language itself by the users (Python has been exceedingly unpopular for some reason, despite the plethora of tutorials, examples, and documentation available).
So for the next iteration of the tool, I’m intrigued by ChaiScript. Looks very simple to embed. The ChaiScript/C++ interface looks clean as well. And should be popular with the users because of the C++ type interface. I also like embedding the stdlib to eliminate external dependencies (the problem with Python was users had to have Python installed as well, not just for the shared Python library, but also the host of python modules).
Before I dive into the questions, it might help to describe my use case. The internal tool I have is for a scripted test environment. It’s intended to be multi-purpose, but is mostly used right now to control test environments. We wanted it to be script based so there is no need to recompile or rebuild the test environment (as is the case with some tools like LabView). And we wanted it to be easily extendable to add support for custom interfaces. The current architecture is organized as event driven. Basically upon startup the script runs and does some configuration then registers a series of callbacks upon events (e.g. temperature reaches a certain level, voltage on an input drops below a certain value, etc). So there are 2 stages: 1) setup and 2) runtime.
So, I have a few questions about ChaiScript that will help with my evaluation:
- What are object lifetimes? Is there some sort of reference counting/garbage collection? After running the “setup” stage, do the created objects remain? Or do they need to be stored in order to be referenced during a callback?
- I see that ChaiScript can extend C++ classes (and vice-versa). But I’ve not seen anything related to inheritance. For example, if I have a class in C++ that I want to expose to the Chai side, I don’t see a way to derive a new class in Chai (though I suppose I can do a “has a” type relationship with a Chai class). I can extend the class by adding methods, but I can’t change the interface, for example by hiding methods in the C++ class. I suppose not really a question, just a general statement that perhaps someone can comment on.
- Does the multi-threaded support handle callbacks cleanly? That is, if I call back into a function from different threads, are these calls serialized? Or do I have to be worried about things changing?