The language that hosts itself

One language. Eight products. Zero dependencies.
A self-hosting compiled language with native performance and a complete web ecosystem.

Get Started GitHub
Syntax

What Nyx looks like

Clean, familiar syntax. Compiles to native code via LLVM.

fn handle_user(req: Request) -> Response {
    let id: String = req.params.get("id")
    return response_json(200, "{\"id\": \"" + id + "\"}")
}

fn main() {
    let app: App = app_new()
    app_use(app, mw_cors)
    app_get(app, "/users/{id}", handle_user)
    serve_app(app, 3000, 64)
}
$ redis-cli -p 6382

> CREATE TABLE events (id INTEGER PRIMARY KEY, name TEXT)
OK
> INSERT INTO events VALUES (1, 'deploy')
OK
> SELECT name FROM events WHERE id = 1
1) "deploy"
$ redis-cli -p 6381

> ENQUEUE jobs '{"task": "send_email", "to": "alice@example.com"}'
"msg_0001"
> DEQUEUE jobs
1) "msg_0001"
2) "{\"task\": \"send_email\"}"
> ACK jobs msg_0001
OK
fn handle_request(method: String, path: String,
                  headers: Array, body: String) -> Array {
    let hdrs: Array = ["content-type", "application/json",
                       "server", "nyx-http2"]
    return [200, hdrs, "{\"ok\": true, \"protocol\": \"h2c\"}"]
}

fn main() -> int {
    h2_serve(3004, 4, handle_request)
    return 0
}
Ecosystem

Eight products, one language

Everything that serves this website is written in Nyx.

NyxKV
Redis-compatible KV store. 52 commands, Pub/Sub, multi-tenant auth, binary persistence.
82K ops/s
nyx-serve
HTTP framework with middleware composition, JSON APIs, and cookie sessions.
9,971 req/s
nyx-proxy
HTTPS reverse proxy with TLS, SNI, health checks, rate limiting, access logs.
4,282 req/s
nyx-queue
Persistent message queue with ACK, automatic redelivery, and round-robin delivery.
3,252 msg/s
nyx-http2
HTTP/2 server with HPACK compression, binary framing, and stream multiplexing.
h2c mode
nyx-db
Embedded SQL database with custom parser, B-tree storage, transactions, persistence.
SQL engine
nyx-edit
Terminal text editor with selection, undo, search, clipboard, and raw mode I/O.
1091 lines
nyx-shell
POSIX interactive shell with pipes, redirects, variable expansion, history.
fork+exec
Playground
Try Nyx in your browser. Edit, compile, and run — no installation needed.
try it now
Performance

Native speed

Compiled to machine code via LLVM. Competes with C.

fibonacci(40)
0.87x C
primes(100K)
0.99x C
loop(100M)
= C
map(100K)
1.07x C
HTTP hello
73K req/s
Get Started

From zero to running in 30 seconds

1 — Install
$ curl -sSf https://nyxlang.com/install.sh | sh

Linux (x86_64, ARM64) · Requires Clang · ~10 seconds

Verify: $ nyx --version → Nyx v0.12.0

2 — Quick Start
Hello World
$ echo 'fn main() { print("Hello!") }' > hello.nx
$ nyx run hello.nx
Hello!
Create a project
$ nyx init myapp
$ cd myapp && nyx run
Hello from myapp!
Web server in 8 lines
import "std/http"

fn serve_req(request: Array) -> String {
    return http_response(200, "Hello from Nyx!")
}

fn main() {
    http_serve_mt(8080, 4, serve_req)
}
$ nyx run server.nx
# Open http://localhost:8080
3 — Examples
JSON API
REST endpoint with routing and JSON response
import "std/web"

fn get_users(req: Request, resp: Response) {
    response_json(resp, "[{\"name\": \"Alice\"}]")
}

fn main() {
    let app: App = app_new()
    app_get(app, "/api/users", get_users)
    serve_app(app, 3000, 16)
}
Key-Value Store
Connect to nyx-kv with the RESP protocol
fn main() {
    let conn: int = tcp_connect("localhost", 6380)
    tcp_write(conn, "SET name Alice\r\n")
    let resp: String = tcp_read(conn)
    print(resp)  // +OK
    tcp_close(conn)
}
File Processing
Read, parse, and filter file contents
fn main() {
    let content: String = read_file("data.csv")
    let lines: Array = content.split("\n")
    var count: int = 0
    for line in lines {
        if line.contains("error") {
            print("Found: " + line)
            count = count + 1
        }
    }
    print("Total: " + int_to_string(count))
}
Concurrent Tasks
Goroutine-style concurrency with channels
fn work(id: int, ch: Map) -> int {
    print("Worker " + int_to_string(id))
    channel_send(ch, id * 10)
    return 0
}

