Ownership-aware native programming with a Lua front-end, a C backend, and a practical project workflow.
Getting Started · Syntax · Standard Library · CLI Reference · Package Workflow
Rex is a systems-style language built around explicit control of values, ownership,
borrowing, and runtime behavior. The compiler front-end is written in Lua. Generated
programs target C and link against the runtime in rex/runtime_c.
The repository contains the compiler, runtime, examples, language docs, and the current project/package workflow used to build real Rex programs.
- Keep ownership and borrowing explicit without turning the language into a maze.
- Compile through a small, inspectable pipeline instead of a large opaque toolchain.
- Ship practical runtime modules for files, time, JSON, HTTP, UI, and native apps.
- Build real projects with
rex.toml,rex.lock, local dependencies, and pinned git dependencies.
- Structs, enums, methods (
impl), and type aliases - Generic functions and generic types
Resultand?for error propagation- Ownership and borrow checking with
&and&mut deferfor scope-based cleanupbond / commit / rollbackfor transaction-style flows- Concurrency primitives including
spawnand channels - Runtime modules for
io,fs,time,json,http,ui, and more - Manifest-aware projects with
rex.tomlandrex.lock
- Lua 5.4+ or a compatible Lua runtime
- A C compiler:
cc,clang, orgcc
rex run "C:\rex-lang\rex\examples\hello.rex"PowerShell fallback:
& "C:\Program Files\RexLang\bin\rex.cmd" run "C:\rex-lang\rex\examples\hello.rex"If Windows reports C compiler not found:
winget install -e --id LLVM.LLVM
setx CC clangcd rex
lua compiler/cli/rex.lua run examples/hello.rexCheck a file without building a native binary:
cd rex
lua compiler/cli/rex.lua check examples/hello.rexBuild the example suite to generated C:
cd rex
lua compiler/cli/rex.lua testuse rex::io
use rex::fmt
use rex::text
fn main() {
let title = "Hello World Example"
let priority: i32 = 42
let zero = "0"
let id = text.initials(&title)
let padded = fmt.pad_left(priority, 4, &zero)
let raw = id + ":" + padded
let result = text.lower_ascii(&raw)
println(result)
}Output:
hwe:0042
Create a new project:
rex init my-appThis writes:
my-app/rex.tomlmy-app/src/main.rex
Then build or run from the project root:
cd my-app
rex build
rex run
rex checkThese commands resolve the program entry from entry in rex.toml.
Rex now supports a project/package workflow built around local and pinned dependencies.
Add a local package:
rex add utils --path ../utils
rex installAdd a git-pinned package:
rex add jsonx --git https://github.com/example/jsonx --rev 4e2d9f1
rex installInspect the current dependency graph:
rex depsCurrent import surface from packages:
pub fnviapkg.fn()pub structviapkg.Type.new(...)pub enumviapkg.Enum.Variant(...)pub typein type positions viapkg::Alias
The full design notes live in docs/package-manager-v1.md.
Minimal manifest:
name = "my-app"
version = "0.1.0"
entry = "src/main.rex"Here version is the project/package version for my-app.
It is separate from the Rex CLI/language release version reported by rex version.
docs/getting-started.md- shortest path from checkout to running codedocs/syntax.md- syntax and core formsdocs/spec.md- language overview and design baselinedocs/ownership.md- ownership and borrowing modeldocs/bonds_system.md- bond, commit, and rollback behaviordocs/stdlib.md- standard library coveragedocs/cli-reference.md- command surfacedocs/examples-index.md- example guidedocs/troubleshooting.md- common errors and fixesdocs/roadmap.md- planned work
| Path | Purpose |
|---|---|
rex/compiler |
Lexer, parser, typechecker, and C code generator |
rex/runtime_c |
Runtime used by generated programs |
rex/examples |
Sample Rex programs |
docs |
Language and tooling documentation |
tools |
Editor and packaging support |
The current branch of Rex is focused on four things:
- freezing a clear
v1.0stability contract before large syntax additions - keeping the core language explicit and inspectable
- making the standard library practical for daily work
- stabilizing project and package management before taking on package hosting
GitHub releases are built through .github/workflows/release.yml.
Use rex version to inspect the CLI release line.
Use rex check-update to compare the installed CLI version against the latest published release.
Project manifests keep their own package version in rex.toml.
Published Windows artifacts:
rex-<version>-windows-setup.exerex-<version>-windows-portable.zip
