Potentially adding support for LuaU?

Post Reply
gscope
New member
Posts: 1
Joined: Wed Feb 22, 2023 22:52
GitHub: g-scope
In-game: g-scope
Contact:

Potentially adding support for LuaU?

by gscope » Post

Hi, I'm extremely new here and I've searched around for a bit.
When it comes to Lua, I've originally learned it under ROBLOX.

ROBLOX nowadays, has a different version of Lua called LuaU.
I was wondering if it's possible to add support for that version of Lua for the following reason:
  • Type annotations, provides more support for intellisense and type checking.

Overall, I think adding LuaU support could have great benefits in terms of code stability via type annotation support. Although it can come at the cost of performance decrease for runtime but LuaU does claim to have the capability to run as fast as LuaJIT in certain instances.

I'm not aware of what limitations there are when it comes to Minetest.
I don't know any user-ended workarounds that exist such as transpiling LuaU into Lua that can be ran in Minetest.

Hope to get some of your thoughts and recommendations.

I'm hoping to figure out if it's possible that there can be support for both versions of Lua.
If you're wanting to know more about LuaU you can check the site here: https://luau-lang.org/

Thank you for your time!

User avatar
Blockhead
Member
Posts: 1622
Joined: Wed Jul 17, 2019 10:14
GitHub: Montandalar
IRC: Blockhead256
In-game: Blockhead Blockhead256
Location: Land Down Under
Contact:

Re: Potentially adding support for LuaU?

by Blockhead » Post

gscope wrote:
Wed Feb 22, 2023 23:15
Hi, I'm extremely new here and I've searched around for a bit.
When it comes to Lua, I've originally learned it under ROBLOX.

ROBLOX nowadays, has a different version of Lua called LuaU.
I was wondering if it's possible to add support for that version of Lua for the following reason:
  • Type annotations, provides more support for intellisense and type checking.

Overall, I think adding LuaU support could have great benefits in terms of code stability via type annotation support. Although it can come at the cost of performance decrease for runtime but LuaU does claim to have the capability to run as fast as LuaJIT in certain instances.

I'm not aware of what limitations there are when it comes to Minetest.
I don't know any user-ended workarounds that exist such as transpiling LuaU into Lua that can be ran in Minetest.

Hope to get some of your thoughts and recommendations.

I'm hoping to figure out if it's possible that there can be support for both versions of Lua.
If you're wanting to know more about LuaU you can check the site here: https://luau-lang.org/

Thank you for your time!
Introduction
Luau (Luau (lowercase u, /ˈlu.aʊ/), from the homepage) even says that they are not fully 5.1-compatible on their compatibility page, due to removing several standard libraries like io, os, debug and dofile, all of which are very widely used in Minetest. What you are proposing would involve a complete mod compatibility break, more so than any other breakage that people typically complain about around here. I can't see it happening, sorry. Gradual typing and good sandboxing are important yes, but I'm not sure anything but a fully transpilable language would succeed for Minetest. There are proliferation of those available for Lua.

Comparing the Roblox vs Minetest landscapes
As good as it might be to leverage Roblox Corporation's technical powerhouse, we are probably too far developed in our own direction and left without resources to make the switch easy enough to complete. Being new you may not realise it, but a lot of people around here are very anti-breaking-changes. So much so that the minor breaks of compatibility introduced in the transition from 0.4.x to 5.x are still considered unacceptable by the (minority) community at minetest.org "Final Minetest", as well as the MultiCraft open source project & mobile app.

Roblox has the 300-pound gorilla status of being able to decide what scripting language their game is going to use and everyone has to follow suit or they'll be outcompeted on the platform. Minetest is a community built around a small core developer team working on the C++ engine and a larger number of Lua developers (being a C++ and Lua developer is obviously not mutually exclusive). Many of those Lua developers wrote their mods once upon a time 3 years ago and either don't care or aren't around to update them. Most salient of all I think: there are no MineBux like there are Robux, no developer share and so on. People by and large don't make money off Minetest, unless they're a top mod/game author with a small amount of donation money coming in, or they rent Minetest servers to others. Minetest is a low-stakes environment compared to Roblox.

Runtime support
As it stands, Minetest presently supports (our bundled, slightly modified) PUC Lua 5.1 and LuaJIT runtimes, though LuaJIT is by far the widely preferred option. Adding a third, quite different, runtime would cause a lot of trouble. Roblox only has one language version and one runtime, and they have a lot more developer resources. Embracing Luau for Minetest would probably mean ditching other runtimes completely due to the incompatibility between mods written either for Luau or our existing 5.1 runtimes.

