RC RANDOM CHAOS

Nimony: Next-Gen Nim Compiler With Borrow Checking and Incremental Builds

· via Hacker News

Original source

Nimony: A New Compiler for Nim

Hacker News →

Nimony is a compiler for Nim 3 that introduces borrow checking, explicit nilability, sum types, and checked generics alongside incremental and parallel builds. It generates native code for x86_64, ARM64, ARM32, AVR, and RISC-V without depending on LLVM or GCC, and can also target C, JavaScript, and WebAssembly. The runtime includes heap exhaustion protection and uses optimized automatic reference counting for memory safety.

The compiler enforces strong compile-time guarantees: array and string indexing requires contracts checked at call sites, with provably out-of-range accesses flagged as compile errors. For modules with the staticContracts feature enabled, all bounds must be proven statically with no runtime checks in the binary. Generics are type-checked at definition rather than instantiation, and sum types require exhaustive pattern matching. The borrow checker prevents mutation of borrowed values, catching classic aliasing bugs during iteration and other scenarios.

Nimony targets multiple domains: embedded systems benefit from independent code generation and memory safety, game developers get incremental builds and passive procs for state machines, and full-stack developers work in a single language from microcontrollers to browsers. The compiler uses NIF as an interchange format between pipeline stages, enabling custom validators and code generators for domain-specific extensions. Version 0.6.2 was released in September 2026.

Read the full article

Continue reading at Hacker News →

This is an AI-generated summary. Read the original for the full story.