fn main() {
    let ch: Map = channel_new(2)
    thread_spawn(fn() -> int { return work(1, ch) })
    thread_spawn(fn() -> int { return work(2, ch) })
    let r1: int = channel_recv(ch)
    let r2: int = channel_recv(ch)
    print(int_to_string(r1) + ", " + int_to_string(r2))
}
Read the Book Try in Playground

31 chapters · Bilingual EN/ES · From basics to building databases

Package Manager

Manage your Nyx projects

Everything you need to create, build, run, and share Nyx projects.

Install & Update
Fresh install
$ curl -sSf https://nyxlang.com/install.sh | sh
  Nyx installed successfully!

Installs to ~/.nyx/ and links nyx to ~/.local/bin/nyx. Adds PATH to your shell profile automatically.

Update to latest
$ nyx update
Updating Nyx...
Rebuilding compiler...
Rebuilding package manager...
Nyx updated successfully.
nyx 0.12.0

Pulls the latest source and recompiles. Run this anytime to get new features and fixes.

Uninstall
$ nyx uninstall
Nyx has been uninstalled.
  Removed: ~/.nyx/
  Removed: ~/.local/bin/nyx

Completely removes Nyx from your system. Clean and reversible.

Create a project
Initialize
$ mkdir myapp && cd myapp
$ nyx init
Initialized project: myapp
  Created: nyx.toml, src/main.nx
  Build:   nyx build
  Run:     nyx run

nyx init creates two files: nyx.toml (project config) and src/main.nx (entry point).

Project structure
myapp/
  nyx.toml          # Project configuration
  src/
    main.nx         # Entry point (fn main)
  packages/     # Dependencies (auto-created)
  nyx.lock          # Lock file (auto-generated)
nyx.toml explained
# Every Nyx project has a nyx.toml at its root
[package]
name = "myapp"          # Project name (used as binary name)
version = "0.1.0"      # Semantic version
main = "src/main.nx"   # Entry point file
description = "..."    # Optional description
no_gc = false           # Optional: systems mode (no GC)

[dependencies]
nyx-kv = "*"            # From registry (github.com/nyxlang-dev/)
mylib = "https://..."  # From custom URL
Build & Run
Build a project
$ nyx build              # Compile (debug)
Building: myapp v0.1.0
  Compiling: src/main.nx
✓ Built: myapp

$ nyx build --release    # Compile with optimizations (-O2)
$ ./myapp                # Run the compiled binary
Build and run in one step
$ nyx run                # Build + execute (inside a project)
Hello from myapp!
Run a single file (no project needed)
$ nyx run hello.nx       # Compile and run a standalone file
Hello!

$ nyx hello.nx           # Shorthand — same result
Hello!

No nyx.toml needed. Perfect for scripts and quick experiments.

Dependencies
Add a package from the registry
$ nyx add nyx-kv
Adding package: nyx-kv
  Fetching: https://github.com/nyxlang-dev/nyx-kv
  Updated nyx.toml
Package 'nyx-kv' added.

Packages are fetched from github.com/nyxlang-dev/<name> by default and stored in packages/.

Add from a custom URL
$ nyx add mylib --from https://github.com/user/mylib
Package 'mylib' added.

Use --from to fetch from any Git repository.

Automatic resolution
$ rm -rf packages/  # Delete local packages
$ nyx build             # They get re-fetched automatically
  Resolving: nyx-kv
  Fetched: nyx-kv
✓ Built: myapp

Dependencies listed in nyx.toml are automatically resolved on build. The nyx.lock file records exact versions.

Command reference
Command Description
nyx initCreate a new project (nyx.toml + src/main.nx)
nyx buildCompile the project
nyx build --releaseCompile with optimizations
nyx runBuild and run the project
nyx run file.nxCompile and run a single file
nyx add <pkg>Add a dependency from the registry
nyx add <pkg> --from <url>Add a dependency from a custom URL
nyx infoShow project details
nyx updateUpdate Nyx to the latest version
nyx uninstallRemove Nyx from your system
nyx --versionShow installed version
Learn

The Nyx Book

31 chapters covering everything from basics to production systems. Bilingual EN/ES.

Basics
Variables, functions, control flow, structs, enums, pattern matching.
Advanced
Generics, traits, closures, iterators, concurrency, FFI.
Systems
Raw pointers, inline assembly, no-GC mode, networking, TLS.
Read the Book
Open source

Built in the open

Apache 2.0 licensed. Contributions welcome.

nyx
Compiler, runtime, stdlib, 318 tests.
nyx-kv
Redis-compatible KV store.
nyx-serve
HTTP web framework.
nyx-proxy
HTTPS reverse proxy.
nyxlang.com
Website and landing pages.