Hacker News new | ask | show | jobs
by tracker1 4839 days ago
Not sure exactly how duped this is for HN... For those that don't know.. Lua is a scripting language, perhaps a bit more structured than it's more popular counterparts (JavaScript and Python), having very good performance characteristics. It's very popular in terms of Game development.

Luvit is essentially a lua interpreter with bindings to libuv (the same core IO library used in NodeJS). And could mainly be considered an alternative to NodeJS, which it most closely resembles.

Some, who don't like JS syntax may wish to consider Luvit, as it will perform close to, and sometimes better than NodeJS, with some similar gotchas.

1 comments

> Lua is a scripting language, perhaps a bit more structured than it's more popular counterparts (JavaScript and Python)

I wouldn't say it has more structure than Python or JavaScript. Lua has only these types: number, string, boolean, table, function, nil, userdata and thread. Table acts as a hybrid between list and map, just like Array/Object in JavaScript. And users rarely are exposed directly to userdata/thread, that's more something you'd use when you write a library (use userdata to emulate classes etc). The Lua VM is also much simpler than the other two, it's a simple stack machine. There are no tuples like in python, no first-class support for classes.

Lua IS a register based machine. The white paper done by the Lua authors is the reason most of the industry has moved to register based machines. (Apple SquirrelFish for Safari was the first to read it and implement it and everybody followed suit to compete.) http://www.lua.org/doc/jucs05.pdf

Lua has true multiple return value support. The overall usefulness of tuples in light of this feature is not clear.

Lua has first class support for functions and actually supports functional programming unlike Python which cripples many techniques and where Javascript has broken lexical scoping. Lua uses metamethod programming to allow you to build functionality like classes; Javascript has prototype inheritance which is different than Python's classical inheritance. Each is just different; not necessarily more or less structured.

Also, never confuse simple for being primitive. Lua IS incredibly simple and elegant. But all the simple things in the language work together elegantly to allow for amazingly sophisticated things.

Lua has a register-based VM. You're probably thinking of Lua's C API, which is stack-based.

EDIT: Also, I just remembered that Lua started as a stack-based VM, but moved to register-based at around version 5. So you could be thinking of the old Lua, too.

I thought Lua used a register based VM.
No, it's a stack machine. See http://www.lua.org/manual/5.1/manual.html#3
You're both right. It has a stack that it uses for callframes and local variables, but the opcodes have operands to directly reference variables on it by index. In other words, it treats all of the stack for a given callframe as a set of registers.
The stack is an abstraction used in the C API. If you look at the actual bytecode generated, it's all register-based.