Lua, with types that stay out of your way.
LuaScript keeps the small, fast language you know and adds Luau-style gradual types, structs, tagged enums and pattern matching, all checked at compile time and erased before the VM runs a single instruction.
go install github.com/hilthontt/luascript/v3/cmd/luascript@latest
Features
Everything Lua does, plus what you kept reaching for.
Start untyped and add annotations where they pay off. The checker catches mistakes before your program runs, and every recording below is a real run of the interpreter.
Gradual types
Annotate a function and the checker holds every call to it. A bad call is a compile error, so nothing runs half-way.

Tagged enums & match
Sum types with payloads, destructured by match. Forget a variant and the checker tells you which one.

A REPL that knows types
Bare expressions print their value, locals survive between lines, and type errors show up as you type.

Testing built in
describe, it, hooks and a full set of assertions, with a runner that gives every test file its own VM.

Lua 5.4 at heart
Metatables, coroutines, closures, goto, integer subtypes and the full pattern library behave the way Lua does.
Types cost nothing
Annotations are checked at compile time and erased before bytecode. Untyped code is just any.
Modern syntax
?. and ?? for nil, |> pipelines, destructuring, spread, continue, if-expressions and default parameters.
Real error handling
try / catch / throw as a true protected region, defer for cleanup, and stack tracebacks across modules.
Batteries included
json, http, an HTTP server, crypto, SQL databases, regexp, time, compression, collections and more.
Data science
N-d arrays with broadcasting, dataframes, stats, linear algebra, clustering, neural nets and SVG plots.
Tooling built in
A formatter, a language server with a VS Code extension, a static analyzer, a profiler and offline docs.
Ship one file
luascript build bundles your script and the interpreter into a single executable.
The language
Familiar on the first line, more expressive by the tenth.
Every snippet here runs as written. The output is in the comments.
struct Vec { x: number, y: number }
impl Vec
function len(self): number
return math.sqrt(self.x ^ 2 + self.y ^ 2)
end
end
local v = Vec(3, 4)
print(v:len()) --> 5.0- Structs and impl blocks. Nominal types with positional or named construction, and methods attached with impl.
- Nil handled in the syntax. Optional chaining, nil-coalescing and destructuring with rest bindings.
- Errors without the pcall dance. try / catch is a real protected region: return and break inside it do what you expect.
- Still Lua underneath. Coroutines, closures and the standard library work as they do in Lua 5.4.
- Tour the syntax
Under the hood
A compiler you can read end to end.
Lex, parse, check, fold, emit, run. The AST is the only contract between stages, and the VM never sees a type.
Install LuaScript in under a minute.
One command with Go, or grab a prebuilt binary for Linux, macOS or Windows from the releases page.
go install github.com/hilthontt/luascript/v3/cmd/luascript@latest