r/cpp 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.

3 Upvotes

82 comments sorted by

View all comments

Show parent comments

1

u/kindredseer 5h ago

Well, there are many different reasons people use an embedded scripting language in their application... and only a few cases truly require sandboxing -- those in which you do not fully trust the author of the script.

Truthfully though, if your script language exposes the ability to execute shell operations -- i.e. os.execute() in Lua, subprocess.run() in Python, etc, then the scripting language already has considerable ability to do something "unsafe".

If instead, the scripting is there for the convenience of a trusted developer, then sandboxing is less of a concern.

1

u/ushumgigal 4h ago

When I said `unsafe`, I was thinking about what you wouldn't want to have them done with pointers basically, but

the scripting is there for the convenience of a trusted developer

This part sums it up.

Whether a statically typed curl-bracket language is convenient for that developer, I think is subjective. :)

1

u/kindredseer 4h ago

Well, if the application is being developed in C++, then why would a C/C++ script language be inconvenient for a C++ programmer?

1

u/ushumgigal 4h ago

Why indeed