Its main downside is that the language changes in backward-compatible ways between releases. And worse, LuaJIT has in some sense forked the language. Lua 5.3 introduced integer support, but there are no plans to add this to LuaJIT AFAIK.
And Wikipedia (Wikimedia) uses Lua for their multimedia scripting engine. Besides good performance, the implementation was good and small enough that it could be audited for security.
Isn't this what most scripting languages do? I know it's the case with Python and PHP.
And I disagree about the 1-based array indexing. With algorithms that require a lot of 1-off values, it can be a huge pain in the ass, particularly if you're trying to integrate it with C (and its 0-based array indexing). Still not sure why the creators chose it, given that Lua was designed for easy and close C interop.
>>> def f(a):
... pass
...
>>> f()
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
TypeError: f() takes exactly 1 argument (0 given)
>>>
I agree 1-based indexing isn't ideal, but in the grand scheme of things, the default nils and the method/function syntax are a constant source of mistakes and frustration for me. In Lua you have to call `obj:method()` which to pass `obj` as the first argument. If you accidentally do `obj.method()` - there is no error, but the first argument becomes `nil`.In Python, there the call syntax is consistent and `obj` is automatically passed as the first argument for methods.
s/first/last/, the arguments will be shifted to the right. But yes, it can be annoying.
http://www.inf.puc-rio.br/%7Eroberto/talks/ws2011.pdf
Excerpt:
- Not all languages are 0-based: Icon, Fortran, AWK1, and Smalltalk are 1-based; Snobol, Pascal, Modula, Modula-32, and Ada have configurable bases.
- Currently, many languages are 0-based due to influence from C.
- Ironically, none of them share the reason that made C 0-based (where a[e] means *(a+e)).
1-based arrays:
- Much more intuitive: first is 1st (not 0th). ISO-C: “E1[E2] designates the E2-th element of E1 (counting from zero).”
- Much easier for non programmers. Easy for (good) programmers :)
- Historical reason: Fortran used 1-based arrays, and most first users of Lua had a Fortran background.
This is false for Python:
>> print bla
NameError: name 'bla' is not defined
In Lua:
> = bla
nil
setmetatable(_G or _ENV, {__index = error})
-- `error` for the example, you can write a function that prints a better error message.A few years(?) later at GDC, there was a 2 hour session to discuss scripting in games. Near the end, after everybody was depressed with no viable solutions, Bret's colleague exclaimed, "Or you can do what Bret did" and he was dragged up on stage. Bret gave an impromptu spiel about what Lua was and how they used it at LucasArts. Everybody else frantically scribbled down notes and that was how the video game industry adopted Lua as the dominant game scripting language.
*Source: Bret Mogilefsky's talk at the very first Lua Workshop in 2005