Luau Recap: July 2024

This is huge for roblox, now only for a wikipedia article to be made or even blog posts discussing the language. (w3schools too?)

3 Likes

The moment Luau allows me to add type constraints to generic functions, that is the day I will never ever disable strict again.

I’d love to do something like a basic interface, and then do composition just based on the type signature alone, not depending on any metamethods.

Something like this (C#)

public interface ITestTestable {
   public string GetTestableName();
}
public class Test {
    public static void RunTest<T>(T value) where T : ITestTestable {
        var name = value.GetTestableName(); // Legal code.
        System.Console.WriteLine($"Testable name: {name}"); 
    }
}

would be perfect in Luau to allow us to define a sort of OOP without the inherent costs of metatables.

-- Purely theoretical.
type IGun = { GetBulletCount: (self: IGun) -> number, ToggleDebugFeatures: (self: IGun, enable: boolean) -> () }
type IEnemy = { GetHealth: (self: IEnemy) -> number }

local function TestGun<T: & IGun, U: & IEnemy>(gun: T, target: U)
            if gun.GetBulletCount() > 20 then
                    warn("Weapon has 20 bullets")
            end
end

type Pistol = { PerformValidation: (self: Pistol) -> () } & IGun
type Zombie = { PlayGroan: (self: Zombie) -> () } & IEnemy

local pistol = nil :: Pistol
local zombie = nil :: Zombie
TestGun(pistol, zombie)

If this ever comes to be, I’d actively consider making types for all my Luau projects, no questions asked, because then I can be guaranteed generics won’t be pretty much taking any with extra steps, which is practically what it is, except on some cases, where you specify the generic type on types that use types that use generics.

2 Likes

Ehhh, that probably won’t happen for a while until Luau spreads a bit further beyond Roblox, as Wikipedia has requirements of notability for an article.

2 Likes

My understanding based on discussions on Discord with the team is that there’s a resistance to bringing it to the client since there are platforms that don’t allow it. While they could enable it for e.g. PC clients, it would make the already significant performance difference even more severe.

Mind you, this is just the vibe I get and not an actual answer. I imagine the official corporate answer is “We are looking into opportunities to being native codegen to the Roblox client” with no followup.

3 Likes

im pretty sure on ios only web browsers are allowed to do that stuff