1

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?

1
  • It is compiled into machine code, just in time. Commented May 15, 2014 at 12:48

1 Answer 1

1

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.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.