Which scripting language is better for embedding in multi-threaded C/C++ application [closed] Which scripting language is better for embedding in multi-threaded C/C++ application [closed] python python

Which scripting language is better for embedding in multi-threaded C/C++ application [closed]


Lua might be worth checking out. It can be used in a thread-safe manner, and the language supports a 'co-routine' concept which might fit your requirements.


Lua is the best choice. Python, Ruby and JavaScript are big languages and they are not designed for to embed. But Lua is different, designed to embed.

You should consider the "restriction" more than any other things for your script language. Embed scripts can use for hack (bad meaning) easily.

For example, by default Lua can not print to console. As I know, Blizzard uses the Lua because of that.


I've been in the same dilemma an choose Lua over Python and JScript. The thing which Lua does best is the great interop with C/C++ code using libraries like luabridge and luabind. That is, you can call lua from C++ and have the script call back into C++ without a problem, access c++ data from the script and vice versa.

The problem with languages like Python and Lua is that the language is not really multi-threaded in the regular sense of the word: if one C++ thread it using the language scripting engine to run a script, you cannot use the same engine to run another script. Both languages has an engine-wide lock which can be used in those cases to make sure the engine integrity is maintained. However, both languages are multi-threaded in the sense that you can run function in the background and interact with any synchronization object you want (just like from C++). So I choose to have all threads created from C++ and scripting code only run in a dedicated threads (thread per engine) and interact with other threads in the application in the regular ways.

If you need to pass data and control from C++ to a script and vice versa, Lua is much better than Python. Beside that, I would not host the CLR in a C++ project. It's too messy.