Developer glouw released Nibble, an experimental LLVM frontend compiler written in approximately 3000 lines of C that compiles code in a single pass without using malloc or building an abstract syntax tree. The project reached the front page of Hacker News on May 14, 2026, receiving 79 points and sparking discussion about minimalist compiler design.
Single-Pass Architecture Eliminates Traditional Compiler Stages
Nibble compiles source code top-down in a single pass, bypassing the multi-stage parsing and AST construction used by most modern compilers. This approach simplifies the frontend design and improves code readability by eliminating intermediate data structures. The compiler generates LLVM intermediate representation directly, which can then be compiled to native code through LLVM's backend.
The implementation avoids heap allocations entirely, instead using stack allocation aggressively—even within loops. This design choice eliminates the need for malloc and makes the compiler completely self-contained without external dependencies beyond LLVM itself.
Supported Features Include Structs, Pointers, and Type Checking
Despite its compact size, Nibble supports:
- Integer, floating-point, and boolean primitive types
- Structs with GLSL-like operators
- Pointers and function pointers
- Recursion and defer statements
- Branching and loops with compile-time type checking
- Basic C interoperability via generic pointers
- Error messages designed for developer clarity
The compiler includes four graphical demonstration programs: two multithreaded software renditions of shader-toy demos, a red-black tree implementation, and a game programming setup example.
Known Limitations and Design Tradeoffs
The aggressive stack allocation strategy can cause stack overflows with certain Clang backend optimization levels. The author acknowledges this limitation in the README, noting that "the IR isn't perfect" but considers the compiler "momentarily complete" as an educational demonstration of single-pass compilation techniques.
The project serves primarily as an educational resource for understanding compiler construction, demonstrating that LLVM IR generation can be accomplished without traditional compiler infrastructure. At roughly 3000 lines of C, the entire implementation remains readable and approachable for developers learning compiler design.
Key Takeaways
- Nibble compiles code in a single top-down pass without building an abstract syntax tree, generating LLVM IR directly in ~3000 lines of C
- The compiler uses zero heap allocations (no malloc) and has no external dependencies beyond LLVM itself
- Supported features include structs, pointers, function pointers, recursion, type checking, and basic C interoperability
- Four included graphical demos showcase multithreaded rendering and data structure implementations
- The aggressive stack allocation strategy can cause overflows with certain optimization levels, a known tradeoff acknowledged by the creator