Hacker News new | ask | show | jobs
Ask HN: Looking for platforms, other than Roblox, that have adopted Luau
40 points by aduermael 965 days ago
We're considering adopting Luau for our project (a platform where users create games with cubes and Lua scripts). We're pretty happy with Lua already, but Luau brings type annotations and performance improvements while remaining backwards compatible with Lua 5.1. Luau's been developped by Roblox, open sourced in 2020, and still mostly used by Roblox apparently. Timing would be good for us if we decide to switch to Luau, but still, feedback from others who've been through the same Lua to Luau transition would be very helpful. Any ideas? Are we crazy to even consider this?
11 comments

Looking at other replies here, I can see I wasn't the only one who didn't realize there is Lua and Luau. Luau is an extension of Lua: https://luau-lang.org/

> Luau is syntactically backwards-compatible with Lua 5.1 (code that is valid Lua 5.1 is also valid Luau); however, we have extended the language with a set of syntactical features that make the language more familiar and ergonomic.

Oh yes, thank you for posting the link. It's hard to notice the extra `u`
I use Luau in my games and tools [1], and I recommend it. While I can't speak to transitioning to it from Lua, since I didn't do that, I can say that it's fast, stable, sandboxing just works (important for your use case), and it's very well supported and regularly updated.

For context, I first started using Luau as an experimental hack by integrating it with Unity. I mostly just wanted fast and simple hot reloading. I found myself writing more and more of it, and now I'm writing most of my code in it.

VS Code support is pretty good via the luau-lsp language server [2]. Type support for certain code patterns isn't great yet, but there are RFCs to improve this.

They're also quietly working on native code gen and JIT support, e.g. this PR from a few hours ago [3].

Overall, recommended! You're not crazy.

[1] https://twitter.com/kineticpoet

[2] https://github.com/JohnnyMorganz/luau-lsp

[3] https://github.com/Roblox/luau/pull/1076

Great feedback thanks! Most devs in my team are using VS Code, but apparently there are integration for Sublime Text too (which I use).

Thanks for the links, I'll check them out later today!

Grimrock/Druidstone devs (Almost Humand Ltd. / Ctrl alt ninja -- mostly the same people) switched their custom engine to Luau https://twitter.com/petrih3/status/1532738882030260225

edit: Nitter link for convenience https://nitter.net/petrih3/status/1532738882030260225

Thank you!
I'm rather biased because I am a Roblox dev who's also contributed to Luau and its tooling environment.

I would generally recommend Luau over Lua in most cases. If you don't need the simplicity that Lua provides (C is a lot easier to compile than C++), there's no contest to me, especially for game development.

LuaJIT is great, but if you plan to ship to mobile or console, you can't use JIT. You could use its FFI library, but that's the only real advantage.

Luau, however, has a bunch. Its interpreter as often as fast as LuaJIT's interpreter (without JIT), it's improved weekly with a variety of optimizations, and you have a killer feature: native vectors. For game development or heavy math code, that's a really big deal because it means vectors live directly on the stack and aren't garbage collected, making them very fast. Luau also has some very nice QOL and of course type checking.

There's some disadvantages, mind you. The most notable one is that as far as I'm aware all tooling for Luau comes from Roblox users. The Luau LSP extension someone linked earlier, as an example, is developed by a Roblox user. Luau also doesn't implement tailcalls, which might matter to you. I forget the reasoning but it was mostly a UX thing.

There's also no native integers and there probably won't ever be. LuaJIT and Lua 5.3+ have support for 64-bit integers but Luau doesn't, since they have complicated semantics if you want them to be first class citizens and a lot of Luau users are children.

Thank you, very insightful! Yes, mobile is very important to us, so we ruled out LuaJIT anyway.

I've read that garbage collection has been improved in Luau, can we know now exactly when the last reference on a table is lost? It's not critical, but would simplify in things for us in a few situations.

Thanks again!

I'm not sure about the garbage collection improvements since I haven't touched the GC, unfortunately. My philosophy is generally that I just let it do its work.
Just recently published some preliminary dotnet bindings/libgen stuff for Luau in hopes to kickstart its wider use in C#:

https://github.com/afterschoolstudio/Luau.NET

World of Warcraft interface addons are made with Lua.

https://www.wowhead.com/guide/comprehensive-beginners-guide-...

That is Lua, not Luau. I noted the distinction in an earlier comment since I see I wasn't the only one here who wasn't aware.
Not crazy. Sounds like a good idea given your used case.

Is there a transpired from Luau to Lua? Otherwise you could never go back, you would eventually be forced to use their run time. Do they have an interpreter only mode? Can you run on web assembly?

Good point, I don't know how hard transitioning back would be, we would need to review the language diff. Is it simple stuff like removing type annotations and reverting "i += 1" (Luau) by "i = i + 1" (Lua) ?

I don't know if they have an interpreter only mode.

Yes, our projet runs on WebAssembly. (https://app.cu.bzh)

Luau also adds a continue keyword. It's probably the most troublesome thing you might encounter if you wanted to go from Luau back to Lua.
Darklua can compile Luau to Lua 5.1: https://github.com/seaofvoices/darklua
Darklua is brilliant and works well for converting existing Lua projects to Luau for improved type safety as well as the reverse to convert existing Luau projects to Lua, allowing better compatibility. Unfortunately last I checked continue statements, if-then-else expressions, and interpolated strings weren't yet supported for conversion to Lua and still had open issues, which was a problem for a number of Luau libraries, though it's still resulted in an improvement in development experience for us.
Factorio uses Lua script for both in-game and mod scripting: https://wiki.factorio.com/Tutorial:Scripting
Yeah but OP is asking about transitioning from Lua to Luau
If I can add a small request, it would be very helpful to get feedback from Roblox dev (either from the company, or people building on Roblox who have experience with Lua as well)
Pretty sure Warframe uses it, too.
Thanks. I have found a possible mention of it here: https://github.com/Reversive/warframe-luau-dump
I don't know, but am bored so looked into it.

From looking at the Github repo's contributors, forks, etc it doesn't look like it.

ChatGPT says it isn't used outside of Roblox, but google found this cross-dev game framework that has their own variant they've started: giderosmobile.com. But Google doesn't show anyone else?

I did exactly the same, starting from the repository on GitHub. Though chat though me it was used outside Roblox, but without giving me examples.

Gideros is an interesting case, seems like they already added / modified features while using Lua and had to replicate those changes supporting their own version of Luau.

Personally, I would prefer to stick with regular Luau to benefit from regular improvements and be able to contribute back to the project eventually.