Live data from Hacker News

Why Lua?

blog.datamules.com

21–30 of 142 posts

Re: Why Lua?

#21
post #5

The article seemed a little short for me, but then I am actively trying to select between Lua and TCL for some personal scripting projects. There are many fine features with each language and few downsides, so the selection process is hard. Of course, that's a nice problem to have. TCL is ahead by a nose at this point with Unicode support baked in (vs. using a library) and file system handling built in (again vs. usi…

Tcl is an interesting little language as well, and the niche it was created for is similar to the one Lua was created for. The biggest advantages that Lua has over Tcl, off the top of my head, are speed and lambdas. Tcl's semantics make it very hard to optimize because it is stringly typed (with some bytecode and value specialization in the background, but with conversions between strings and other values as needed).…

Tcl has lambdas (anonymous functions): http://wiki.tcl.tk/4884. As of 8.6 (currently in beta), it also has coroutines, and has a non-recursive engine (stackless) among other niceties.

Re: Why Lua?

#22
post #8

In lua, the metatable is the killer feature that python doesn't have.

Could you explain what you can accomplish with Lua metatables that you can't do with python __eg__ methods? I've only seen them used as a way to implement operator overloading.

Re: Why Lua?

#23
post #16

The worst problem with Lua is that arrays start at 1. That is way too bad for me to use it. I only use it to configure Awesome WM, but it sucks for everything else IMO because of "tables" starting at 1.

I've done a lot of work in Lua and haven't really found it to be an issue. As long as you stick to doing things the "lua way" (i.e. pairs / ipairs), the specific indexes matter very little. Every once in a while I'll have an, "oh yah," moment where I use the wrong index and something doesn't work, but I don't see how it's a deal breaker for anyone.

There are many features of Lua that have caused me more problems (the somewhat inconsistent string conversion, for instance).

Re: Why Lua?

#25

Speed& Simplicity LuaJIT speeds can rival code written in C. And if you are still not getting the speed you want, see my 1st point above (Integration with C and C++ for that matter). The simplicity of Lua is, I think, really underrated. It is a good learning exercise to write some small benchmark / utility / tool in Lua so you can get an idea of how quickly you can develop, and how fast the resulting code will be. Th…

The simplicity of any code is really underrated. Like 4 orders of magnitude underrated: http://www.vpri.org/html/work/ifnct.htm (Long story short: a typical mainstream desktop weights more than 200 millions lines of code. The guys at the Viewpoint Research Institute can simplify it down to 20.000 lines.)

Re: Why Lua?

#26

To echo chubot: Why isn't Lua more widely used? * It lacks an easy-to-use symbolic debugger. * It lacks a first-rate IDE. * It lacks a standard way for people coming from OO/Java to define objects and interfaces. * It lacks a GUI toolkit. * It has a great set of manuals. It lacks an O'Reilly book with a woodcut animal on the cover. * Arrays indexes start at 1. Except for the last item, these are all relatively small…

I also think that Lua has a perception of being an embedded-only language (which it's very good at). The biggest code bases are World of Warcraft interface modifications and other plugin architectures. The features Lua would need to be really competitive as a stand-alone language (ex: good library management[1]) are still developing. I think it has the potential to be very powerful, though.

If you want to have some fun with Lua, check out LÖVE[2].

[1] http://lua-users.org/wiki/LuaModuleFunctionCritiqued [2] https://love2d.org/

Re: Why Lua?

#27

Earlier quoted context omitted.

> add unicode support This won't happen soon. Lua targets ANSI C and only ANSI C. C11 includes new character types to support unicode, but I imagine that the Lua implementers will take their time. Plus there's implications for embedded situations. If you need unicode (and most do), there are libraries and patches that do a reasonable job.

I'm fine with C-style strings, but once in a while there are things for which a bit of UTF-8 tagging would be good enough.

Lua strings aren't C-style: they're prefixed with the string length. Lua's strings are suitable enough to store UTF-8 encoded data, but none of Lua's built-in functions are equipped to process it. Unicode libraries don't need to provide a special Unicode string type, they simply need to provide Unicode-aware string processing functions.

Re: Why Lua?

#28
post #8

In lua, the metatable is the killer feature that python doesn't have.

Could you explain what you can accomplish with Lua metatables that you can't do with python __eg__ methods? I've only seen them used as a way to implement operator overloading.

Roll-your-own prototypical inheritance. I also vaguely recall rolling my own approximation to class inheritance long ago.

Re: Why Lua?

#29
post #9

lua (the language and core libraries) is stable and small. many developers are attracted to node.js or rails due to the community ("look, everyone else is doing it!"), ecosystem (abundance of modules/gems to choose from), and rapid release cycles. lua seems to have more of a relaxed, niche community among game developers and scripting language embedders. i've been using lua for about a week so far, for a music player…

There are several server side Lua options with coroutines.

Could you name a few, alls I see are kepler based ones..

Re: Why Lua?

#30

To echo chubot: Why isn't Lua more widely used? * It lacks an easy-to-use symbolic debugger. * It lacks a first-rate IDE. * It lacks a standard way for people coming from OO/Java to define objects and interfaces. * It lacks a GUI toolkit. * It has a great set of manuals. It lacks an O'Reilly book with a woodcut animal on the cover. * Arrays indexes start at 1. Except for the last item, these are all relatively small…

> * It lacks an easy-to-use symbolic debugger.

> * It lacks a first-rate IDE.

This is changing http://eclipse.org/koneki/ldt/;

> * Array indexes start at 1.

This sounds dangerously similar to "I can't use Python because it has significant whitespaces". Developers might like or dislike it, but if you can't get over _that_, you either lack important cognitive abilities, or you're suffering from a very serious case of Asperger's/OCD. I can't imagine that someone seriously hampered by _that_ could ever digest any large API.

However, I'll admit it's a bit irritating when you're frantically switching between C and Lua.

> the Lua style seems to be to understate the achievements to the point that folks can't tell the big new stuff from the abandoned projects.

You're right, organizing the efforts of the Lua "community" would probably be trickier than herding cats, and the Lua core team doesn't seem very interested in helping that happen. I sometimes suspect that even Lispers form a tighter community than Lua hackers...

Post reply on HN