Question

I have a newbie question regarding Lua.

If I embed some Lua script inside my C++ application. When I compile my C++ application, will the Lua script part be compiled into machine code or does C++ application runs the Lua script part each time with Lua interpreter?

The web is saying using LuaJIT will improve embedded script performance greatly, then I guess the Lua script inside C++ application is never compiled into machine code.

If I would like to squeeze every bit of performance in this kind of situation, i.e, I would like to write part of my program in Lua to be embedded in a C++ application. What is my best option? Is there something I can used to compile Lua part into C++/C part and will this improve performance?

Was it helpful?

Solution

The entire point of a JIT compiler is to generate machine code at runtime from the source files.

LuaJIT will look for 'hotspots' in your code that run frequently (such as inner loops or frequently used functions), and try to compile them to machine code. It doesn't matter where the code came from; after loading, that is completely irrelevant.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top