jordanhubbard/nanolang

A tiny experimental language designed to be targeted by coding LLMs

What it solves

NanoLang is a minimal programming language designed specifically to be written by machines and read by humans. It addresses the problem of ambiguity in programming languages and the lack of integrated testing by enforcing unambiguous syntax and requiring test blocks for functions.

How it works

NanoLang uses a formally proved core (NanoCore) with semantics verified in Coq to ensure type soundness, progress, and determinism. It offers two primary execution paths: transpilation to C for native performance or execution via its own stack-based virtual machine (NanoISA) which isolates dangerous external calls in a separate process. The language features automatic memory management via reference counting, algebraic effects for explicit side-effect handling, and a compiler that performs constant folding, dead-code elimination, and profile-guided inlining.

Who it’s for

It is intended for developers who need a formally verified, unambiguous language that is easy for AI/machines to generate and for humans to maintain, as well as those interested in formal verification and language design.

Highlights

  • Formally Proved Semantics: Core semantics are mechanically proved in Coq with no axioms or admitted sub-cases.
  • NanoISA VM: A stack-based virtual machine with ~94 opcodes and a co-process model for FFI isolation.
  • Multi-Target Compilation: Supports transpilation to C, WebAssembly, LLVM IR, PTX/CUDA, and RISC-V assembly.
  • Shadow Tests: Enforces the use of shadow test blocks to ensure function coverage.
  • Advanced Language Features: Includes algebraic effects, async/await (via CPS state machine), rich pattern matching, and type inference.
  • IDE Support: Ships with its own Language Server (LSP) and Debug Adapter (DAP) for VS Code integration.