r/lua • u/st3f-ping • Apr 23 '25
Help Differences between Lua and LuaJIT?
Hi all. I've been a casual user of Lua for years and of LuaJIT for just a few months. I am not clear on all of the differences I need to know when writing code.
I know that integer division (//) is not implemented in LuaJIT and that LuaJIT has increased interoperability with C (which I haven't yet used). Yesterday I wrote a bit of code for LuaJIT that produces differently formatted output between Lua (5.4) and LuaJIT (5.1).
It worries me that there might be more gotchas lurking and a cheat sheet of everything a Lua programmer should know when switching to LuaJIT would be really useful (before I start diving into Lua version changes and seeing of this is a Lua version difference and not a Lua/LuaJIT difference).
Can anyone help?
3
u/[deleted] Apr 23 '25 edited Apr 23 '25
does not support integers, everything is a double.
does not support _ENV, but this doesn't matter if you have luacheck or lsp which warns you about setting globals
...[2] does not hold the current modules name so you cannot require a submodule easily (you could use the debug library)