Why is LuaJIT so good?

LuaJitLuajit

Lua Problem Overview


EDIT: unfortunately LuaJIT was taken out of the comparison in the link below.

This http://shootout.alioth.debian.org/u64/which-programming-languages-are-fastest.php">comparison</a> of programming languages shows that LuaJIT has an over tenfold improvement over the normal Lua implementation. Why is the change so big? Is there something specific about Lua that makes it benefit a lot from JIT compilation? Python is dynamically typed and compiled to bytecode as well, so why doesn't PyPy (that has JIT now, I believe) show such a large jump in performance?

Lua Solutions


Solution 1 - Lua

Mike Pall has talked about this in a few places:

As with every performant system, the answer in the end comes down to two things: algorithms and engineering. LuaJIT uses advanced compilation techniques, and it also has a very finely engineered implementation. For example, when the fancy compilation techniques can't handle a piece of code, LuaJIT falls back to an very fast interpreter written in x86 assembly.

LuaJIT gets double points on the engineering aspect, because not only is LuaJIT itself well-engineered, but the Lua language itself has a simpler and more coherent design than Python and JavaScript. This makes it (marginally) easier for an implementation to provide consistently good performance.

Attributions

All content for this solution is sourced from the original question on Stackoverflow.

The content on this page is licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Content TypeOriginal AuthorOriginal Content on Stackoverflow
QuestionMihaiView Question on Stackoverflow
Solution 1 - LuaBen KarelView Answer on Stackoverflow