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.

8-Bit Open Source Sorcerer - Programming - Sticker Graphic - Auto, Wall, Laptop, Cell, Truck Sticker for Windows, Cars, Trucks

8-Bit Open Source Sorcerer – Programming – Sticker Graphic – Auto, Wall, Laptop, Cell, Truck Sticker for Windows, Cars, Trucks

Vibrant Pixel Art Design: Showcase your love for retro gaming with our 8-Bit Sorcerer sticker, featuring a modern,…

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

StrongMocha News Group Unveils New Music Video Collaboration with Rhythm Failure & Burning Sands Festival

Rhythm Failure & Burning Sands Festival Release “Ambiance Trance Song” Music Video…

Is He Afraid to Lose You? Watch for These Signs

Yearning for reassurance? Discover signs like possessiveness and fear of disagreements that may reveal his hidden fears in the relationship.

How Cloud Services are Reshaping Business Operations: A Deep Dive

Explore the transformative impact of cloud services on modern business operations with our comprehensive analysis.

NYT and Vaping: How to Lie by Saying Only True Things

Analysis of a 2022 NYT article on teen vaping shows how carefully worded truths can mislead readers about the causes of lung injuries.