Lua was pretty much perfect at version 5.1 (the version LuaJIT supports). Lua is meant to be a simple language, not one of those languages which accumulate more and more features and thus complexity over time (I am looking at you C#, Java, etc.).
So unlike those languages Lua can really be considered "done". Version 5.2 was a lot like C99, maybe people considered one or two features "nice to have" but most Lua programmers saw no need to upgrade. Others like Mike Pall even considered 5.2 inferior to 5.1.
Now we have 5.3 which is really all about one special-purpose feature: 64 bit integers. That is a feature most Lua users do not need and it comes with a massive complexity and performance price tag.
Unless you really need 64 bit integer math in your scripts 5.3 is the inferior language.
I really enjoy that in classic Lua a number is a number, that is such a relief compared to the hell that is C's countless numeric types and all the potential bugs resulting from (silent) conversions between them. Lua 5.3 brought that problem to Lua e.g.
a = 9223372036854775000
b = 0.5
c = a + b
c = c - b
print(c) // 9.2233720368548e+18
The third line silently converts a 64-bit integer variable to a 64-bit floating point variable, corrupting its value.
And of course Lua 5.3 is slower and needs more memory because of the additional complexity which must be handled.
Thanks but no thanks.
I mean Lua 5.3 still makes sense if you really need 64-bit integers in your Lua scripts. But otherwise it is a downgrade.
I have little experience in lua myself, and I know only that lua is meant to be a simple language. That said, I can't see from your example what's wrong with lua5.3. I ran the same code with lua5.1, lua5.2, and lua5.3 – and the output was identical across all:
In Lua < 5.3
a = 9223372036854775000
is not even valid code. Because only 32-bit integer values are supported.
In Lua < 5.3 the value is immediately corrupted (check the value of 'a' after the initial assignment) and static analysis can detect that line as a bug.
In contrast in Lua 5.3 it is perfectly fine code and the value of 'a' will be 9223372036854775000 as one would expect. However the moment you - maybe accidentally - mix that int64 variable with a float64 variable in an expression you end up with a (silent) bug.
Such bugs will happen. They happen all the time in C and in Lua's case things are even worse because function parameters do not have types. The possibilities of hard to find, nasty bugs are endless here. E.g. simply forgetting the second '/' in '//' in one part of the program can cause bugs in a completely different part, maybe even in a third party module, and only under certain circumstances.
>That's not true at all, Lua < 5.3 uses doubles for all numbers
I know that of course, but using doubles for integer math is only safe if you limit yourself to a certain integer range.
>which on most computers is IEEE 754, they can represent integers perfectly up to 2^53
False. You get rounding errors after 10^14.
>The value is not corrupted, depending on the rounding mode is which number you're going to get out of that (I get 9223372036854774784)
The above being an example of such a rounding error.
If I assign the value 9223372036854775000 to a variable I expect said variable to afterwards have the value 9223372036854775000 not 9223372036854774784. Your example is exactly what I meant with "corrupted" i.e. the value is changed by the conversion.
As a long-term Lua fan, I completely agree with you, even though its not a popular opinion. Too many times I've been debugging some Lua code, tearing my hair out, only to discover "oh yeah, we're using Lua5.3 for this - is that a problem?" .. but at least we're catching up with Python in this regard.
So unlike those languages Lua can really be considered "done". Version 5.2 was a lot like C99, maybe people considered one or two features "nice to have" but most Lua programmers saw no need to upgrade. Others like Mike Pall even considered 5.2 inferior to 5.1.
Now we have 5.3 which is really all about one special-purpose feature: 64 bit integers. That is a feature most Lua users do not need and it comes with a massive complexity and performance price tag.
Unless you really need 64 bit integer math in your scripts 5.3 is the inferior language.
I really enjoy that in classic Lua a number is a number, that is such a relief compared to the hell that is C's countless numeric types and all the potential bugs resulting from (silent) conversions between them. Lua 5.3 brought that problem to Lua e.g.
The third line silently converts a 64-bit integer variable to a 64-bit floating point variable, corrupting its value.And of course Lua 5.3 is slower and needs more memory because of the additional complexity which must be handled.
Thanks but no thanks.
I mean Lua 5.3 still makes sense if you really need 64-bit integers in your Lua scripts. But otherwise it is a downgrade.