• Announcement: Lua.org now officially recommends this forum as a meeting place for the Lua community

LuaJIT tutorial? (1 Viewer)

kinderalpha

Newcomer
Joined
Jan 9, 2020
Messages
8
Reaction score
11
Age
24
Location
Chicago
I tried looking into it, but it turns out I don't know anything about OTLand, or what you linked haha.

Instead, I can share this. Although LuaJIT is renowned for it's speed, beating out all other JIT-ed languages by an order of magnitude, the performance increase heavily depends on how Lua calls C/C++ libraries in the games codebase. This relies on the developer of the API for your game to ensure performance and efficiency. This doesn't mean you're out of luck though. Lua is still extremely fast. If you're working within the scope of a games Lua VM/API then you'll be fine as is. If you have performance issues with your code; it's either poor programming practices, improper localization, or inefficient usage of loops.

Either way, there may be somebody else with more information on the topic. I personally haven't used LuaJIT as I haven't found a necessity for it. I also know it's common for people to use FFI to achieve performance boosts in certain aspects of their project. That's something you could look into as well.
 

younyokel

Newcomer
Joined
Jan 8, 2020
Messages
16
Reaction score
19
Age
20
Location
Kazakhstan
Website
stackoverflow.com
LuaJIT is a compiler for Lua programming language. By “regular Lua” you probably mean the original C-compiler for it and since lua.c often compiles source code into byte code almost immediately, it is designed to be a fast one-pass compiler. But if you still interested, according to MagicWall's post about OTClient (which also written in C++): MSBuild (Visual Studio) version in standard build, uses LuaJIT library instead of regular Lua.

It's off-topic, but the OTLand Forum looks kind of familiar ;)
 

dinsdale247

Moderator
Staff member
Community Patron
Creator of WinLua
Joined
Nov 17, 2020
Messages
93
Reaction score
34
Location
Victoria BC
Website
winlua.net
Just look up Lua 5.1 tutorials. LuaJIT uses the Lua 5.1 API, not the current 5.4 API.

While you can write code that is compatible across all 5.x flavours, there are new things in 5.4 that will make it more difficult in the future. LuaJIT is very popular and many Lua modules and Lua Rocks support the 5.1 API. I would say LuaJIT is the dominant Lua engine in most games (but I'm not an expert). LuaJIT 2.0 is *smoking* fast.

(My paraphrased history that I pieced together some time ago) LuaJIT was developed by Mike Pall, who was a very active member in the Lua community. LuaJIT was written with large chunks of assembler and was optimized for Lua 5.1, 32 bit. When the Lua team started making changes to the VM he got very upset and when Lua 5.2 was announce he split with the Lua.org community and said he is keeping his VM API at 5.1. The Lua community has never recovered from that split and Mike Pall has no inclination to adopt the newer API. There was some code written to patch LuaJIT 2.0 for the Lua 5.3 API, but I don't think it gained much traction.

The Lua 5.1 API does not have bitwise operations or Booleans and loads modules much differently than 5.2+. However, the bitwise operators issue has been patched with extensions. Lua 5.3 added an integer and float number type. Lua 5.4. has added new closures that will be interesting. LuaJIT has a very good Foreign Function Interface (FFI) that allows you to dynamically load C/C++ very easily without having to write extensions like in regular Lua. LuaJIT is not deficient, it's just a little different.

NOW, with all that said, "regular" Lua is an extremely fast language. Don't think you need to use LuaJIT to write fast applications or scripts. I use Lua to script various tasks at work and it makes python and bash shell scripts look dopey. Powershell.... is.... so.... slow....
 
Top