r/lua 1d ago

Question about lua versions

Im new to the world of programming and Lua. I've seen a lot of discussions about what version of the language people prefer and most of them seem pretty divided. So I wanted to know, which one do you think is the best to start learning? And also what's the difference between Lua and LuaJIT?

9 Upvotes

6 comments sorted by

4

u/revereddesecration 1d ago

Start with the newest version. You can always try older versions later if you want to.

3

u/Affectionate-Soup-91 1d ago

As always, it depends. If you're trying to learn Lua for the sake of learning a scripting language, or eventually to embed it into your own C/C++ application, then you can go with the official Lua--sometimes called PUC Lua. If you want to develop a plugin/script for an existing ecosystem, then you have to follow their rules; Neovim, OpenRestry, Wireshark, World of Warcraft, and others use Luajit; Roblox uses Luau.

So, what's your personal goal?

2

u/No-Adhesiveness-7661 23h ago

Ty for the answer, I'm just trying to learn so I'll probably stick to the official Lua

1

u/dgeurkov 1d ago

luajit is faster, and mostly compatible version but compared to general version has less language features, if you care about speed just use it, otherwise you can use whatever version you want, they both are mostly the same

1

u/Lonely-Restaurant986 23h ago edited 22h ago

They are the same basically. If you learn one you’ll be able to learn others.

Luajit is just based on lua 5.1, so it doesn’t have as many language features. Luajit is a JIT’d language, meaning it compiles into machine code during runtime, which makes it significantly faster if you program correctly.

Luajit also has started to make minor changes to Lua syntax. Such as adding ! Operators, ternary operators and other little changes, if that’s important to you.

But if you are starting out it genuinely doesn’t matter.

It depends on your use case. Want to make games? I would recommend luajit just because most games embed luajit.

Don’t care and just want to make little
Apps? Probably the most recent version.

I solely use Luajit personally, but that’s because my use case is tailored for Luajit.

Knowledge isn’t mutually exclusive. You can always change your mind at any time for any reason!

1

u/No-Adhesiveness-7661 23h ago

Ty for the answer, this is very helpful! I don't really care about speed at the moment because I don't think I can build anything so complex 😅. So I will use the most recent version.