Technical difficulties in the transition
We have our own Lua sandbox code already present. This protects against file access from unauthorised locations. I don't doubt the quality of Roblox Corporation's sandbox, since they probably have black and white hats who work full time trying to find Roblox vulnerabilities. Minetest mods that want to use certain functions outside the sandbox have to be deliberately marked trusted. The ability to do this is a blessing and a curse. Minetest is certainly freer than Roblox: we have no centralised authentication system, no global bans, and it's free software. Minetest mods can bridge chat to Matrix, Discord, IRC and more, which I'd hazard a guess is not possible in Roblox. On the other hand, all it takes is a singular malware author to possibly spread a bad 'trusted' mod. The strongly pro-free software nature of Minetest means we get investigations like Suspicious block of code in a mod pull request.

File I/O is present and perhaps even a performance necessity for many mods. Certainly, removing it would be a hugely breaking change. Mods would have to refactor from a variety of serialisation formats into the Minetest modstorage API or a hypothetical new virtual filesystem.

The Debug library has been used successfully to create the Debug mod. This mod requires the unsafe environment, but it is also very useful in some cases. What debugging tools does Roblox have?

The os library is limited to the following functions in the default sandbox:

Code: Select all

os.clock
os.date
os.difftime
os.getenv
os.remove -- limited to current world directory
os.rename -- limited to current world directory
os.setlocale
os.time
dofile is the method for splitting source files up in Minetest. I've tried require several times but it doesn't seem to be supported. I poked around some Roblox open source code and it seems require is the method used there. Removing dofile in favour of require would certainly break every mod ever made that isn't just a singular init.lua. At least it wouldn't be so difficult I suppose, mostly find and replace.

There are mods that embed Lua scripting into themselves. These include mesecons' Luacontroller and AdvTrains' LuaATC. Those mods manage their own sandbox environments that further restrict what functions are available. Most of them completely disallow most of the above functions as well.

You mentioned performance against LuaJIT probably being worse. A lot of server operators aren't going to be happy about that. Running a high population server requires high performance and most of the gains in Minetest are to be had from optimising what Lua mods you are running. If the Luau runtime isn't up to scratch, your proposal has basically already lost.
/˳˳_˳˳]_[˳˳_˳˳]_[˳˳_˳˳\ Advtrains enthusiast | My map: Noah's Railyard | My Content on ContentDB ✝️♂

User avatar
LMD
Member
Posts: 1386
Joined: Sat Apr 08, 2017 08:16
GitHub: appgurueu
IRC: appguru[eu]
In-game: LMD
Location: Germany
Contact:

Re: Potentially adding support for LuaU?

by LMD » Post

If you're familiar with LuaU, switching to Lua 5.1 should be pretty easy.

You cite
Type annotations, provides more support for intellisense and type checking.
as the primary reason for supporting LuaU. You don't need LuaU for this though. You can have type annotations in regular Lua, e.g. by using the sumneko lua language server in VS Code / VS Codium / OSS Code (whichever you prefer).

Furthermore, there are multiple typed Lua preprocessors such as Teal or the more popular TypeScript which transpile to Lua. I know that TypeScript has already been successfully used with Minetest (I can't find the blog article right now though - EDIT: wsor has pointed out to me that the link is https://leanrada.com/works/miniforts.html, thanks!).

Blockhead has already done a good job of outlining why we can't support LuaU: We have to maintain backwards compatibility with PUC Lua 5.1. This would not be possible when switching to LuaU. Supporting both (by running them in parallel or the like) is not feasible; our current design supports only one scripting environment.
My stuff: Projects - Mods - Website

c56
Member
Posts: 307
Joined: Wed Apr 21, 2021 03:05
GitHub: tigercoding56
In-game: bm5 or bemo5 also sell_her_on55

Re: Potentially adding support for LuaU?

by c56 » Post

i could swear people already ask this question for every other language . "potentially adding support for python " / "potentially adding support for rust " / "potentially adding support for golang " "potentially adding support for c++ (wait it is already there) " / "potentially adding support for english " (wait english is such a bad language it probably would break everything )
this is a signature not a place to post messages also if i could change my username i would change it to sell_her_on55

Post Reply

Who is online

Users browsing this forum: No registered users and 3 guests