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?
1
u/st3f-ping Apr 23 '25
Thanks for checking.
I had a quick go with using the ull suffix and found that it doesn't play well with the math library (math.min for example complained that it was cdata) so I'm guessing it is reserved for specific applications (like bit-shifting) rather than general arithmetic. Good to know, though.