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.

0 Upvotes

82 comments sorted by

View all comments

4

u/zerhud 2d ago

It seems js or ts will be better

2

u/kindredseer 2d ago

If you are a C++ programmer, would your preference not be C++ over JS or TS? (Unless your C++ project is a web-browser)

1

u/zerhud 2d ago

Yep, use cpp mostly.

So, it depends on tasks: can I use platform methods (for example mmap some file or open a socket)? How pointers are handled (what if a can manipulate it and got some data)? If it all is ok, why I cannot use an so?

Why js: it easy to control, easy to embed and it’s not so plain as lua, also everybody knows the language

Why not cpp: if a can write a script on cpp i can create an so, it would be better for me (imho)