HN
Today

Show HN: Nibble

Nibble introduces a novel C-like systems programming language, notable for its LLVM frontend built in approximately 3000 lines of C. Its most striking features are the complete eschewal of both malloc and an Abstract Syntax Tree, opting for a single-pass compilation. This minimalist design, while presenting interesting technical challenges, captivated the Hacker News audience with its bold approach to compiler construction.

63
Score
11
Comments
#7
Highest Rank
9h
on Front Page
First Seen
May 14, 3:00 AM
Last Seen
May 14, 11:00 AM
Rank Over Time
2171013131412915

The Lowdown

Nibble is presented as a C-like systems programming language with a unique compiler implementation. The author, glouw, developed it as a demonstration of an LLVM Intermediate Representation (IR) generation approach that foregoes traditional methods like dynamic memory allocation (malloc) and an Abstract Syntax Tree (AST). The entire frontend is written in roughly 3000 lines of C, compiled in a single pass.

  • Language Features: Nibble supports core programming constructs including defer, recursion, integer, floating, and boolean types, structs (with GLSL-like operators), pointers, function pointers, branching, and loops. It also includes type checking and basic C interoperability via generic pointers.
  • Implementation Philosophy: The compiler is designed to compile top-down in a single pass, allocating freely on the stack (alloca) even within loops. This design prioritizes front-end simplicity and readability.
  • Demonstrations: The project includes four graphical demos showcasing Nibble's capabilities, ranging from multithreaded software renditions of ShaderToy projects to a red-black tree implementation and a basic game programming setup. These require SDL2 and Clang to run.
  • Author's Reflections: The author notes that the alloca-heavy approach can lead to stack overflows with certain Clang back-end optimizations, challenging their initial assumption that Clang would hoist all stack allocations. Despite this, they consider the project momentarily complete, having satisfied their LLVM curiosity.

Nibble stands out as an intriguing experiment in compiler design, pushing boundaries on resource constraints and design simplicity, albeit with acknowledged trade-offs in optimization behavior.

The Gossip

Minimalist Marvels and Compiler Constraints

Many commenters were deeply impressed by Nibble's audacious design, particularly its implementation in roughly 3000 lines of C without dynamic memory allocation (`malloc`) or a traditional Abstract Syntax Tree (AST). This constrained and single-pass approach was widely lauded as "wild" and "seriously impressive," showcasing a unique take on compiler construction and resource efficiency that resonated strongly with the HN technical audience.

Documentation Desires

While admiring the technical feat, some commenters expressed a desire for more extensive documentation and explanations. Specific requests included clarification on language features like `defer` and a deeper dive into the memory management approach, as these details were not immediately clear from the provided `README`.

GIF Gripes and Graphical Grace

The README's use of animated GIFs, while serving to visually demonstrate Nibble's graphical capabilities, also sparked a minor discussion regarding accessibility. Some users noted that continuously animating elements could be distracting for those with sensory processing issues. This led to comments about modern browser features designed to mitigate such distractions, alongside general appreciation for the project's logo and the featured shader work.