Introduction
Nio is a small programming language for writing fast, safe programs — especially back-end services. Types are checked before your program runs, and the compiler turns your code into a standalone native program, with no virtual machine or interpreter needed to run it.
The compiler, nio, is itself written in Nio. It produces LLVM IR and uses clang to build the final program, so clang is the only thing you need installed.
source.nio ──lexer──► tokens ──parser──► AST ──checker──► typed AST
│
codegen
▼
native binary ◄──clang── LLVM IR (.ll) + runtimeA taste
import 'json';
type Car {
String make;
int age;
String? owner; // optional field
}
int[] myArray = [2, 5, 4];
int sum;
forEach(myArray, element) {
sum = sum + element;
}
print(sum); // 11
Car myCar = {
make: "toyota",
age: 4
}
print(json.toText(myCar)); // {"make":"toyota","age":4}Highlights
- Checked before it runs. Every value has a type, and mistakes like passing text where a number is expected are caught by the compiler. Numbers are never silently converted from one type to another.
- Native programs.
nio buildproduces a single executable file you can copy and run. - No surprise nulls. A
Stringalways holds a string. When a value might be missing, you say so withString?, and the compiler makes you check before you use it. - Records and methods.
type Car { ... }declares a record with fields and methods. Records turn into JSON and back with one call. - Extending types.
type Truck extends Car { ... }starts from everythingCarhas, adds to it, and can replace methods withoverride. - Enums and unions.
enum Status { OK: 200, NOT_FOUND: 404 }names a fixed set of values, and aunionholds one of several kinds of value, with the compiler checking that you handle every kind. - Maps.
Map<String, int>stores values by key, keeps them in the order they were added, and returnsnullfor a missing key instead of crashing. - Functions as values. Functions can be stored in variables, passed to other functions, and remember the variables around them.
- Simple error handling. A function that fails returns
Error("..."). The compiler works out which functions can fail, errors pass up to the caller on their own, and you handle them withcatchwherever you choose. - Async without threads. Functions marked
asynccan wait for network, disk or timers withawaitwhile other work carries on, all on one thread. - A useful standard library. Text, arrays, maps, JSON, dates, files, paths, processes, regular expressions, networking, HTTP servers and clients, TLS, cryptography, math, random numbers, and a testing library.
- Packages.
nio getadds published code to your project, at exact versions checked against a hash on every build. - Tooling included. A formatter (
nio format), a test runner (nio test), a documentation viewer (nio doc), debugger support, and an editor language server (nio lsp).
Where to go next
- Installation — get the compiler running.
- Quickstart — the core of the language in a few complete examples.
- Basics — types, variables, and control flow.
- Function values — passing functions around.
- Errors — failing, passing errors on, and
catch. - Async and futures —
async,await, and callbacks. - Arrays and Maps — collections.
- Packages — using code other people published.
- The complete language reference, with every rule and edge case, is
specs.mdin the language repository.
Nio is at version 0.1. It is ready to try, but it may still change in ways that break existing code before 1.0 — see Versions and compatibility. A few features you might expect, such as loop labels and exponent number literals (1e3), are planned but not available yet. Some others were decided against, so you can plan around them: there are no generics, no threads (run several processes to use several cores), and no TLS server.