Search code examples
javascriptc++pythonscriptingembedding

Embedding a scripting engine in C++


I'm researching how to best extend a C++ application with scripting capability, and I am looking at either Python or JavaScript. User-defined scripts will need the ability to access the application's data model.

Have any of you had experiences with embedding these scripting engines? What are some potential pitfalls?


Solution

  • It's sure easy to embed Python by using the Boost::Python library (ok, ok, sarcasm.) Nothing is "easy" when it comes to cross-language functionality. Boost has done a great deal to aid such development. One of the developers I've worked with swears on the Boost->Python interface. His code can be programmed by a user in Python, with a REPL built right into the UI. Amazing.

    However, my experience has been better observed using SWIG and other languages such as Java. I'm currently working with SWIG to wrap C++ with Python. There's all sorts of gotchas with exceptions, threading, cross-language polymorphism and the like.

    I'd look at these two places first. As I said, nothing will be "easy" but both these make life more livable.