Skip to main content

Nebra

A typed superset of Lua. Classes, generics, pattern matching, async/await, modules and a package manager, all compiled away into clean, portable Lua.

Lua 5.1 to 5.4LuaJITNo runtime dependencyMIT licensed

What the compiler does

Types, classes and default parameters exist only while compiling. What lands on disk is Lua you would have been happy to write by hand. This is real compiler output, with [reflection] mode = "none"set so the optional metadata block is left out.

src/counter.neb
--- A counter that never leaves its range.
class Counter
count: number = 0

constructor(start: number = 0)
self.count = start
end

function bump(by: number = 1): number
self.count = clamp(self.count + by, 0, 100)
return self.count
end
end

function clamp(v: number, lo: number, hi: number): number
if v < lo then return lo end
if v > hi then return hi end
return v
end

local c = new Counter(5)
print(c:bump()) -- 6
print(c:bump(10)) -- 16
out/counter.lua
local Counter = {}
Counter.__index = Counter
Counter.__name = "Counter"
function Counter.new(start)
local self = setmetatable({}, Counter)
self.count = 0
self.count = start
return self
end
function Counter:bump(by)
if by == nil then by = 1 end
self.count = clamp(self.count + by, 0, 100)
return self.count
end
function clamp(v, lo, hi)
if v < lo then
return lo
end
if v > hi then
return hi
end
return v
end
local c = Counter.new(5)
print(c:bump())
print(c:bump(10))

Install in one line

The installer detects your platform, downloads the matching release archive and puts nebra on your PATH. No admin rights and no .NET or Lua installation required on the target machine.

curl -fsSL https://raw.githubusercontent.com/nebra-lang/nebra/master/scripts/install.sh | bash

Then open a new shell and run nebra version. See the installation guide for manual downloads, pinning a version and building from source.

Editor support

The language server ships inside the same binary. The VS Code extension launches it for you and gives you diagnostics, hover types, completion, go to definition, rename, signature help and semantic highlighting.