News for hackers. Stuff that matters.
Re:Love for LuaJIT by mbrubeck on Wednesday January 20, 2010 @06:41PM (#1066118)
Ruby might just need a better implementation with more time spent on optimization. http://maglev.gemstone.com/ is going in this direction.

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.]

Re:Love for LuaJIT by haberman on Wednesday January 20, 2010 @07:55PM (#1066300)
Also, Ruby has much more complicated rules for method dispatch. Lua just has functions, and if you want to implement any more complicated dispatch, you have to do it yourself. Once I implemented Ruby-like dispatch on top of Lua, and it was terribly slow:

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.

Re:Love for LuaJIT by dchest on Wednesday January 20, 2010 @06:56PM (#1066163)
Also, "The Evolution of Lua" — an interesting paper that shows how they came to this fast and somewhat elegant language: http://citeseerx.ist.psu.edu/viewdoc/download?doi=10.1.1.72.... [PDF]
Re:Love for LuaJIT by silentbicycle on Wednesday January 20, 2010 @07:07PM (#1066192)
Also good: "The Implementation of Lua 5.0" (http://www.tecgraf.puc-rio.br/~lhf/ftp/doc/sblp2005.pdf).

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.

Re:Love for LuaJIT by ambulatorybird on Wednesday January 20, 2010 @08:22PM (#1066344)
Just chiming in as another Lua fan; I really like it because it's like the Scheme of imperative scripting languages. And while we're passing around links to papers, I've found the following the be good for additional insight:

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...)

Re:Love for LuaJIT by yread on Thursday January 21, 2010 @01:57AM (#1066793)
Agree. If you want to learn more about Lua+C check out sources of this awesome game: http://springrts.com/
Re:Love for LuaJIT by stcredzero on Saturday January 23, 2010 @02:33AM (#1071521)
Ruby might just need a better implementation with more time spent on optimization...But also, Lua was always designed with cleanness and simplicity of implementation in mind

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.

Re:Love for LuaJIT by derefr on Wednesday January 20, 2010 @07:13PM (#1066202)
It'd be interesting to see how fast Ruby would run "cached" (i.e. with the AST already assembled in memory,) to see how much of the time is really spent in the parsing and lexing phases.
Re:Love for LuaJIT by mbrubeck on Wednesday January 20, 2010 @07:20PM (#1066219)
Note that I'm not claiming Ruby's parser and lexer are slow, or that they're the cause of any greater problems. I'm just picking on them as one example of deeper differences between the Ruby and Lua designs/implementations.