Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

Playing devils advocate here, Lua does indeed have some warts that make it less pleasant to use in a heterogenous environment (which pretty much all large code-bases are). Not so much due to deficiencies in Lua but due to the impedance-mismatch versus other languages.

The most obvious issue that everyone stumbles across is the "counting from 1". It seems like a minor thing, but the context-switch remains a drag when you're dealing with complex data-structures in two languages and only one of them is Lua.

The impedance-mismatch becomes even more apparent when the table-abstraction meets serialization. The lack of distinction between an "array" and a "hash" is awesome when you're in a pure Lua-environment, but it becomes a real problem when you need to exchange data with languages that do depend on this distinction (e.g. if you feed Lua an empty "array" it will later serialize it back to an empty "hash").

The final issue that I can't resist mentioning here is not a language but a community/mindset one. Up to this day Lua doesn't have an established package manager akin to RubyGems, Pip, Maven, Leiningen etc. (Luarocks exists but is... well, I've yet to see someone actually using it)

This is a deadly sin in terms of mainstream adoption. It makes deployment a serious pain in the ass.

GoLang shows how a modern language is supposed to handle this (importing/bundling packages directly from urls). I keep hoping someone will add something similar to lua-core, but I'm sadly not very optimistic about it.

I think many of the driving people behind Lua just don't care about it becoming a mainstream language or not. They care about it shining as an embedded language (and it does!) - it's just a little bitter for those of us who would love to use it on a broader scope.



You raise some good points; I understand you're playing the devil's advocate but I thought a few would benefit from a friendly counter :)

> ... everyone stumbles across is the "counting from 1" ...

Fair enough :) I find this objection to be largely a matter of taste; it was never an issue for me [added in edit: even when interoperating with C and JS code]. People have made similar complaints about Matlab that I never found persuasive (there are other more persuasive criticisms of Matlab's language design). I think the core argument I'd make here is that if you're using Lua tables in a way that requires array-offset semantics for the index variable, you could probably step up a level of abstraction using ipairs/pairs and save yourself worrying about 1 vs 0.

> The impedance-mismatch becomes even more apparent when the table-abstraction meets serialization.

Lua tables naturally serialize to Lua table syntax (modulo cycles). This is in fact Lua's origin story (if Lua were a spiderman comic, it would be a story of a table description language being bitten by a radioactive register-based VM). At a technical level, how are Lua table literals any less successful a serialization format than JSON (i.e. JS object literals)? To put it another way: JSON doesn't map naturally to XML; should we then conclude that it has an impedance mismatch with respect to serialization?

> doesn't have an established package manager ...

<old guy hat> The idea that a language should have a package manager has always seemed... confusing... to me. C doesn't have a package manager; people still seem to be able to get the relevant packages when they need them through the OS's package manager. That, to me, seems the sane solution. I realize I may be in the minority. </old guy hat>

Having said that I agree that LuaRocks' comparative weakness relative to Ruby's gems limits adoption in mainstream programming applications. OTOH, it is vastly easier to get started embedding Lua in a host program than any of its competitors (this is in fact what drove me to try it in the first place). So it's not all friction on the deployment story.

> ... many of the driving people behind Lua just don't care about it becoming a mainstream language or not.

Yes, I think this is likely true. I don't think any of the core contributors care about it being "the next Python/Ruby/Perl". If I had to summarize the emergent aesthetic, it's that Lua is designed to be a just a language with a large set of DIY practices around it, rather than a curated software ecosystem.


> C doesn't have a package manager; people still seem to be able to get the relevant packages when they need them through the OS's package manager.

This is fine with Linux, which has at least a few sane package management systems between the different distros. This goes out the window with OS X and Windows.

(This may just be an argument that anyone working on server-side software should be working inside a VM that matches your production environment. The Ruby community seems to have shown that people push back very hard on that.)


In the particular case of Nginx and Lua, the OpenResty package[1] is pretty much self contained except for libpcre.

Nginx+Lua is only the core part that powers this ecosystem. OpenResty comes with a lot of libraries for "usual web stuff", except maybe a default template system. I've been using this rather simple one [2]

In the full example[3], I installed it on Mac OS (and actually found a small problem with homebrew that should be fixed soon)

[1] http://openresty.org/#Download [2] http://code.google.com/p/slt/ [3] https://github.com/mtourne/nginx_log_by_lua/


The idea that a language should have a package manager has always seemed... confusing... to me.

Yes, it's seems less than ideal, but in practice it has proven to be a significant advantage (not only) in cross-platform deployments.

The C toolchain has the benefits of being a compiled language (dynamic linking) and ubiquity (autoconf is a mess but sort of works pretty much everywhere). No other language has that, you can not even rely on a recent version of your runtime being available on a given platform. And things get really hairy when you need multiple different versions on the same host.

The rubygems+rbenv approach just works really well, almost independently of the platform that you're dealing with. And once you become used to deployment being this easy your tolerance versus languages lacking this convenience declines rapidly.


> The most obvious issue that everyone stumbles across is the "counting from 1". It seems like a minor thing, but the context-switch remains a drag when you're dealing with complex data-structures in two languages and only one of them is Lua.

Not so much of a problem for me, because I found out I rarely need to use array indices on the same structure in two different languages.

> The impedance-mismatch becomes even more apparent when the table-abstraction meets serialization.

I don't know if you read the Lua mailing list but I have posted about that recently (http://lua-users.org/lists/lua-l/2012-11/msg00683.html) and gotten a reasonable answer (http://lua-users.org/lists/lua-l/2012-11/msg00691.html). I still think separate types for lists and maps (arrays and hashes) are good but the proposed solution is elegant (and a good example of loose coupling: you teach libraries your convention and not the other way around).

> Luarocks exists but is... well, I've yet to see someone actually using it

I can assure you the part of the community using Lua as a standalone language uses it. Embedded users don't really need a package manager anyway.

Things are moving on that front too: the Moonrocks project could become what Rubygems is to Ruby (http://rocks.moonscript.org/).




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: