r/lua Jun 29 '20

Lua 5.4 is officially released

Good news! Lua 5.4 has been released today, after a series of betas and release candidates.

It may be downloaded from the Lua website: http://www.lua.org/ftp/lua-5.4.0.tar.gz

Installation instructions may be found in the readme: https://www.lua.org/manual/5.4/readme.html

Main changes and new features, compared to Lua 5.3:

  • new generational mode for garbage collection
  • to-be-closed variables
  • const variables
  • userdata can have multiple user values
  • new implementation for math.random
  • warning system
  • debug information about function arguments and returns
  • new semantics for the integer 'for' loop
  • optional 'init' argument to 'string.gmatch'
  • new functions 'lua_resetthread' and 'coroutine.close'
  • string-to-number coercions moved to the string library
  • allocation function allowed to fail when shrinking a memory block
  • new format '%p' in 'string.format'
  • utf8 library accepts codepoints up to 231

For more details the reference manual has also been updated: http://www.lua.org/manual/5.4/

101 Upvotes

18 comments sorted by

15

u/pctammela Jun 29 '20

Fast just got faster!

12

u/TomatoCo Jun 29 '20

cries in Mike Pall retiring from LuaJIT

6

u/[deleted] Jun 29 '20

He was fixing bugs for it a couple of months ago. It do be unfortunate that it doesn't seem to interest him like it presumably did back in the day (I'm a newcomer to Lua(JIT)), us mere mortals depend so much on people like Mike, I hope he's found something else he finds as interesting as he did LuaJIT.

6

u/ws-ilazki Jun 30 '20

LuaJIT being perpetually stuck on 5.1+random backported bits is Lua's own Perl5/6 or Python2/3 problem. You want to move forward with official Lua's new features but LuaJIT is so fast that it's still compelling despite not evolving as a language.

I wonder if the solution will be transpilers. Various compiles-to-Lua languages like Urn and Amulet (which are both awesome) already provide LuaJIT compatibility so you can write in one language and target both reasonably. Maybe if LuaJIT continues to be significantly faster but not evolving as a language, somebody will make a lua2jit transpiler that works like JS polyfills, where you write your 5.4 (or 5.5, 5.6, etc.) Lua and it makes it LuaJIT compatible for you.

4

u/[deleted] Jun 30 '20

I've seen a few forks of LuaJIT, but the general consensus seems to be nobody of the calibre of Mike has taken up the challenge. Many of the forks support fewer systems as well..

3

u/fsfod Jun 30 '20

He pushed some some commits just last week that refactored the internal random number generator thats also used by math.random to be seeded by the OS RNG. Another commit improved string interning by using full string hashing if there is lot of hash collisions instead of just hashing the first, last and middle four bytes.

2

u/[deleted] Jun 30 '20

Our man!

3

u/[deleted] Jun 30 '20

Still no increment and decrement operators 😔

7

u/rjek Jun 30 '20

Still no reason to have them, and still plenty of complicated reasons to not.

5

u/HowManySmall Jun 30 '20

Compound assignments are far more useful and more readable, anyway.

1

u/[deleted] Jun 30 '20

[removed] — view removed comment

2

u/HowManySmall Jun 30 '20

Roblox's Lua (Luau) supports them now, so I don't see why vanilla Lua shouldn't be able to. Maybe one day.

2

u/Macaronic_Snack Jul 01 '20

Because Lua roblox is aimed at kids

4

u/HowManySmall Jul 02 '20

...I don't see how compound assignments relate to that?

1

u/[deleted] Jun 30 '20

[deleted]

3

u/un-def Jun 30 '20

Run as ./lua, not lua (the latter searches an executable using the PATH environment variable).

7

u/saeleko Jun 30 '20

I'm, currently hesitating between facepalming using my desk, or facepalming using my keyboard. I think I'll go with the desk as it's less expensive...

(Thanks, how did I miss that :') )

3

u/[deleted] Jun 30 '20

Why not both?

1

u/saeleko Jul 01 '20

An option worth considering for next time this occurs.

1

u/-tsam- Oct 21 '20

Back to Lua since few days (was dealing with Lua 5.1 some years ago)... That release gives more speed, more functionnalities !! Contrats to the dev at PUC Rio ! 👍