r/cpp • • Sep 18 '26

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.

6 Upvotes

92 comments sorted by

View all comments

Show parent comment

2

u/cristi1990an ++ Sep 22 '26

Scripting is supposed to be fast (as in fast to write and deploy) and easy (fast learning curve and having easy to use libraries that already do the heavy lifting for you like parsing or OS stuff).

C++ is neither of this.

2

u/kindredseer Sep 22 '26

Again, if you are a C++ developer then there would be no learning curve. If you already are building an application in C++ which could benefit from “scripting”, then why not use C++ instead of a language you are less familiar with (Lua, Python, etc)? C++ already has a lot of libraries you are also using in your application and you’d be able to call C++ functions and methods and work with C++ objects, structs and data types without conversion.

4

u/cristi1990an ++ Sep 22 '26

Because it's genuinely faster and easier to learn the scripting language and implement the solution in it than to write it in C++. Not to mention to maintain it. If runtime performance is a factor, then yes, I'm putting in the effort to write it in C++, but that's the only case

4

u/[deleted] Sep 22 '26

[removed] — view removed comment

2

u/kindredseer Sep 22 '26

I wasn't implying that C/C++ devs only know C/C++ ... just that I would expect they would be more familiar and comfortable writing C/C++ code than Lua scripts.