Show HN: Nibble
AIThis post was created with the assistance of artificial intelligence (AI).

TL;DR

FOR BUSINESS

Open a free Amazon Business account

Business pricing, bulk buying and tax-exempt orders.

Create a free account

As an affiliate, we earn on qualifying purchases.

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

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.

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.

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.

POOL SEASON

Pool season Picks

As an affiliate, we earn on qualifying purchases.

You May Also Like

Nidec confirms ‘suspected improper conduct’ over quality irregularities

Nidec announces suspected improper conduct related to quality irregularities, prompting investigation and stock price decline. Details remain under review.

Steve Jobs in Exile – New book on his years at NeXT Computer

A forthcoming book by Geoffrey Cain explores Steve Jobs’s years at NeXT Computer (1985-1997), highlighting his struggles, innovations, and lessons learned outside Apple.

Lady Gaga's Love Saga Unveiled

Witness Lady Gaga's love saga unfold, a captivating tale of passion, heartbreak, and enduring romance that will leave you spellbound.

Pokemon Go Outage

The popular mobile game Pokémon GO experienced a widespread outage, affecting players across the US. The cause and expected resolution time remain unclear.