Hacker Newsnew | past | comments | ask | show | jobs | submit | Dekkonot's commentslogin

Disclaimer: I've contributed to Lune multiple times and have contributed off and on to Luau as well.

For those who aren't familiar, Luau is a language based on Lua that is developed and maintained by Roblox. It's entirely open source (you can see the repo here: https://github.com/luau-lang/luau) and it's diverged a fair bit from Lua at this point. Most notably, it's quite a bit faster than the PUC-Rio distribution of Lua, has native vector support, and has a type checker. It's not as fast as LuaJIT, but it's about as fast as you can expect for a non-JITed language and it has support for AoT compiling to native instructions on x86 and aarch64, so it can be basically as fast as LuaJIT for some tasks.

It's worth reading the website: https://luau.org/

Lune itself is nice and I use it for basically all of the scripting needs I have. Some of the API is limited compared to what you'd get in other runtimes (the obvious example is hashing, where it's just "string in, string out" instead of a stream that you can feed into and then finalize) but the logic is essentially that APIs should be "good enough" for the average user, not perfect. I think that's fine, but I'm also the one that wrote the hashing API so take it with a grain of salt. :-)


Luau also has some special features to make running untrusted user code.

Lua itself has a bit of a reputation for this, but it isn't quite true. For example, normal Lua doesn't really let you stop the execution of a program stuck in an infinite loop, either accidentally or maliciously.


Does it compile to wasm? So that it is useful inside the browser?


Luau itself does by design, but I've never tried compiling Lune to WASM. I know that there are some blockers with the Roblox library but that's an optional component and you can just leave it out.

The WASM build is actually what powers the demo on their website: https://luau.org/demo


Hey! Yet another long-term contributor to Lune, and this is something I've experimented with for a while, but it wasn't possible due to our heavy reliance on Tokio for async I/O for a while. That has recently changed though, so I'm curious if that has changed much. I might try again and report back here.

However, I should mention that there is another Luau runtime called cart which has the sole goal of being heavily portable across environments -- and it supports running within WASM! You can even interact with JS APIs and mutate the DOM to write websites with it, if you wanted to.

cart: https://github.com/crossapprt/cart


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.


Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: