Clear rules,
free as a butterfly.
A compiled language with closed sum types, no null, and errors in the signature.
$ curl -fsSL https://nabi.sh | shmacOS (Apple silicon), Linux and FreeBSD. Or an archive.
> powershell -ExecutionPolicy Bypass -c "irm https://nabi.sh/install.ps1 | iex"Windows on x64 or arm64, in PowerShell. Or an archive.
What it checks for you
Every case of a sum type
A value is i32 | str | bool, and match has to handle all three. Leave one out, or add a variant later, and the compiler names the case no arm covers.
fn describe(v: i32 | str | bool) -> str {
match v {
n: i32 => f"integer {n}",
s: str => f"string {s}",
}
}
fn main() {
println(describe(true));
}$ nabi run Compiling describe (.) error[E0098]: non-exhaustive match on `bool | i32 | str`: `bool` not covered --> src/main.nabi:2:5 | 2 | match v { | ^^^^^^^^^ | = help: add `x: bool => ..` error: could not build describe (1 error, 0 warnings)
Values that may be missing
There is no null. A value that might not be there has the type T?, and you say what happens when it isn't: a default with ??, or a branch with if let.
fn find(xs: List<i32>, target: i32) -> usize? {
for i in 0..xs.len() {
if xs[i] == target { return i; }
}
none
}
fn main() {
let at: usize = find([70, 90], 90);
println(at);
}$ nabi run Compiling find (.) error[E0040]: mismatched types: `let at` expects `usize`, found `usize | none` --> src/main.nabi:9:21 | 9 | let at: usize = find([70, 90], 90); | ^^^^^^^^^^^^^^^^^^ | = help: `find([70, 90], 90)` may be none: write `find([70, 90], 90) ?? 0`, or `if let x = find([70, 90], 90) { .. }` error: could not build find (1 error, 0 warnings)
Errors you can see coming
A function that can fail says so with throws, and every call to it is marked try. Reading the code, you can see each place an error can come from.
fn parse_age(s: str) throws -> i32 {
let n: i32 = try s.parse();
if n < 0 { throw f"age {n} is negative"; }
n
}
fn main() {
let age = parse_age("-1");
println(age);
}$ nabi run Compiling ages (.) error[E0062]: this call can throw `any Error` and must be marked with `try` (`try f()`; `try? f()` / `try! f()` to drop / panic on the error) --> src/main.nabi:8:15 | 8 | let age = parse_age("-1"); | ^^^^^^^^^^^^^^^ error: could not build ages (1 error, 0 warnings)
Using a package
The packages the Nabi project publishes come with the toolchain: JSON and HTTP, tables, statistics, plots and more. Write use and run; nabi adds the package to your manifest, with no download and no network. Anything else on the registry is one nabi add <name> away.
- json JSON
- http HTTP client and server
- regex regular expressions
- toml TOML
- table data frames, CSV, Parquet
- stats statistics
- linalg linear algebra
- plot SVG and PNG plots
- optimize fitting and optimization
- ode differential equations
Browse packages.nabi-lang.org Guide, chapter 11: Modules and Packages
use json::parse;
let v = try parse("{\"lang\": \"nabi\", \"year\": 2026}");
println(v.get("lang")?.as_str() ?? "");$ nabi run main.nabi Added json ^0.1 (official) nabi
Programs to read
21 complete programs, each one built and run when the docs are checked.
All 21 examplesInstall
One toolchain: the compiler with its own code generator and linker, the package tool, a REPL, a Jupyter kernel, a language server and the official packages. Nothing else to install.
# macOS (Apple silicon), Linux, FreeBSD
curl -fsSL https://nabi.sh | sh
# Windows (x64, arm64), in PowerShell
powershell -ExecutionPolicy Bypass -c "irm https://nabi.sh/install.ps1 | iex"
# Nix
nix profile install github:nabi-lang/nabi| macOS | aarch64-apple-darwin | Apple silicon | .tar.xz24 MB |
|---|---|---|---|
| Windows | x86_64-pc-windows-msvc | x64, Windows 11 | .zip70 MB |
| Windows | aarch64-pc-windows-msvc | arm64, Windows 11 | .zip68 MB |
| Linux | x86_64-unknown-linux-gnu | glibc 2.34 or later | .tar.xz26 MB |
| Linux | aarch64-unknown-linux-gnu | glibc 2.34 or later | .tar.xz24 MB |
| Linux | x86_64-unknown-linux-musl | static, any distribution | .tar.xz26 MB |
| Linux | aarch64-unknown-linux-musl | static, any distribution | .tar.xz24 MB |
| FreeBSD | x86_64-unknown-freebsd | FreeBSD 14 or later | .tar.xz26 MB |
Checksums, other formats and cross-compilation targets: Download.
nabi auditreadsnabi.lockand reports each pinned package that a packages.nabi-lang.org advisory affects, with the advisory ID, summary, severity and the version to update to (for examplenabi update json). It exits 0 when nothing is affected, 1 when something is, and 2 when it cannot check, so CI can run it as a gate.--jsonprints machine-readable output,--ignore <ID>skips an advisory, and--offlineuses only the cached advisory list. The list is cached for an hour; without a network, an older cache is used with a warning. Path and git dependencies are skipped and listed as not checked.