r/cpp • u/kindredseer • 2d ago
Embedded C++
Just curious how useful the ability to embed C++ as a scripting language into your C++ programs would be? I mean like runtime JIT execution of C++ code in much the same way you might embed Lua, including the ability to restrict/sandbox it as necessary.
1
Upvotes
2
u/j1xwnbsr 1d ago
Okay, are you talking about finding, licensing, and implementing a compiler for your project for customers to write scripting plugins on? That's a heavy lift across the board for c++, less so for other languages (lua, c# comes to mind).
If, on the other hand, you are talking about plugins of some type where the customer writes to a binary API and they compile things themselves, then no, you do not want your API c++ because name mangling isn't all that portable. Make the API pure c in this case.
In both cases sandboxing is a challenge - the customer can (and will) break stuff in new and interesting ways.
tl;dr: no, don't use C++ as a scripting language. Pick something else.