Nish
Nish — Native Instruction Static Host — compiles a strict,
static subset of TypeScript ahead of time to native code. You write .ts
files with the syntax you already know; the compiler checks that every value
has one fixed type and layout, turns the program into LLVM IR, and LLVM turns
that into a small executable for x86_64, ARM64 or WebAssembly. There is no
interpreter, no garbage collector and nothing to ship beside the binary.
Nish is pre-alpha. Do not use it in production. It is an early experiment, not a tool to build on yet: expect miscompilations, crashes, missing features and confusing diagnostics. Until 1.0 the language, the command-line flags and the output all change without notice, often between one minor release and the next. If you try it, pin an exact version and read the changelog before you upgrade.
Why Nish
The TypeScript you know
Arrow functions, classes, interfaces, discriminated unions, generics and
modules, in .ts files your editor already understands.
One binary, nothing beside it
LLVM builds a small executable for x86_64, ARM64 or WebAssembly. No runtime to install, no interpreter, no JIT warming up.
No garbage collector
The compiler decides where every value lives and when its memory is reused, so nothing pauses the program to scan for garbage.
Errors you can act on
What only makes sense at run time — any, exceptions, prototypes — is a
compile error with a stable code and a message saying what to write instead.
Checked by default
Integers have fixed widths, and arithmetic that overflows stops the program with a message rather than wrapping round.
A way back out
A Nish module is still TypeScript: the nish package runs it in Node or a
browser, and a native build can be called from Node, WebAssembly or C.
A first look
const sumOfSquares = (limit: i32): i32 => {
let total = 0;
for (let i = 1; i <= limit; i++) {
total = total + i * i;
}
return total;
};
export const main = (): i32 => {
console.log(`1² + … + 10² = ${sumOfSquares(10)}`);
return 0;
};
i32 is a 32-bit integer, export const main is where the program starts and
its return value is the exit status, and total + i * i is checked: if it
overflowed, the program would stop with a message rather than wrap round.
Save it as squares.ts and nish run squares.ts prints 1² + … + 10² = 385.
Explore the docs
Getting started
Install Nish, build and run a first program, and see what changes coming from TypeScript.
The language
Types, functions, unions, errors and Result, generics, modules, memory and
the rest of what a program is written in.
Using Nish
The command line, the standard library, threads, networking, databases, the sandbox and going back to TypeScript.
Reference
Every module and builtin of the library, the compiler's flags and diagnostics, and the language specification.
Every page
- Getting started — install Nish, build and run a first program, and see what changes coming from TypeScript.
-
The language — types,
functions, control flow,
arrays and strings,
classes and interfaces,
destructuring,
discriminated unions,
errors and
Result, maps and sets, generics, modules, memory, function references, regions, vectors (SIMD) and async functions. - Using Nish — the command-line interface, the compatibility dialect, the standard library, calling Nish from other languages, threads, shared memory between processes, SQLite, terminal programs, the sandbox, compression and going back to TypeScript.
- Networking — sockets, Unix sockets, verifying TLS certificates, the TLS client, HTTP routing, an API server, an async server, one server for HTTP/1.1, 2 and 3, WebSocket, the HTTP client, calling other services, PostgreSQL, password hashing, authentication tokens (JWT) and tokens from an OpenID Connect issuer.
This guide teaches; it is not the definition of the language. That is the language reference, and each page here links the section of it that governs what the page describes. Where the two disagree, the reference is right and the guide has a bug.