Live data from Hacker News

Why nobody talks about Lua

goplexian.com

61–70 of 78 posts

Re: Why nobody talks about Lua

#61
post #2

It seem to me that Lua usage reside primary in the game industry. People who works in the game industry and people who works in web technologies rarely collide with each other.

Lua shines at interfacing with C; it's useful when you've got a high-performance engine in C or C++, and want a friendly programming interface to control it.

That's obviously the case for games and their 3D / physics engines, but Lua is steadily gaining momentum in the embedded devices world, where CPUs are also pushed to the limits of their (lesser) capabilities.

Web developers have already put most of their high performance wizardry in their SQL engines, and already have standardized/comprehensive APIs to these databases; I don't think Lua would bring them much, and certainly not enough to compensate for the loss of Python's or Ruby's existing web-friendly libraries.

Re: Why nobody talks about Lua

#62
Every once in a while, I used to think, "What about Lua? Wouldn't Lua be nice?" Then I would start reading the docs, and stop when I came to the "local" keyword. Ick. Variables are global by default, you have to explicitly label local bindings. If any scope is the default, it should be local scope. Accessing an uninitialized variable is also not an error. Chalk this up to personal taste, but this reminds me too much of bad experiences in bash scripting. The languages I prefer: Python, Haskell, C, Scheme, Common Lisp... never play so fast and loose with where your variables go.

Re: Why nobody talks about Lua

#63

Every once in a while, I used to think, "What about Lua? Wouldn't Lua be nice?" Then I would start reading the docs, and stop when I came to the "local" keyword. Ick. Variables are global by default, you have to explicitly label local bindings. If any scope is the default, it should be local scope. Accessing an uninitialized variable is also not an error. Chalk this up to personal taste, but this reminds me too much…

I agree. Variables being global by default (without the var keyword) has been the source of countless bugs in JavaScript.

Re: Why nobody talks about Lua

#64
post #9

Because the arrays start at 1.

Dude, you can find a reason to write off every language in existence. Lisp has all those parens. Python has the whitespace. Perl...is Perl. Etc. Nothing's perfect. Lua's a pretty good language, though. It's completely replaced Python as my default language (much like Python replaced Perl years before), because, while it too has its surface annoyances, it makes a lot of other very intelligent trade-offs. For example,…

+1 for pbLua. I've used it for a few things and it's brilliant. Docs are pretty good too.

Protip: Having kids is a great way to legitimise buying things like Mindstorms. eg, without kids - "I just spent $300 on Lego" "Wow, what a sad life you lead". with kids - "I just spent $300 on Lego" "Wow! What an awesome parent you are. My Dad never did anything like that for me"

Re: Why nobody talks about Lua

#65
post #55

Earlier quoted context omitted.

Why not `sudo apt-get install lua5.1`? 5.0 is rather old.

Thanks, apt-get suggested lua40 and lua50 when I tried plain lua; I've got 5.1 now.

The biggest difference between lua4 and lua5 is that lua4 doesn't really have a module system, per se. 5.1 also has a better garbage collector. LuaJIT (which is based on Lua 5.1) is also an option, if you're on 32-bit i386.

For learning Lua, Ierusalimschy's _Programming in Lua_ is the best book, by leaps and bounds. There are a couple other Lua books, but that one is succinct yet comprehensive, like K&R and Pike's Bell Labs stuff.

The Lua Users' Wiki (http://lua-users.org/wiki/) is also helpful, as is the mailing list.

Re: Why nobody talks about Lua

#66

Every once in a while, I used to think, "What about Lua? Wouldn't Lua be nice?" Then I would start reading the docs, and stop when I came to the "local" keyword. Ick. Variables are global by default, you have to explicitly label local bindings. If any scope is the default, it should be local scope. Accessing an uninitialized variable is also not an error. Chalk this up to personal taste, but this reminds me too much…

While you're right that "global by default" is usually a problem, it isn't in Lua, because Lua also lets you restrict the global scope (with i.e. setfenv). Generally, the "global" scope you get by default is "global to the current module", i.e., publicly exported from a module.

It's still not a problem if your whole program is in one file, though. Since the global environment is just another table, you can set its metamethods to warn about any accidentally global vars. This is an example in PiL, and strict.lua is included in the standard Lua distribution. require "strict", problem solved.

The Lua designers know that unrestricted global-by-default vars cause a lot of pain in Awk, but defaulting to local scope for everything instead can make using closures awkward (as in Python), since it's difficult to know automatically where variables are local to. In the other languages you mention, C doesn't have proper lexical scoping, Scheme and Common Lisp have fully parenthesized syntax (and thus no scoping ambiguity), Python's closures are awkward, and Haskell (and ML) use let blocks and other explicit scope markers. This is a semantic issue in any language where you can nest blocks and the default is a series of statements, not individual statements (i.e., "begin" / "progn" is the default).

See also: http://lua-users.org/wiki/LocalByDefault

Re: Why nobody talks about Lua

#67
post #42

Earlier quoted context omitted.

>Lua still doesn't really satisfy as a "batteries-included" platform. This is exactly the problem, imo. Lua is a niche language because its benefits only apply to a certain niche, i.e., scripting glue on top of an extant system, because that's where the time investment makes sense. Is Lua so much better that using it is worth losing the convenience of something like Rails or Django? Those things come all bundled up n…

you need to realize lua isnt targeted as a batteries included platform, its design philosophy is minimalist, not junk included but customize for your requirements. where lua absolutely excels is when paired with C (not C++) and not used as "scripting glue" but fully integrated and driving the system. it really appeals to minimalistic / keep it simple philosophy guys which isnt the web community. lua is not a one stop…

What is the best example of this combo ?

Also, the idea reminds me of this: http://c2.com/cgi/wiki/wiki?AlternateHardAndSoftLayers

Re: Why nobody talks about Lua

#69

Earlier quoted context omitted.

I think the explosion of node.js is actually evidence of what you're saying; the web guys who were scared of the server are taking their javascript skills there via node.js. Perhaps it could happen when a generation of iPhone developers who have written games in Lua decide they want to do some server side development. I have less hope that Lua will take off though. Appropriately, I'm giving a talk on Lua/Erlang integ…

I am still waiting for node.js for windows.

FWIW, I'm working on something similar in Lua, which uses libevent for high performance on Unix but also has a pure Lua (based on LuaSocket.select) backend for portability. I haven't tested it on Windows yet, but I don't expect any issues with running it there, and I'm planning on supporting it as a platform (for developing convenience, not performance).

It's reasonably complete, but its development is being driven by another project (a distributed filesystem of sorts), and it's still changing too much. I hope to have it released in a month or two, but I'm also in the process of buying a house, and that's keeping me plenty busy.

If you're interested, learning Lua should would be pretty straightforward. It sounds like you're already proficient in Javascript, and they have quite a bit in common.

Re: Why nobody talks about Lua

#70
post #24

I have trouble finding a use for Lua, even though I like it better as a language than most. The problem is that it isn't a good "starting place" for an app. Instead you write something in C/C++ and say "oh, I wish I had a dynamic language for this part" and then you add Lua on top. And this is part of why Lua is such a compelling language now - by being extension-focused it's been able to iterate the entire language…

While Lua doesn't have many batteries included, it is trivial to expose a C lib-whatever interface to Lua when needed (example - http://github.com/iamaleksey/lua-zmq/blob/master/zmq.c).

And there is a c/++ library for almost everything.

Post reply on HN