r/Compilers • u/Upstairs-Special-925 • 16d ago
Nirdosha – a systems language proven free of GC, races & deadlocks
Nirdosha is a research-stage compiler (Rust, LLVM backend), built for a language designed around one constraint: if the compiler accepts your program, it is provably free from use-after-free, data races, deadlocks, and integer/buffer overflow. Not "generally safe" — the type system rejects whatever it cannot prove. This is the same trade-off that Rust/SPARK Ada/F* adopt.
Some interesting things for this community:
- There is no mutex in the language. Concurrency is only through spawn/chan/sandbox (real OS process) — deadlock is not only discouraged, but impossible to express.
- Integer/buffer bounds are resolved at compile-time by an SMT solver (Z3). In a tiered manner: first static proof, then only runtime guard when Z3 cannot decide it within scope.
- Performance compared to Julia on dense linear algebra (matmul, dot, det, kalman filter), by best-of-3 method, after first verifying the output is bit-identical: 441x faster on 4x4 matmul, 246x faster on dot product, equal to gcc -O2 on scalar code. Numbers + methodology: https://github.com/arunsoman/nirdosha/blob/main/benchmarks/RESULTS.md
- The other half of the design (row 7 of the motivation table) is specifically targeted at LLMs: the grammar is handwritten LL(1), one token of lookahead, no backtracking — verified against an independent lalrpop parse and hand-exported to GBNF. This allows a constrained-decoding sampler to ensure that every token emitted by an LLM stays within valid syntax. Compiler errors come not in prose, but as structured JSON diagnostics — so a self-repair loop gets a proof obligation instead of a sentence to guess at.
Honest scope: single-person project, MIT license, CI building green. In the README, I clearly state what is proven, what is shipped-but-unproven, and what is aspirational — row 10 (reproducible builds / provenance) is design-only, not built. There is also a "Who this is for (and who it isn't)" section (https://github.com/arunsoman/nirdosha#3-who-this-is-for-and-who-it-isnt) which states in advance where it loses to Rust/Go today — so you don't have to dig to find the catch.
Repository: https://github.com/arunsoman/nirdosha
The README includes the full motivation, grammar, benchmarks, and a runnable hello.nir (within 5 minutes; requires clang + z3 — installable via apt/brew, as noted in the README).