> using a combination of techniques pioneered by LuaJIT and custom optimizations that are able to improve performance by taking control over the entire stack (language, compiler, interpreter, virtual machine), we’re able to get close to LuaJIT interpreter performance while using C as an implementation language.
At first I was a bit surprised by this, given that they have much better type information, but they forget to mention until further on that Luau doesn't use JIT/AOT optimizations (yet). Still, it's as good an excuse as any to bring out this quote again:
“LuaJIT is much faster than all of the other languages, including Wren, because Mike Pall is a robot from the future”
Slight digression. IIRC PHP was using Mike’s work (DynASM) a while ago. Is this still the case and is anyone else using aspects of LuaJIT (eg DynASM or the byte code interpreter)?
People seem to say this (or similar remarks) when talking about Lua but even more specifically, LuaJIT in particular but it seems like Lua is already a pretty niche language so am I just missing something? Like you can embed Lua in other languages but why use Lua instead of something like mruby for all the warm fuzzy feelings you get when writing Ruby?
Just curious, appreciate any context you can provide!
The main reason is momentum - Lua has been the de-facto standard embeddable language for at least 15 years. For example, it's used in World of Warcraft which was released in 2004.
Another reason is the quality of the implementation - Lua has very few bugs [0], whereas Shopify tried to embed mruby and had to give up because it had too many security holes [1].
Finally, Lua is a complete language in itself, with a guidebook, reference manual and so on. Mruby (and MicroPython) are less well-known. Plenty of people know Ruby or Python, but if you use the smaller implementations, you never know when your code might hit a language feature that they don't support.
The advantage that Lua has is that it has about the simplest possible binding interface you can imagine for a Language.
There's no manifests, no class definitions, no anything really. It's as simple as calling lua_newstate to create a state, calling lua_pushcfunction to register some functions that expose your desired engine functionality, and calling lua_loadstring with a script to run.
That means you can use Lua in your engine for something as simple as a CLI interface that just exposes a couple dozen functions, and it's still worth it. Where with any other scripting language you'd have to be doing a lot more with it to make the setup cost worthwhile.
Having LuaJIT available if you end up wanting to do more with it later is the icing on the cake.
> it seems like Lua is already a pretty niche language
Keep in mind that what we see on the internet is a vocal publicly part. Some important domains are not publicly represented.
For example, in my domain CGI/VFX, Python is used all around, but lua has growth in some places. For example it is used in Guerilla[0] and Katana[1], two software related to rendering and scene management. Technically a niche, but commercial product too. So, groups of people uses it all day but you will not find questions about it on stack overflow.
The reason to choose lua despite having Python all around is it's lightweight, apps can hack the VM for your specific needs, function call cost is faster and you can easily expand it with C (compared to Python).
This is just an example related to my domain, but I suspect this pattern is similar in many domains that doesn't pop on the internet. I suspect web dev is overexposed on the internet, making people thinking it's how dev runs all around.
At first I was a bit surprised by this, given that they have much better type information, but they forget to mention until further on that Luau doesn't use JIT/AOT optimizations (yet). Still, it's as good an excuse as any to bring out this quote again:
“LuaJIT is much faster than all of the other languages, including Wren, because Mike Pall is a robot from the future”
- Robert Nystrom