Why isn't everyone using Lua?

9 points by martijn_himself ↗ HN
I came across the Lua programming language and started reading the first edition of 'Programming in Lua', which is available for free online (http://www.lua.org/pil).

I am incredibly impressed by the conciseness of the language and its syntax and really like it (there are only a handful of types, the 'table' data structure can be used to easily create any complex data structure), it is fast and is designed to be called as a script from c, and c functions can be easily called from it. Intuitively it appeals to me even more than Python does.

Its adoption seems to suggest it is not widely used outside game programming? Why? What is wrong with you people? ;)

14 comments

[ 3.0 ms ] story [ 44.7 ms ] thread
Personally, I find the syntax horrible. A good few years ago, I wrote reasonably complex stuff in Lua (a game addon, you wouldn't have guessed, right? :P), and it was quite painful to do that.

It doesn't help that it's embedded into larger applications most of the time, which do not allow easy debugging, if at all.

That's really interesting. Obviously, I've only started reading the docs and have no real-world experience with the language. I hadn't even thought about debugging. Do you know an alternative language that you would prefer to use in that context? Do you think the reason for its popularity in game programming is because there is not really any alternative?
i don't see any great advantage that outweighs the cost of switching from python. the language is not that different, but i already know python, my co-workers know python, and python has more libraries and wider support.

i am not criticising lua in any way - from what i know of it, it is exemplary (there's a good paper on its implementation that i enjoyed). but languages don't succeed on intrinsic qualities alone.

I don't have a lot of experience with Python, is it as easy to call out from and into c code as with Lua? (I am now just guessing as to why a game programmer would choose Lua over Python).
lua is easier to embed, is smaller, and has better performance. it's also a slightly cleaner language (all other things being equal, i think it is slightly better than python: the handling of tables is more regular; it has better support for continuations; it has tco; and correct scoping). on the downside, the "maps as arrays" approach is a bit clumsy.
Lua tables are sort of two-headed beasts. They aren't like PHP's array construct, which is effectively always an ordered dict. In Lua, an ordered list and a dictionary are both expressed by the same type, but are effectively different types. You can even have both an ordered list, and a dictionary in the same table.

   foo = {1,2,3}
This is an ordered list. #foo -> 3

   foo = {foo = "bar", baz = "bin"}
This is a dictionary. #foo -> 0; the reason for this is that #foo (or more clearly, the length of foo) measures the length of the ordered list portion of a table. If you iterate an ordered list with ipairs(), you will only get the ordered list entries, even if you were to have dictionary data in the same table.

This is somewhat unintuitive in the context of other similar languages, but once you have a grasp of it, it makes a lot of sense, and is remarkably elegant.

I've always gotten the impression that Lua has a somewhat anemic standard library and a somewhat limited set of abstractions, in contrast to the things that draw me to Python – is this still accurate? Python, Ruby, etc. have a wide range of built-in functionality, which allows them to stand on their own, whereas Lua seems to be intended for use with C programs and libraries, keeping it in the game/scripting world. Are these assumptions still accurate? (Also, indexing from one is just frustrating when almost everything else is zero-based!)
That seems definitely accurate. From my limited experience it certainly seems Lua has the more minimalistic approach, although that must have been a conscious decision on the part of the authors. I like how built-in functions can be 'overriden' (more like replaced) to be made more restrictive to create a sandboxed environment. I agree I can't think of any good reason for the one-based indexing, it seems to be a bit of a gimmick :)
(comment deleted)
The Lua community has been historically more focused on embedded and scripting scenarios, and less on building a comprehensive platform for libraries and applications (compare the quality and availability of LuaRocks to PyPI, Ruby Gems, CPAN, etc.). That combined with the almost non-existent standard library means that not only does Lua not give you a solid base of code to build off of, it's hard to find a community-driven one as well. This leads to developers having to play mix-and-match to get a good base running. Also, the "table can be used to emulate any structure" piece means that every library and developer does OO and modules just a little bit differently, harming reuse across code bases.

There are a couple of syntax decisions (default globals, no ++ or --, indexes start at 1) that might cause negative reactions, but I'd put the lack of libraries and frameworks above that.

Lua is still awesome for simplicity, easy C binding, and performance, but deciding to build a new project in Lua requires a significant investment in just getting the base libraries put together.

Lua is a wonderful language. Small, terse, extremely powerful, easily embedded, and fast. I'm a huge fan of it.

It does suffer from the lack of a robust standard library, because it is intended to be embedded, where it should inherit the majority of its functionality from the host application. That said, when embedded in a rich host environment, it's a marvelous tool.

I just disagree with the 1-based indexing...