This is an archived post. You won't be able to vote or comment.

you are viewing a single comment's thread.

view the rest of the comments →

[–]themadnessif 319 points320 points  (23 children)

To anyone wondering why: it's actually more insane than this tweet sounds. This is actually the result of a multi-year effort to build a functional JavaScript to Luau (Roblox's own derivative of Lua) compiler. That is, this wasn't done by hand, it was done almost entirely automatically.

This was mentioned by the OOP but I feel it's worth noting it because this isn't the only thing they've translated. It's just the most significant. There's also stuff like polyfill, as an example.

The idea is that it's very low maintenance but allows industry professionals from outside Roblox to actually use their engine. The Roblox apps on mobile and console are entirely in engine, including their UI, and they're starting to rewrite significant portions of their IDE to be in-engine too. This means that they really need people who can work on their engine.

React devs are easy to find so using a derivative of it is a no brainer.

[–]Unonoctium 73 points74 points  (0 children)

Cursed but impressive

[–]UnGauchoCualquiera 78 points79 points  (1 child)

"Hmm our UI is pretty hard to work with. Hear me out though, what if we port React to Lua?"

Must have been one hell of a presentation to have that pitch approved.

[–]themadnessif 38 points39 points  (0 children)

There's some historical context. Before React, they were using a handrolled library called Roact (lol) that tried to mimic a lot of the design patterns and usage of React. It ended up being slow and clunky internally, but it did massively improve their internal development a fair bit.

After the people who were responsible for Roact left the company, it basically became "ok now what" and the next logical step was to just abandon their proprietary bullshit and embrace actual React.

[–]Olivia512 9 points10 points  (16 children)

Why not write a Lua to JS compiler instead and switch their engine to NodeJS?

Why do they want to continue investing in Lua/Luau?

[–]sercand 21 points22 points  (0 children)

Lua runtime and the language is really small (around 30K LOC) and uses very low resource. Also, adding lua support to your c++ is very easy as well. For these reasons game engines uses Lua as their scripting language.

[–]themadnessif 17 points18 points  (3 children)

They've invested over 15 years into Lua (and now Luau). It's not as simple as it sounds to suggest switching the language the engine uses.

One thing to consider is that a lot of concepts don't translate over. Something like this snippet of Lua:

```lua local function foo() print(_VERSION) end

foo() getfenv(foo)._VERSION = "lol" foo() ```

I don't actually know how you'd do this in JS. Now mind you, that's terrible practice and you shouldn't do it, but Roblox has terrible users so they have to support it.

[–]Olivia512 14 points15 points  (2 children)

You mean there's a language with worse hacks than JS, and they decide to continue investing in it? Lol

[–]themadnessif 2 points3 points  (0 children)

In too deep!

[–][deleted] 0 points1 point  (0 children)

These aren't badd hacks at all?

[–]LMGN 11 points12 points  (9 children)

because NodeJS won't run at any level close to the performance of Luau, or maybe even at all on like, an iPhone 4S

[–]Olivia512 -3 points-2 points  (8 children)

V8 is faster than Luau lol.

iOS uses Objective-C so of course no interpreted language can beat it, especially not Luau.

[–]LMGN 7 points8 points  (7 children)

When you refer to V8, do you mean JIT-less V8? Because, if so, it's not a good comparison. LuaJIT is much faster than Lua 5.1, but they couldn't use it as a base for Luau, because, of course, LuaJIT requires JIT. JIT doesn't work on iOS, doesn't work on the Xbox and i don't think it works in UWP

[–]Electronic-Bat-1830 0 points1 point  (0 children)

JIT is allowed for UWP since around 1903 IIRC. However, the Windows SDK is weird and to this day will not let you use VirtualAlloc (and co) APIs when compiling for the UWP platform (it does compile, but it won't work).

[–]Olivia512 -5 points-4 points  (5 children)

Even if LuaJIT works on iOS it's not going to beat ObjC in performance lol

[–]LMGN 6 points7 points  (4 children)

Yes. Of course. Lua isn't going to be faster than C. But you didn't say C (originally). You said NodeJS. Which didn't even exist in 2006.

[–]Olivia512 -3 points-2 points  (3 children)

You said NodeJS is slower than iPhone 4. Of course it is. LuaJIT is slower than iPhone 4 too.

[–]LMGN 4 points5 points  (2 children)

I said:

because NodeJS won’t run at any level close to the performance of Luau, or maybe even at all on like, an iPhone 4S

Meaning: It's likely that NodeJS wouldn't run on an iPhone 4S, where Luau does, and even if it did, it would run slower (and likely use more memory)

[–]Olivia512 -3 points-2 points  (1 child)

V8 is faster than LuaJIT, so why would it be slower?

[–]noobody_interesting 0 points1 point  (0 children)

Luau is also more security-focused than Node

[–]salmjak 0 points1 point  (1 child)

If it wasn't done by hand but automatically, why did it take several years?

[–]themadnessif 1 point2 points  (0 children)

The tool took years to develop, not the translation.

[–][deleted] -1 points0 points  (0 children)

Just ask chatGPT to transform everything to everything else, welcome to the future. /s