5 ms·
Lua sometimes drives me nuts, but it's such a humble little language that you can't hate it for too long. There are alternatives I would have preferred, like th
by vor_ 14y ago
Lua sometimes drives me nuts, but it's such a humble little language that you can't hate it for too long. There are alternatives I would have preferred, like the Lua-inspired Squirrel (http://http://squirrel-lang.org http://http://squirrel-lang.org ), but Lua is the most well-known and is written in plain C, which is likely appealing to a BSD project. I'm interested to see if this gains any popularity and if the other BSDs show interest.
- StavrosK 14y agoHow does it drive you nuts?
- rwmj 14y agoArrays based on 1. The odd and slightly under-documented stack that you have to use when interfacing it with C. Global variable scope by default. Tables (.. are both good and bad). Not standard named operators like '=~' and ':'. Having said that, it's not a bad language. It has an excellent community, who really went to great lengths to help me writing the Lua libguestfs bindings. http://libguestfs.org/guestfs-lua.3.html http://libguestfs.org/guestfs-lua.3.html
- snogglethorpe 14y agoThe 1-based arrays are theoretically annoying (I'm a C guy), but in practice I find they simply aren't an issue, I guess due to the differences in typical programs for each language. "~=" is unusual (I too wish it used "!=") but other than that, Lua's pretty much like everybody else (":" doesn't really count because it's an operation that doesn't exist in most languages). "Global by default" can be annoying, but at least it's better than "local by default" like python etc. [As a programmer, who'd rather find bugs easily than save some typing, I think better than either would be "nothing by default, you gotta declare your variables", but that might not be popular for "dash off a quick script" usage; maybe make it configurable based on the load context or something?] But this: > The odd and slightly under-documented stack that you have to use when interfacing it with C ... seems almost bizarre. Lua's C interface is probably the most elegant and usable I've ever seen. A stack is the classic abstraction to use for this application, Lua's implementation is well-designed, and Lua's API documentation is both comprehensive and very well written.
- vor_ 14y agoIt's annoying building a class system by hand. I've got C functions I wrote to do it for me, but I wish I didn't have to. There are certain behaviors I dislike even more. One example is a historical quirk in which all non-nil or non-false expressions are true. This means inconsistent behavior like: while 0 do print("Loops forever") end while not 1 do print("Does nothing") end and: while 1 do print("Loops forever") end while not 0 do print("Does nothing") end I also don't like how undefined variables return nil. This can cause a host of subtle errors, including accidentally creating sparse arrays if you make a typo in a variable name, which will mess up the behavior of the length operator. The syntax, which is what most people complain about in Lua, really doesn't bother me. It's the sometimes unconventional behavior of the language and its minimal feature set.
- StavrosK 14y agoHmm, I understand how 0 can evaluate to true (it's non-nil, non-false), but how is "not 1" false too, if 1 is true?
- vor_ 14y agoThe only things that evaluate to false are nil and false, so applying the "not" operator to a true value (non-nil, non-false) will evaluate to false. Hence, "not 1" is false, as is "not 0".
- pasbesoin 14y agoYour link is borked. It should be http://squirrel-lang.org http://squirrel-lang.org P.S. No criticism meant. Just a friendly correction. :-)