Skip to content
HN On Hacker News ↗

GitHub - glouw/nibble: Generating LLVM IR without malloc or external dependencies

▲ 102 points 25 comments by glouwbug 2w ago HN discussion ↗

Pangram verdict · v3.3

We believe that this document is fully human-written

0 %

AI likelihood · overall

Human
100% human-written 0% AI-generated
SEGMENTS · HUMAN 1 of 1
SEGMENTS · AI 0 of 1
WORD COUNT 228
PEAK AI % 0% · §1
Analyzed
May 14
backend: pangram/v3.3
Segments scanned
1 windows
avg 228 words each
Distribution
100 / 0%
human / AI fraction
Verdict
Human
Pangram v3.3

Article text · 228 words · 1 segments analyzed

Human AI-generated
§1 Human · 0%

Nibble is C-like systems programming language.

Nibble was written in 3000 lines of C to demonstrate an approach to LLVM IR generation without relying on external dependencies or heap allocations.

Nibble supports defer, recursion, integer, floating, and boolean types, structs (simply named types), GLSL-like struct operators, pointers, function pointers, branching, loops, type checking, basic C interoperability via generic pointers, and reasonable error messages.

Included are these four graphical demos demonstrating Nibble's ability. To try them out, ensure SDL2 is first installed, as well as Clang, and then run make. Clang will compile main.c and output the nibble compiler, and nibble will then compile and run the graphical demos. Of these four demos, two demos are multithreaded software renditions of popular shader-toy demos, one demo is a demonstration of a red-black tree implementation, and the final demo demonstrates a basic setup for game programming.

Thoughts Nibble compiles top down in a single pass and allocas freely, even within loops, by design. This simplified front-end design greatly improves main.c readability but causes stack overflows with lower (and sometimes even higher) clang back-end optimizations. I was under the impression clang's back-end optimizer would hoist all allocas to a function's top level, but so we learn in life. I have been meaning to explore stacksave/stackrestore but my LLVM curiosity has more or less been satisfied, and I deem this compiler momentarily complete.