Show HN: Nibble

TL;DR

Nibble is a minimalistic, C-like systems programming language created in C to demonstrate LLVM IR generation without external dependencies. It supports core features like recursion, structs, and pointers, and includes graphical demos. The project is now complete, with some limitations noted.

A developer has introduced Nibble, a C-like systems programming language built entirely in 3000 lines of C, designed to demonstrate LLVM IR generation without relying on external dependencies or heap allocations.

Nibble supports features such as defer, recursion, integer, floating-point, boolean types, structs, GLSL-like struct operators, pointers, function pointers, branching, loops, and type checking. It also offers basic C interoperability through generic pointers and provides reasonable error messages. The project includes four graphical demos: two multithreaded shader-toy renditions, a red-black tree implementation, and a simple game programming setup.

The compiler processes code top-down in a single pass and freely allocates on the stack, even within loops. This design simplifies the front-end but can cause stack overflows with certain Clang optimizations, a known limitation acknowledged by the developer. To run the demos, users must install SDL2, Clang, then run ‘make’ to compile and execute the demos. Clang compiles ‘main.c’ into the Nibble compiler, which then compiles and runs the demos.

The project is considered momentarily complete by its creator, who notes that exploring stack save/restore techniques is a future consideration. The developer also mentions that the current design choice simplifies readability but introduces some technical constraints.

Why It Matters

This development matters because Nibble exemplifies a minimal, self-contained approach to systems programming language design, emphasizing LLVM IR generation without external dependencies. It provides a practical example for compiler developers and those interested in low-level programming, while its graphical demos showcase its potential for graphics and game development. The project’s limitations highlight ongoing challenges in compiler optimization and stack management.

Amazon

SDL2 development kit

As an affiliate, we earn on qualifying purchases.

As an affiliate, we earn on qualifying purchases.

Background

Traditional systems programming languages like C and C++ rely heavily on external dependencies and complex compiler toolchains. Nibble aims to demonstrate that a minimalistic, self-contained approach is feasible, even for features like IR generation and graphics. The project builds on existing compiler research and experimentation, with the developer noting that it’s a proof of concept rather than a production-ready tool. Its release aligns with ongoing interest in compiler design, LLVM IR, and lightweight language implementation.

“Nibble compiles top down in a single pass and allocas freely, even within loops, by design.”

— the developer

“I have been meaning to explore stacksave/stackrestore but my LLVM curiosity has more or less been satisfied.”

— the developer

LLVM Techniques, Tips, and Best Practices Clang and Middle-End Libraries: Design powerful and reliable compilers using the latest libraries and tools from LLVM

LLVM Techniques, Tips, and Best Practices Clang and Middle-End Libraries: Design powerful and reliable compilers using the latest libraries and tools from LLVM

As an affiliate, we earn on qualifying purchases.

As an affiliate, we earn on qualifying purchases.

What Remains Unclear

It is not yet clear how Nibble will perform in more complex or real-world applications, or whether its limitations with stack overflows can be effectively addressed in future iterations.

C Programming Language, 2nd Edition

C Programming Language, 2nd Edition

As an affiliate, we earn on qualifying purchases.

As an affiliate, we earn on qualifying purchases.

What’s Next

The developer plans to explore advanced stack management techniques like stacksave/stackrestore and possibly extend Nibble’s features. Future updates may address current limitations and improve stability, especially regarding compiler optimizations.

Competitive Programming 4 - Book 2: The Lower Bound of Programming Contests in the 2020s

Competitive Programming 4 – Book 2: The Lower Bound of Programming Contests in the 2020s

As an affiliate, we earn on qualifying purchases.

As an affiliate, we earn on qualifying purchases.

Key Questions

What are the main features of Nibble?

Nibble supports recursion, structs, pointers, function pointers, branching, loops, type checking, and basic C interoperability. It also includes graphical demos demonstrating its capabilities.

How does Nibble compile code?

It compiles top-down in a single pass, allocates freely on the stack, even within loops, which simplifies the front-end but can cause stack overflows with certain Clang optimizations.

What are the graphical demos included?

Two multithreaded shader-toy demos, a red-black tree implementation, and a basic game programming setup.

Is Nibble ready for production use?

No, it is primarily a proof of concept and experimentation platform. It has limitations, particularly with stack overflows and certain compiler optimizations.

You May Also Like

Celestial Insights: Taylor Swift's Cosmic Essence Unveiled

Fathom the enigmatic depths of Taylor Swift's cosmic essence and unravel the celestial influences shaping her captivating persona.

49ers Buzz: Breaking News & Player Highlights

Uncover the latest updates on the San Francisco 49ers' coaching decisions, player contracts, standout performances, and more that will keep you hooked for more.

Milwaukee's Cultural Festivities and Must-See Attractions

Adventure awaits in Milwaukee with its vibrant cultural festivities and iconic attractions – immerse yourself in a city bursting with art, heritage, and flavor!

Lady Gaga's Mysterious Engagement Rumors Unraveled

Nagging questions persist as Lady Gaga's silence on a diamond ring sparks intense speculation about her possible engagement to Michael Polansky.