开发者

Why is LuaJIT so good?

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

This comparison 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 Py开发者_StackOverflow社区Py (that has JIT now, I believe) show such a large jump in performance?


Mike Pall has talked about this in a few places:

  • http://article.gmane.org/gmane.comp.lang.lua.general/58908
  • http://lambda-the-ultimate.org/node/3851
  • http://www.reddit.com/user/mikemike

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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