Hacker News new | ask | show | jobs
by spc476 3340 days ago
Batteries are not included in Lua. To do most anything interesting requires third party libraries (like directory manipulations, network, etc).
4 comments

Not just that, but Lua is very conservative about adding new language features so a lot of quality of life things are missing - no ternary operator, verbose lambda syntax, the incoherent mixing of arrays and dictionaries, bad default scoping, stuff like that.
If you are willing to fork Lua (and it's been done---one example is Ravi, which brings static typing) you can fix the verbose lambda syntax (http://lua-users.org/lists/lua-l/2017-04/msg00387.html) and add ternary operators (which I haven't missed). I haven't found the mixing of arrays and dictionaries that bad in practice (and I do a lot of Lua programming at work) and the default scoping ... yeah, I can see that (I've learned to deal).
I had a fork a long time ago solely to allow the use of "?" in function-names. Writing:

    function alive?
       ... blah
    end
Is so much more natural, after being exposed to ruby. But maintaining forks is hard, so I've slowly gotten use to the standard.

It's a shame that the development is so conservative, and closed, but despite that it is a great language to play with.

    A function that tests for something involving its arguments
    is called a predicate and usually ends in p or -p.
http://www.cliki.net/Naming+conventions
>"incoherent mixing of arrays and dictionaries"

Incoherent? 10 years of Lua development, never had a problem with it. In fact, the ability to use a table as either an array or a dictionary is one of the great features of the language. Most newbie Lua coders get over the differences pretty fast. For everyone else, there is lua-enumerable.lua ...

https://github.com/mikelovesrobots/lua-enumerable

Well, 10 years isn't the problem, it's picking it up in the first place. For example, the whole pairs/ipairs thing falls out of that original weird decision.

I love Lua. It's embeddable, it's written with newbie-friendliness in mind... but I still think it has flaws that I wish we'd see fixed. To me, the biggest one missing is just some simple convenience stuff for higher-order-functions - like I said before, the lack of a ternary "inline if" which is super-handy for writing one-line lambdas, and the verbosity of its lambda syntax.

I dunno, I think that the distinction between pairs/ipairs is quite handy - there are times when you want to use an array, a list, a dictionary, a sparse array, a sorted array, and so on. Lua's tables are so flexible that it can be used in all of these cases quite handily - of course, the programmer has to pay attention to how he's using those tables, though. I think thats kind of a strength, but ymmmv ..
Yep. Lua's small (and removable) standard library makes it really great for embedding, not so great standalone.
But when you need batteries, you just install luarocks and move on with it.
It's not that libraries are not available, it's that they are not _standard_. Python has much healthier and more coherent community partially because everybody started out with same carefully chosen building blocks. With Lua you either build your own or bring in dependencies from libs and frameworks.

Regardless, I'm enjoying Lua more and more and it's becoming my go-to language for prototyping and exploring concepts. The code just flows more naturally than in other languages.

I think there is something else to this. Most highly productive Lua applications I've seen, been involved in, &etc., are bound to system-level libs/api's, etc. So the thing about Lua as a scripting language like Python, is that you can use it like that. But the major power of the language is when you apply it by glom'ing it into some bundle of C/C++ libraries that are, indeed, BYO-batteries...

Like, Lua is bring-your-own battery, true. For everything else, there's Penlight/luarocks, though.

Isn't it the same in many other languages? For a Ruby project, you usually have to use a dozen gems to get started. For a javascript project, it's at least two dozens of npm packages
But at the very least, you can open a socket without external modules in those languages.
It's comparable to mruby but better since you can install extensions w/o rebuilding your interpreter.
and how good is the ecosystem? honest question
It's much smaller community than Ruby or Rust... People are very friendly and most of learning content is freely accessible. Most of us use LuaJIT (at least on desktops) but many are worried about its future, as lead genius has stepped off and few other people can understand the internals of LuaJIT.

There's a very nice "package manager" for downloading and installing modules, called LuaRocks. On the other hand, lack of tooling is a big issue. ZeroBrane seems to be only decent IDE with debugging support.

There's ton of stuff in libraries and Lua extensions, you just have to be careful about what you are integrating. You might for example end up with two incompatible implementations of class system from two different libs.