News for hackers. Stuff that matters.
Re:Why isn't everyone using Lua? by martijn_himself on Thursday July 21, 2011 @11:24AM (#2789877)
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).
Re:Why isn't everyone using Lua? by andrewcooke on Thursday July 21, 2011 @11:31AM (#2789904)
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.
Re:Why isn't everyone using Lua? by cheald on Tuesday July 26, 2011 @08:31AM (#2807004)
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.