Adapted from the black-candle-technologies/rexlang repository docs.
Rex is a memory-safe programming language inspired by Rust, Zig, and Go:
Rex programs define a zero-argument main returning int or void:
fn main() -> int {
let value = increment(1);
print("result: {}", value)
}
fn increment(x: int) -> int {
x + 1
}
let creates inferred or explicitly typed locals; // starts a line comment; semicolons discard expression results.-> type declares void.print(value) writes the value's representation + newline. String literals support named interpolation ("{value}"); extra args fill positional {} placeholders. format(...) returns the string without writing.==, !=, <, <=, >, >= work as expected. if requires a boolean condition and is an expression when both branches return the same type.Structs and contracts (compile-time interfaces):
contract Identifiable { id: int, fn id(&self) -> int }
struct User { id: int, }
satisfy Identifiable for User { fn id(&self) -> int { self.id } }
The std library defines std.Eq using @fields(Self), allowing derived fieldwise equality:
const std = @import("std");
struct User { id: int } satisfies std.Eq;
Packages and visibility:
package example;
const std = @import("std");
fn main() {
let instant = std.Time.Now();
print("{}", instant.format("dd-mm-yy"));
}
@import("std") is a compile-time builtin. @import can also name a Rex package (currently same-directory). Functions default to private (file-local); protected fn is visible within the package; public fn is visible to importers.
rex run program.rex # compile and execute (.rex source or .rexl bytecode)
rex build program.rex # compile to bytecode (writes program.rexl)
rex build program.rex -o out.rexl
rex pack program.rex # self-contained native executable bundling the Rex VM
rex pack program.rex --platform=windows # cross-platform pack (darwin/linux/windows)
Cross-platform pack needs a rex-runner for the target platform next to rex (or REX_RUNNER).
Cargo workspace under crates/: lexer, parser, compiler, vm, runner, cli.
Borrow checking is not yet implemented. The package system is an early slice (same-directory imports), not a package manager.