Nyx is a compiled, statically typed systems programming language engineered to make high-level code effortlessly expressive without hiding the machine underneath it.
A single compiler model lowers to native C++20, WebAssembly (WASM ABI v1), Node.js, and Python through an authoritative typed intermediate representation (Typed HIR v1) with byte-identical native self-hosting.
Important
Nyx v4.0.0-rc.1 "Samsara" (4.0.0-rc.1) is the active release candidate. It validates compiler correctness, reproducible native self-hosting without Python runtime dependency, C++20/WASM targets, language ergonomics, and language server tooling. Microcontroller firmware has been decoupled to focus on an uncompromising semantic core.
MANIFESTO • LANGUAGE TOUR • ARCHITECTURE • TARGETS • BUNDLE ABI • VERIFICATION • INSTALL • TOOLING • DOCS
Nyx is a compiled, statically typed systems programming language engineered to make high-level code effortlessly expressive without obscuring the underlying hardware.
Most programming languages force an ultimatum: either surrender control to a heavyweight managed runtime, garbage collector, and bloated abstractions, or retreat into the manual ceremony, undefined behaviors, and boilerplate of legacy systems languages.
Nyx rejects this dichotomy.
High-Level Ergonomics Low-Level Machine Control
┌─────────────────────────────┐ ┌─────────────────────────────┐
│ • Expression-bodied syntax │ │ • Deterministic i64/f64 │
│ • Values from if & match │ ▲ │ • Zero-runtime cost defer │
│ • Linear pipe composition │ ────┼──── │ • Deterministic scope exits │
│ • First-class async Task<T> │ ▼ │ • Strict pointer-safe ABI │
│ • Unicode string transforms │ │ • No hidden GC stop-the-world│
└─────────────────────────────┘ └─────────────────────────────┘
▲ ▲
│ │
ONE UNIFIED COMPILER CONTRACT
Nyx is not a thin syntactic sugar over C, a grab-bag of transpiler macros, or an interpreter hiding behind runtime dispatch. Parsing, type checking, module resolution, and optimizations are enforced by a single, canonical, typed intermediate representation (Typed HIR v1). Target backends are strictly prohibited from reinterpreting program semantics: they act as faithful mechanical translators of a verified semantic model.
- Semantic Sovereignty: The language semantics are established by the HIR v1 contract. Backends serve the specification; the specification never bends to target convenience.
-
Correctness Before Feature Count: A feature does not exist until it survives the unbroken gauntlet:
$$\text{Syntax} \longrightarrow \text{Lexer} \longrightarrow \text{Parser} \longrightarrow \text{Type Checker} \longrightarrow \text{HIR v1} \longrightarrow \text{Verifier} \longrightarrow \text{Backend} \longrightarrow \text{Differential Parity}$$ - No Leaky Boundaries: When compiling to WebAssembly, memory and UTF-8 strings cross a versioned, pointer-free ABI without leaking raw pointers or allocator internals to host JavaScript/TypeScript.
- Reproducible Self-Hosting: The production compiler compiles itself. A native stage-1 binary compiles stage 2, and stage 2 emits byte-identical stage-3 C++ output. No Python runtime is required in production workflows.
- Scope Discipline: A language cannot excel everywhere simultaneously. The v4 line intentionally decouples embedded microcontroller targets to focus on absolute compiler precision across native binaries (C++20), modern web infrastructure (WASM/Node.js), and scientific tooling (Python/Rust).
Nyx scales seamlessly from zero-ceremony top-level scripts to high-assurance systems architecture without mode switching or dialect forks.
For quick automation, pipelines, or algorithm prototyping, no fn main() or boilerplate wrapper is required. Top-level statements execute sequentially:
#target cpp
let base_freq: int = 5000
let multiplier: int = 2
// Direct top-level execution with pipelines
base_freq * multiplier |> print
Functions can be expression-bodied, branching produces values, and data flows naturally through forward-piping operators:
fn classify(code: int) -> string =
match code {
200 => "ok",
404 => "not found",
500 => "internal error",
_ => "unknown"
}
fn clamp_score(score: int) -> int =
if score < 0 { 0 }
else if score > 100 { 100 }
else { score }
fn normalize_input(val: int) -> int =
val * 2
fn main() {
// Elegant pipe composition with string interpolation
let status = 200 |> classify
let score = 120 |> clamp_score |> normalize_input
print($"Request status: {status} | Adjusted score: {score}")
}
When writing performance-critical systems code, Nyx delivers structured safety without ceremony:
#target cpp
struct Build {
name: string,
score: int
}
trait Show {
fn show(self) -> string
}
impl Show for Build {
fn show(self) -> string {
return $"{self.name}: {self.score}"
}
}
// Typed, non-blocking Task primitive
async fn evaluate_metric(value: int) -> int {
// Explicit precondition gate: guarantees invariants early
guard value >= 0 else {
throw "Metric value cannot be negative"
}
return value |> transform_metric
}
fn transform_metric(v: int) -> int = v * 2
async fn main() {
let build = Build("production-host", 42)
// Guaranteed LIFO deterministic scope cleanup (RAII semantics)
defer print("[teardown] scope exited cleanly")
// Concurrent task scheduling and resolution
let task: Task<int> = evaluate_metric(build.score)
let computed_score: int = await task
// Explicit range iterations with loop control
for pass in 1..4 {
if pass == 2 { continue }
print($"Running verification pass {pass}...")
}
let result = Build(build.name, computed_score)
print($"Final artifact: {result.show()}")
}
Core v4 features: let/var/const, explicit set, guard ... else, defer, match, if/elif/else, for ranges, while, loop, try/catch/throw, async/await, Task<T>, pipelines (|>), structs, traits, implementations, in-file test blocks (test "name" { assert(...) }), null-safe navigation, string interpolation, and explicit unsafe boundaries. Complete grammar specification: docs/SYNTAX_SPEC.md.
Runnable Examples: Check out the
examples/directory for ready-to-run programs covering math scripts, DSP pipelines, null-safety, in-file test suites, memory inspectors, and foreign C++/Node.js/Python bindings.
The Nyx toolchain operates through an authoritative, deterministic middle-end:
NYX SOURCE CODE (.nyx)
│
▼
[ UTF-8 Lexer / Scanner ]
│
▼
[ Canonical Syntax Parser ]
│
▼
[ Dependency Graph & Semantic Type Checker ]
│
▼
┌───────────────────────────┐
│ TYPED HIR v1 BOUNDARY │ ◄── Single Source of Truth
│ (Canonical Deterministic) │
└───────────────────────────┘
│
┌──────────────────┼──────────────────┐
▼ ▼ ▼
HIR Verifier Dead-Code Elimination Deterministic Passes
│ │ │
└──────────────────┼──────────────────┘
│
▼
[ Capability-Gated Backend Emitter ]
┌─────────────┬─────────────┬─────────────┬─────────────┐
▼ ▼ ▼ ▼ ▼
C++20 Node.js Python 3 WASM ABI v1 Rust 2021
(Native) (ES2022) (Reference) (Wat/Wasm) (Preview)
Nyx does not depend on a host runtime. The production toolchain compiles itself through a hermetic bootstrap cycle:
stage-0 bootstrap (Python reference)
│
▼
native nyxc (stage 1) ──► generates stage-2 C++ ──► compiled to native stage 2
│
▼
emits byte-identical stage-3 C++
- No Python Dependency: The distributed
nyxcnative compiler performscheck,emit-cpp,compile, and targets queries independently. - Topological Module Resolution: Handles diamond dependencies, eliminates module duplicates, detects circular imports, and resolves symbols deterministically.
Nyx exposes multiple code-generation backends with explicit capability gating. Targets that cannot support a language feature fail at compile time with a clear diagnostic instead of silently producing deviant runtime behavior.
┌─────────────┬──────────────────────────────┬──────────────┬───────────────┐
│ Target │ Artifact │ Maturity │ HIR Authority │
├─────────────┼──────────────────────────────┼──────────────┼───────────────┤
│ cpp │ C++20 / Native Executable │ Stable │ Authoritative │
│ js │ ES2022 / Node.js Module │ Stable │ Authoritative │
│ python │ Python 3 Standalone / Script │ Stable │ Authoritative │
│ wasm │ WAT + WASM ABI v1 │ Beta │ Authoritative │
│ rust │ Rust 2021 Source / Crate │ Beta │ Authoritative │
│ react │ React 19 TSX Module / Hook │ Beta │ Tooling-Level │
│ asm │ x86_64 Assembly (Intel) │ Beta │ via C++ │
└─────────────┴──────────────────────────────┴──────────────┴───────────────┘
| Subsystem | Exact Compiler Guarantee |
|---|---|
| Source Standard | Strictly UTF-8 encoded .nyx files with 46 canonical v4 keywords. |
| Integer Semantics | Signed i64 with defined two's-complement overflow wrapping, integer division, and bitwise shifts. |
| Floating-Point | IEEE-754 binary64 with canonical cross-platform formatting for nan, inf, and -0.0. |
| String Architecture | UTF-8 sequences with embedded \0 safety, \uXXXX escapes, interpolation, and zero implicit normalization mutations. |
| Compilation Gate | Checked against Typed HIR v1 verifier; pass runs deterministically across all environments. |
| Native Toolchain | Zero-dependency emission compatible with standard Clang++ (≥14), GCC/G++ (≥11), or MSVC (≥2019/2022). |
Compiling for the web should not require manually orchestrating memory offsets, byte lengths, and pointer arithmetic in JavaScript. Nyx packages complete WebAssembly modules with type-safe host wrappers in a single command:
nyx bundle src/crypto.nyx --output dist/crypto
nyx bundle src/crypto.nyx --output dist/crypto --react| Generated Artifact | Purpose & Role |
|---|---|
<module>.wat |
Human-readable, auditable WebAssembly text representation |
<module>.wasm |
Optimized, standalone wasm32 binary payload |
<module>.mjs |
ES2022 loader with automatic memory resizing, string marshalling, and Promise caching |
<module>.d.ts |
100% pointer-free TypeScript declaration interface |
<module>.react.tsx |
Native React 19 client hook with Concurrent Mode / Suspense safety |
ABI v1 requires modules to export memory, __nyx_alloc(i32), __nyx_free(i32, i32), and __nyx_abi_version() -> 1. Strings cross the boundary as a packed 64-bit scalar (length << 32) | pointer. The generated JavaScript layer automatically invalidates views upon heap growth, releases input buffers inside finally blocks, and frees returned memory immediately after decoding.
'use client'
import { useCryptoModule } from './crypto.react'
export function VerificationWidget() {
const { hashToken, isReady } = useCryptoModule()
if (!isReady) return <p>Instantiating WASM engine...</p>
return <div>Digest: {hashToken("payload-secret")}</div>
}The generated Promise cache completely eliminates double-instantiation penalties under React Strict Mode.
Samsara RC1 is certified by a comprehensive automated test battery. We test language invariants across target boundaries under hostile conditions:
╔══════════════════════════════════════════════════════════════════════╗
║ NYX v4 CONFORMANCE BATTERY ║
╠══════════════════════════════════════════════════════════════════════╣
║ ║
║ Edge-case regression test suite ──► 138 / 138 PASS ║
║ Typed HIR corpus emission test ──► 162 / 162 PASS ║
║ Nyx/Python canonical HIR byte parity ──► 194 / 194 PASS ║
║ Cross-backend runtime execution parity ──► 3 × 138 PASS ║
║ Deterministic backend code generation ──► 3 × 10 PASS ║
║ Standard library HIR verification ──► 17 / 17 PASS ║
║ Bundle ABI allocation stress test ──► 100,000 PASS ║
║ Native self-hosting reproducibility ──► STAGES 1-2-3 PASS ║
║ Deterministic differential fuzz engine ──► 530 / 530 PASS ║
║ LSP JSON-RPC protocol compliance ──► 4 / 4 PASS ║
║ C/C++ native ABI interoperability ──► 5 / 5 PASS ║
║ Self-installers & VS Code VSIX verification ──► PASS ║
║ ║
╚══════════════════════════════════════════════════════════════════════╝
Compiler errors should instruct, not confuse. Nyx diagnostics feature precise source spans, context snippets, and machine-actionable hints indexed in ERROR_REFERENCE.md:
error[E1302]: ambiguous symbol collision
--> src/network/client.nyx:24:9
|
24 | use protocol.packet
| ^^^^^^^^^^^^^^^
|
= note: symbol 'packet' is exported by both 'core::transport' and 'protocol'
= help: qualify the import explicitly: 'use protocol::packet as WirePacket'
Standalone native installers are provided for Windows, Linux, and macOS. Releases bundle the precompiled native nyxc compiler.
Set-ExecutionPolicy -Scope Process Bypass
.\install.ps1Or install directly via the release script:
$env:NYX_RELEASE_TAG = 'v4.0.0-rc.1'; irm https://raw.githubusercontent.com/justsomeone-e/nyx/v4.0.0-rc.1/install.ps1 | iexchmod +x install.sh
./install.shOr install directly via curl:
curl -fsSL https://raw.githubusercontent.com/justsomeone-e/nyx/v4.0.0-rc.1/install.sh | NYX_RELEASE_TAG=v4.0.0-rc.1 bash| Target | Host Requirement |
|---|---|
cpp (Default) |
Any standard C++20 compiler: Clang++, GCC/G++, or MSVC cl |
js |
Node.js (≥18 LTS with ES2022 support) |
python |
Python 3.10+ |
rust |
rustc / Cargo (2021 edition) |
wasm |
None (Nyx bundles its own binary WAT/WASM assembler) |
Run the built-in diagnostic doctor to verify your environment:
nyx doctorModern languages demand exceptional developer tooling from day zero.
Nyx ships with a fully integrated, zero-telemetry local extension (nyx-language-support-4.0.0-rc.1.vsix):
- Language Server Protocol: Built-in JSON-RPC server powering syntax diagnostics, hover documentation, completion, and definition lookups.
- Persistent Execution Console: Windows executables run in an integrated persistent shell—never closing abruptly before you inspect output.
- One-Click Commands: Instant Run, Build, Check, and Doctor shortcuts with clean keybindings.
Install locally with:
code --install-extension nyx-language-support-4.0.0-rc.1.vsix# Initialize a new Nyx project workspace
nyx new telemetry_service
cd telemetry_service
# Run type checking and HIR semantic analysis
nyx check src/main.nyx
# Build and execute with the default native C++20 backend
nyx run src/main.nyx
# Compile an optimized standalone native release binary
nyx build src/main.nyx --target cpp --release
# Execute via the Node.js ES2022 backend
nyx run src/main.nyx --target js
# Emit standalone Intel-syntax x86_64 assembly (.s)
nyx build src/main.nyx --target asm
# Package for WebAssembly with TypeScript bindings
nyx bundle src/main.nyx --output dist/bundle --react
# Run native self-hosting compiler commands directly
nyxc check src/main.nyx
nyxc emit-cpp src/main.nyx -o dist/main.cpp
nyxc compile src/main.nyx -o dist/mainThe Nyx release lifecycle is bound to verifiable technical milestones rather than calendar estimates:
| Version | Codename | Conceptual Meaning | Core Architectural Milestone | Status |
|---|---|---|---|---|
v2.x |
— | — | Initial compiler pipeline, standard library, CLI baseline | Historical |
v3.x |
— | — | Bundle ABI, Unicode compliance, cross-backend parity | Historical |
v4.0.0-dev |
Maya | Illusion / Appearance | Microcontroller decoupling, typed HIR v1 expansion, self-hosting | Completed |
v4.0.0-rc.1 |
Samsara | Cycle of Existence | Cross-platform release candidate, verification battery, VSIX | Active RC |
v4.0.0-rc.2 |
Bodhi | Awakening | Target fixes & edge optimizations identified during RC1 soak | As needed |
v4.0.0-rc.3 |
Moksha | Liberation | Release-candidate lock without syntax additions | As needed |
v4.0.0 |
Nirvana | Absolute Stability | Long-term stable v4 language, toolchain, and ABI contract | Planned |
v5.0.0 |
Aether | Upper Medium | Portable C output, LLVM IR emitter, reference frontend | Future Target |
nyx/
├── compiler/ # Self-hosted compiler written in Nyx (Frontend, HIR Lowerer, C++ Emitter)
├── src/
│ ├── core/ # Stage-0 Lexer, Parser, Type Checker, Module Resolution, Diagnostics
│ ├── ir/ # Typed HIR v1 definition, serialization passes, semantic verifier
│ ├── codegen/ # Target emitters (C++20, JS, Python, Rust, WASM, ASM), Native Linkers
│ ├── self_host/ # Stage reproducibility & bootstrap orchestration
│ ├── stdlib/ # Capability-gated standard library modules
│ └── cli.py # Primary nyx CLI entrypoint
├── vscode-extension/ # VS Code extension (LSP client, syntax, themes, snippets, task runners)
├── tests/ # Regression suites, backend parity, differential fuzzing, ABI tests
├── tools/ # Reproducible release packagers, SBOM generators, audit scripts
├── docs/ # Specifications, language references, and internal decision records
├── assets/ # Official visual identity assets and animated architecture diagrams
├── install.ps1 # Native Windows installer script
├── install.sh # Native Linux / macOS installer script
└── VERSION # Single source-of-truth version declaration
| Resource | Scope |
|---|---|
GETTING_STARTED.md |
First project guide, basic workflows, and compiler flags |
INSTALLATION.md |
In-depth platform guide and native C++ compiler setup |
LANGUAGE_REFERENCE.md |
Exhaustive language manual: types, ownership, and syntax |
docs/SYNTAX_SPEC.md |
Formal EBNF grammar, expressions, types, and Task mechanics |
CLI_REFERENCE.md |
Complete CLI documentation: flags, options, and commands |
ERROR_REFERENCE.md |
Comprehensive catalog of compiler diagnostic error codes |
docs/internals/ROADMAP_AND_BACKEND_GATES.md |
Architecture decision records, RFCs, and release gates |
CHANGELOG.md |
Chronological version history and migration notes |
We welcome contributions from systems engineers, compiler authors, and language enthusiasts.
Before opening a pull request, verify that:
- Determinism is Maintained: Compiler output must be bit-for-bit identical across runs.
- HIR Contracts are Respected: Never emit target code directly from the AST; all transformations must pass through Typed HIR v1.
- Verification Battery Passes: All 138+ regression tests, 194 HIR parity tests, and 530 fuzz passes must succeed:
python -m unittest discover tests nyx self-host verify
- Diagnostics are Actionable: Error messages must carry precise spans and clear explanations.
The Nyx compiler, standard library, and associated tooling are licensed under the Apache License, Version 2.0.
Your code is your own.
- No Viral Restrictions: You are 100% free to license, distribute, sell, or keep proprietary any software, binaries, libraries, or WebAssembly modules you create with Nyx.
- Trademark Protection (Section 6): The Apache 2.0 license explicitly protects the Nyx name, logo, and brand against unauthorized commercial hijacking, misrepresentation, or false endorsement.
- Patent Grant (Section 3): Grants an explicit, perpetual patent license covering contributor patents to protect users and downstream developers.
See LICENSE for full legal terms.