Lua & TypeLua (.tyl)¶
Orbita embeds the Luau VM as its unified execution engine. This lets you run standard Lua 5.1 (.lua) alongside gradually typed TypeLua (.tyl) in the same process, with seamless require() interoperability.
Why Luau?¶
- Native gradual typing: add type annotations where they help, without a separate type-stripping build step.
- High performance: an optimized C++ VM with an incremental garbage collector.
- Sandboxed by design: Luau omits unsafe
io,os.execute,package.loadlib, and rawffiAPIs — all system access flows through Orbita's permission-checked Rust standard library.
TypeLua (.tyl) Syntax¶
type User = {
id: number,
name: string,
admin: boolean?,
}
local function format_user(user: User): string
local role: string = if user.admin then "admin" else "member"
return string.format("#%d %s (%s)", user.id, user.name, role)
end
local ada: User = { id = 1, name = "Ada", admin = true }
print(format_user(ada))
Native OOP with ob.class(base?)¶
Orbita provides a built-in ob.class() helper so you can write clean classes and inheritance without manual __index / setmetatable boilerplate:
local Animal = ob.class()
function Animal:init(name: string)
self.name = name
end
function Animal:speak(): string
return self.name .. " makes a sound"
end
-- Single inheritance
local Dog = ob.class(Animal)
function Dog:speak(): string
return self.name .. " barks!"
end
local rex = Dog.new("Rex") -- or Dog("Rex")
print(rex:speak()) -- Rex barks!
Supported Extensions¶
| Extension | Behavior |
|---|---|
.lua |
Executed directly in the Luau VM. |
.tyl |
TypeLua — executed natively in the Luau VM with full gradual type syntax support. |
.luax / .tylx |
Automatically transpiled into ob_jsx(...) calls before execution. |
Shebang support
You can start any script with #!/usr/bin/env ob — Orbita strips the shebang line automatically before loading the chunk.