1 stable release
Uses new Rust 2024
| 2.2.0 | Sep 24, 2026 |
|---|
#21 in #rl-lang
Used in rl-cli
16KB
427 lines
RL
A statically-typed interpreted language written in Rust with a clean syntax, a TUI REPL, and a growing standard library.
Toolchain: rl (core CLI) · rlc (compiler) · rlt (C transpiler) · rlrepl (REPL) · rlsp (LSP) · rldocs (docs) · rlm (toolchain manager)
Quick look
get println from std::io
get len from std
get pow, mod, factorial, fibonacci, is_prime from std::math
get PI from std::math::consts
fn collatz(int n)
{
dec int steps = 0
while (n != 1)
{
if (mod(n, 2)? == 0)
{
n = n / 2
}
else
{
n = n * 3 + 1
}
steps += 1
}
return steps
}
println(factorial(10)?) // 3628800
println(fibonacci(15)?) // 610
println(is_prime(97)?) // true
println(collatz(27)) // 111
dec float r = 5.0
println(PI() * pow(r, 2.0)?) // 78.53981633974483
Statements are separated by newlines. Semicolons (;) are optional and can be used as an alternative statement terminator.
All keywords have Arabic equivalents (e.g. دالة for fn, لكل for for, بينما for while, أرجع for return). Identifiers may freely mix Arabic and Latin characters.
The pipe operator |> chains function calls left-to-right. With get to_upper from std::str, "hello" |> to_upper() becomes "hello".to_upper().
Installation
Via install script (recommended)
Prebuilt binaries are published for every release. The install script downloads the build you pick (or the latest stable) and puts it on your PATH.
Linux / WSL (installs to $HOME/.local/bin; set RL_INSTALL_DIR to override):
curl -fsSL https://raw.githubusercontent.com/rl-lang/rl-lang/main/install.sh -o install.sh
bash install.sh
Android (Termux) - works the same way on aarch64 devices (install script detects Termux and downloads the Android build):
curl -fsSL https://raw.githubusercontent.com/rl-lang/rl-lang/main/install.sh -o install.sh
bash install.sh
Non-interactively (installs the latest stable build):
bash install.sh latest
Pick specific binaries (-b) or a pinned version instead:
bash install.sh -b rl,rlc,rlt latest
bash install.sh v2.2.0
Windows (PowerShell) (installs to %LOCALAPPDATA%\rl-lang\bin and adds it to your user PATH - restart your terminal afterwards):
Invoke-WebRequest https://raw.githubusercontent.com/rl-lang/rl-lang/main/install.ps1 -OutFile install.ps1
.\install.ps1
The installer lets you pick which binaries to install: rl, rlc, rlt, rlrepl, rlsp, rldocs, rlm.
From source
git clone https://github.com/rl-lang/rl-lang
cd rl-lang/crates/rl-cli
cargo build --release
# binary at target/release/rl
Via cargo install
cargo install rl-cli
Via releases
from releases you can choose nightly builds or the latest build
Usage
# check available commands
rl --help
# start a new project
rl new example-project
# in project root
rl dev # run project
rl run src/main.rl # run file directly
rl check # type-check only
# standalone binaries
rlc compile src/main.rl # compile to .rlc bytecode
rlc run src/main.rl # lex+parse+check+compile+run
rlt src/main.rl --compile # transpile to C and compile
rlrepl # interactive REPL
rldocs --tui # browse docs in TUI
rlsp # LSP server for editors
# package manager
rl pm install some-package
rl pm list
# toolchain manager
rlm install latest
rlm list
Documentation
Full language reference and stdlib documentation is available on the wiki, or offline:
rldocs io # look up a stdlib module, concept, or tutorial
rldocs --tui # browse docs in TUI
Editor support
VS Code
- Install the rl-lang extension for syntax highlighting in
.rlfiles. - Install the rl-lang runner extension to run and check files from the editor.
- Install the rl-lang LSP extension for diagnostics and hover.
Tree-sitter
A Tree-sitter grammar is available at rl-lang/tree-sitter-rl for editors that support it (Neovim, Helix, Zed, etc.).
Benchmarks
Criterion benchmarks live in crates/rl-benches. Run with:
cargo bench
Development
cargo test --all-features # full test suite
cargo clippy --all-targets --all-features -- -D warnings # lints (CI gate)
cargo bench # criterion benchmarks
Feature flags:
| Flag | State | Description |
|---|---|---|
vm |
On by default |
Bytecode VM backend |
repl |
On by default |
Interactive TUI REPL |
docs |
On by default |
Documentation tooling |
docs-tui |
On by default |
Interactive TUI mode for docs |
pm |
On by default |
Package manager |
cc |
Off by default |
C transpiler backend (rlt) |
lsp |
Off by default |
Language server (rlsp) |
debug |
Off by default |
Logging and debugging |
Per-module std feature flags (all on by default, disable for custom builds):
std-array, std-audio, std-bitwise, std-c, std-cli, std-collections, std-core, std-crypto, std-debug, std-fs, std-gui, std-http, std-io, std-math, std-net, std-path, std-process, std-random, std-result, std-serialize, std-string, std-terminal, std-time, std-types
Contributors
License
Licensed under either of MIT or Apache 2.0 at your option.
Dependencies
~5–11MB
~218K SLoC