Luiz Henrique de Figueiredo has notified on the Lua mailing list that a paper in PDF format on the
implementation of Lua 5.0 is now available for downloading:
The Implementation of Lua 5.0 – Roberto Ierusalimschy, Luiz Henrique de Figueiredo, Waldemar Celes.
Reccommended to anyone interested in the internals of Lua.
Lua is a good example to lead on from yesterday’s bloat discussion of a clean and unbloated program.
The whole thing compiled in less than a minute to 108K interpreter and 73K bytecode compiler. It loads instantaneously with a memory usage of 860K (Windows).
I doubt this is because it was heavily optimised; just written well in the first place. The code is easy to read and there is a well-defined interface. It’s 100% re-entrant. Great.
Those are some impressive improvements in performance with the switch to a register-based VM from the stack-based one they had in previous versions. The first test (sum) was 2.28 times faster than Lua 4! Very cool.
Lua is a very nice language to embed in another C program. It is a great language for providing a configuration and extension language without having to reinvent everything yourself.
as someone said before, is the xandros file manager source available? From the screenshots it seems QT so unless they paid per dev license they should develop a gpl app shoudn’t they?
Lua is the scripting language for the Ion desktop. Desktops don’t come much more stripped down than Ion. Get some.
Lua’s license is like BSD license. So don’t count on Lua developers developing GPL applications.
lua is undoubtly well written, but the reason for being a <200k interpreter is also realted to lua providing little features (by choice).
Anyway, from a quick skim of the paper some things are not clear, i.e. how is the vm working at low level? Direct threading, TOS/register caching, peephole optimizations and so on.
“It’s 100% re-entrant. Great.”
Whats re-entrant mean?
Thanks.
The VM uses a simple switch-based loop. GCC-based direct threading (&&label + goto *) was tried, but the difference was negligible.
There is a sliding/overlapping register window for the current function that directly maps to stack positions (like CPUs with register windows, but without the spill/fill problems). There is no point in caching registers because 3-operand instructions rarely benefit from chaining. The L1 cache works really well for the registers/stack.
The compiler does a few obvious optimizations, but is not designed like a full-blown optimizing compiler. This is not really required for Lua, since the language operates at a different level and the VM is tuned towards the language.
You can write a few scripts and look at the output from luac -l -p xx.lua. You’ll hardly find anything to optimize, provided you wrote your script in a straightforward way (you may notice that dead code elimination is note done, but this does not affect performance).
If you want to know more about the VM, then please get the source (the download is less than 200K!) and study it. The core VM loop is in lvm.c, the call stack stuff is in ldo.c. You may need to get used to the language first, to understand all of it, though.
Advance notice: Lua 5.1 is in the making. Prerelease versions are available. The most important new feature will be an incremental+generational garbage collector, a new module system and enhanced portability (clean compile from 16 bit to 64 bit systems).
The online version of “Programming in Lua” (PIL) can be reached from http://www.lua.org/ . Have a look at http://www.lua-users.org for the mailing list archive and the Wiki, too.
Lua is also the UI scripting language for the MMORPG World of Warcraft.
If facts, Lua is used in a number of games. Look here for an extensive list of projects (not only games) that make use of Lua:
http://www.lua.org/uses.html
Bye!
Lua’s license is like BSD license. So don’t count on Lua developers developing GPL applications.
That’s not a problem; BSD-style licenses (without the old advertising clause) is compatible with the GPL.
http://www.fsf.org/licensing/licenses/license-list.html#GPLCompatib…
lua.org asserts that their license is GPL-compatible, and it looks to me like they’re right (as of 5.0, anyway; they used a different license before).