Latest Update
What is Classe?
Classe is a smart class wrapper for Luau. It automatically calculates Object Structures, including Fields and Methods, using advanced Type Functions. Furthermore, Classe optimizes metadata lookups, ensuring high performance even with deep inheritance hierarchies
Basic Class
local Weapon = Classe.meta({ })
type Self = Classe.Self<typeof(Weapon)>
function Weapon.shot(self: Self)
self.bullets -= 1
print("Boom!")
end
function Weapon.construct(self)
self.bullets = 10
return self
end
return Classe.build(Weapon)
Inheritance
local Rifle, super = Classe.meta({}, Weapon)
type Self = Classe.Self<typeof(Rifle)>
function Rifle.aim(self: Self)
self.isAiming = true
print("aiming...")
end
function Rifle.construct(self)
self.isAiming = false
super(self)
return self
end
return Classe.build(Rifle)
Standard Basic Class
--!strict
local Rifle, __class = {}, setmetatable({}, {
Weapon.__meta
})
function __class.aim(self: Rifle)
self.isAiming = true
print("aiming...")
end
local __meta = {__index = __class}
export type Rifle = setmetatable<{
isAiming: boolean,
bullets: number,
}, typeof(__meta)> & Weapon.Weapon
function Rifle.new(): Rifle
local self = Weapon.new()
self.isAiming = false
return setmetatable(self, __meta) :: Rifle
end
Rifle.__meta = __meta
return table.freeze(Rifle)
Speed and memory
Classe is primarily focused on performance rather than memory efficiency.
During inheritance, the parent’s metadata is copied into the child. This should not significantly impact memory usage, since mostly function references and primitive values are copied, which are inexpensive on their own.
This approach improves method call performance because it avoids __index chains and additional lookups across the inheritance hierarchy.
If a class has subclasses and its metadata needs to be modified, __newindex is triggered. It iterates through all child classes and updates the corresponding data, while checking whether the metadata has been overridden in the subclass.
Here is a method call at the 99th level of inheritance (500k tests)







