Tooling & Debugging
Nyx treats tooling and debugging as first-class features, not afterthoughts. The compiler itself doubles as a language server, the runtime includes a time-travel debugger, and the standard library provides a built-in test framework and benchmarking.
Development Tooling
Language Server Protocol (LSP) — nyx-ls
The Nyx LSP server reuses the compiler's incremental analysis engine, guaranteeing 100% consistency between editor diagnostics and actual compilation errors.
- Real-time diagnostics — minimal re-typecheck of changed functions only, under 100ms
- Autocompletion — context-aware: struct fields, methods, traits, generic inference
- Hover — full type info, doc comments (
///), region/ownership annotations - Go-to-definition / Find references — across files and into dependencies via persistent symbol index
- Rename — safe, project-wide rename
- Inlay hints — inferred types, parameter names, lifetimes
- Code actions — "import missing module", "wrap in Option", "add mut"
Code Formatter — nyx fmt
Uses the lossless Concrete Syntax Tree (CST) to format code. Preserves intentional blank lines and custom line breaks while normalising indentation and spacing. Output is always idempotent.
Documentation Generator — nyx doc
Parses doc comments (///) and generates static HTML documentation with cross-referenced types, search, and syntax-highlighted examples.
Build System & Package Manager — nyx
| Command | Purpose |
|---|---|
nyx init | Scaffold a new project |
nyx add <pkg> | Resolve, fetch, and lock a dependency |
nyx build | Incremental compilation with file-hashing and caching |
nyx run | Build and execute in one step |
nyx test | Discover and run all @test functions |
nyx publish | Package and upload to the registry |
nyx install | Restore dependencies from lockfile |
The build system supports reproducible, byte-for-byte deterministic builds and cryptographic signing of artifacts.
Profiling
nyx build --profileinjects instrumentation- Runtime emits pprof-compatible CPU and memory profiles
- CI integrates with Grafana/Prometheus for long-term trend tracking
- Hardware performance counters (via perf/Instruments) exposed through
nyx bench --profile
Debugging
Time-Travel Debugger
When a Nyx program is run with nyx run --record, the runtime logs all non-deterministic events: I/O results, random numbers, task scheduling decisions, and thread interleavings. The recorded trace is fully deterministic.
nyx debug <trace> launches an interactive debugger (CLI or GUI) that can step forward and backward through execution.
- Reverse watchpoints — ask "when did this variable last change?" and get the exact instruction
- Call-stack inspection — works across
awaitpoints, showing the full asynchronous call chain - Task visualisation — graphical view of all live tasks, nurseries, and causal relationships
Because Nyx's region allocation is deterministic and borrow-checked, the trace only records external inputs—not every memory operation—so overhead is manageable.
Hot-Reload (Development Mode)
For rapid iteration in UI code, changed modules compile to a shared library and patch into the running process. The widget tree automatically re-executes its build methods while preserving local state (text inputs, scroll positions, animation controllers). On the web, the WASM module is hot-swapped via the JS bridge.
Structured Logging & Tracing
std.log provides tamper-evident, capability-aware logging. Logs can be enriched with cryptographic chain of custody for audit. The async runtime integrates with std.log so every spawned task carries a trace ID for correlating logs across concurrent operations.
Testing Framework
@testannotates test functions; tests run in parallel, each in a fresh memory region- Assertions:
std.test.assert_eq,assert_true,assert_throws @benchmarks benchmarks — multiple iterations, statistical regression detection, CI gating- Async tests are automatically awaited by the runner
- Test failures print structured diffs for complex data structures (via auto-derivable
Difftrait)
Unified Architecture
All these tools work together. The LSP server uses the same incremental compilation database that drives nyx build, and the debugger replays traces that the profiler can also analyse. You never leave the Nyx ecosystem to develop, test, debug, and deploy your application.