Love for LuaJIT
google-opensource.blogspot.com
google-opensource.blogspot.com
http://shootout.alioth.debian.org/u32q/which-programming-lan...
Mike Pall wrote LuaJIT and now LuaJIT 2 as essentially solo efforts. Thanks to Google and the other sponsors for helping him continue!
http://shootout.alioth.debian.org/u32/benchmark.php?test=all...
Edit: replaced "performs" with "compares", eliminating ambiguity around competitive performance vs clocktime performance
I haven't tried LuaJIT 2 yet, but I'm eagerly waiting for it to get ported to amd64.
And the port of the interpreter to x64 is already done, so it was certainly practical. Porting the rest of the VM and the JIT compiler is what takes most of the time.
Super fast desktop publishing FTW !
Interesting! Anyone know details?
Our Lua usage isn't too widespread at the moment; it's really one infrastructure project in particular that uses Lua to allow user-defined functions to run within a tightly controlled container. Lua was the best choice, because of its low overhead, fast execution, and the ability to set limits on execution time.
Unfortunately I cannot be more specific, since the project is not public.
This sort of makes me want to try to write a Python->Lua compiler.
I found this Sinatra clone for Lua called Mercury (http://github.com/nrk/mercury), but it lacks documentation and does not seem to be very mature at the moment.
I was excited when I heard that mod_lua was going to be included with Apache by default [1] ... but I haven't really heard anything since then.
But also, Lua was always designed with cleanness and simplicity of implementation in mind. Its developers have strong backgrounds in both theory and engineering, which you can see in their interview in the book Masterminds of Programming. They've been very conservative about the design of the language. In contrast, Ruby feels much messier and more "evolved" - look at its Yacc grammar[1], for example, compared to the grammar of JavaScript or Lua[2]. Even the Ruby lexer is full of weird edge cases. Much of MRI is like that, and for years it was the only "spec" for the language; now its decisions have been reverse-engineered and inherited by all other implementations.
[1]: http://blog.nicksieger.com/articles/2006/10/27/visualization...
[2]: http://www.lua.org/manual/5.1/manual.html#8
[By the way, I've used Ruby for years and like it at lot, while I've written only a few lines of Lua code and like it but am not deeply familiar with it.]
http://blog.reverberate.org/2009/02/09/disappointment/
To make a long story short, porting my existing Lua project to use my Ruby-like method dispatch resulted in a 4x slowdown.
Past discussion: http://news.ycombinator.com/item?id=617278
If you want to learn Lua, Ierusalimschy's _Programming in Lua_ (http://www.inf.puc-rio.br/~roberto/pil2/) is by far the best book. Lua is one of my favorite languages. While it's good on its own, you'll get a lot more out of it if you're comfortable with C. Lua+C is an excellent combination.
Lua Performance Tips: (http://www.lua.org/gems/sample.pdf)
A No-Frills Introduction to Lua 5.1 VM Instructions: (http://luaforge.net/docman/view.php/83/98/ANoFrillsIntroToLu...)
Ease of implementation has a multiplier effect with Open development effort. Not only do you get more of "more eyeballs," new contributors can ramp up faster. There tends to be a better effort/ fun ratio.
Even the Ruby lexer is full of weird edge cases.
Actually, the lexer sets state that changes the operation of the parser and vice versa.
So, yes, language design does impact performance.
Any examples in particular? Besides name resolution and method dispatch (and callcc, but I think that may have even been removed from Ruby 1.9) none of Ruby's semantics seem all that different from Lua. Am I missing something?
I guess there's also throw/catch and exceptions.
http://blog.headius.com/2009/04/how-jruby-makes-ruby-fast.ht...
Read it, you will find it interesting. The guy also wrote a small language called Duby which used Ruby like syntax but is much more faster, because he didn't include any of those slowing down features.
The Rubyists certainly know about these issues, so you'll have to ask them for details.
Dispatch is worse than you realize due to the hackish optimizations made in MRI: if you monkeypatch a natively-method from Ruby, other native code will call the original by default.
MRI's garbage collector is abysmal, use Phusion's REE fork to get one that at least doesn't mark every single object on every collection and actually bothers to perform them in normal situations. It didn't do any desugaring at all until 1.9, and YARV only has bytecodes for the most primitive accessors, assignments, stackops, jump/condjump, and returns; with optimizations for -, +, <. <<, and some regexes. Your normal code just gets passed through verbatim.
Every once in a while I'll be reading docs or sitting in irb and suddenly scream at the ceiling, spin in my chair, and get the urge to throttle a Japanese person.
I haven't looked at LuaJIT yet but considering how small it is I'm sure it meets or exceeds the quality of the code behind Lua.
Standard Lua (the one from PUC-Rio) doesn't really, it uses boxed numeric values, as I imagine ruby (and almost every other dynamic language) does as well. "Boxed" meaning that each number is stored on the heap with some kind of tag, and when you pass such a value to a function you're really passing a pointer to it and that indirection costs cycles and puts pressure on the cache. LuaJIT's most significant (IMO) feature is that it stores numeric values directly, like C does, so when you call a function the actual bits representing it go right on the stack, not the address of where the bits can be found, and it uses some cool tricks of floating point representation to prevent the garbage collector from trying to follow these stack values as if they were pointers. This (combined with the trace optimization) is why when you write a numeric for-loop in LuaJIT it runs (nearly?) as fast a C.
LuaJIT 2's NaN tagging alone does not speed up the stock interpreter: http://article.gmane.org/gmane.comp.lang.lua.general/44823.
Of course, the fact that it's tied to the Objective-C runtime means it's not portable as-is, but at least it's a proof that Ruby need not be slow.