lua-users home
lua-l archive

[Date Prev][Date Next][Thread Prev][Thread Next] [Date Index] [Thread Index]

2012/1/28 sergei karhof <>:
> Why isn't Lua more widely used?
> Granted, being a script language, Lua can only hope for a niche
> position, and can never become as popular as C or C++.
> However, why is Lua *so much* underrated, compared to Javascript, for
> instance? Could not Lua be used in browsers and do as much a good job
> as Javascript? I mentioned browsers, but my point is more general.

Lua cannot replace C or C++ for application where performances are
important. This is changing a little bit with LuaJIT2 but still we
cannot replace C/C++ in many cases. Using strong static typing C and
C++ can often generate code that is near-optimal for a given
architecture. The compilation is done only once and you can make sure
that the code is optimal. With a JIT you are always at the merci of
the JIT. In addition C/C++ are not garbage collected so you can often
optimize the memory allocation strategy and you can also allocate
objects on the stack. You can also optimize a lot of things tha with
Lua you cannot manage yourself.

Talking about browser, well this is a matter of standard. Javascript
is the standard scripting language supported by browser and it is also
a standard with ECMAScript. So even if JavaScript have many flaws it
still have a prominent position because you cannot choose the
scripting language that you prefer. Otherwise Javascript and Lua are
quite similar but I consider that Lua is just better because it does
have a clean design and does not have the flaws of Javascript. Still
you cannot choose because the standard is Javascript :-)

If we limit ourselves to the niche of stand-alone dynamic programming
language still Lua is much less used that Python and Ruby. I'm using
myself also Python at work for some tasks instead of Lua. The reason
to prefer Python to Lua is: the standard set of libraries are very
complete and of very good quality: you have many things already there
out of the box, you need just make sure that python itself is
installed. Python is also a richer programming language than Lua, so
often you can write compact elegant code where with Lua often you need
to be more verbose. For example in Python you have list
comprehensions, list generators, generator functions, a more complete
exception mechanisms. Of course this have a cost: Python is more
complex, it is slower and bigger. It is therefore more difficult to
have good JIT and it is difficult to embed because it is quite a big
beast. Lua chosen the simplicity instead of the number of features and
complexity. This have paid in the sense that Lua is lighter and more
easy to embed but the downside is that it does not have all the
elegant features of Python.