Show HN: Nibble

TL;DR

Nibble is a newly introduced C-like language focused on LLVM IR generation without external dependencies. It supports features like recursion, pointers, and graphical demos. Its development highlights new approaches to compiler design.

A developer has introduced Nibble, a C-like systems programming language built in 3000 lines of C, aimed at demonstrating LLVM IR generation without external dependencies or heap allocations. The project is shared on Hacker News, highlighting its design and capabilities.

Nibble supports a range of features including defer, recursion, multiple data types (integers, floats, booleans), structs, GLSL-like struct operators, pointers, function pointers, branching, loops, and type checking. It also offers basic C interoperability via generic pointers and produces reasonable error messages. The language is demonstrated through four graphical demos, which include multithreaded shader-like rendering, a red-black tree implementation, and a simple game programming setup.

The compiler compiles top-down in a single pass and uses allocas freely, even within loops, which simplifies readability but can cause stack overflows with certain Clang optimizations. The developer notes that the design intentionally favors simplicity over compatibility with some backend optimizations, and considers the compiler momentarily complete after exploring LLVM’s features.

Why It Matters

This development matters because Nibble represents an experimental approach to systems programming language design, emphasizing minimal dependencies and direct LLVM IR generation. Its graphical demos showcase practical applications and performance considerations, potentially influencing future compiler or language development. It also highlights ongoing challenges in balancing language simplicity with compiler optimization compatibility.

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.

Background

Developed by an individual developer and shared on Hacker News, Nibble builds on existing trends in language experimentation and LLVM-based compiler design. The project arises amid broader interest in minimal, efficient languages for systems programming and graphics programming. Prior efforts in similar domains include projects like Zig, D, and various LLVM front-ends, but Nibble distinguishes itself through its minimal C foundation and focus on IR generation without external dependencies.

“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

The Rust Programming Language, 3rd Edition

The Rust Programming Language, 3rd Edition

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 beyond the initial demos. The developer notes potential stack overflow issues with certain compiler optimizations, and broader community testing and feedback are still pending.

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.

What’s Next

Future steps include refining the compiler to handle more complex scenarios, addressing stack overflow issues, and potentially expanding documentation and community engagement. The developer may also explore deeper LLVM backend interactions and optimization strategies.

C++ Compiler Construction: Mastering Language Processing (Computer Science Fundamentals)

C++ Compiler Construction: Mastering Language Processing (Computer Science Fundamentals)

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 defer, recursion, various data types, structs, pointers, function pointers, branching, loops, type checking, C interoperability, and graphical demos.

How does Nibble generate LLVM IR?

It compiles in a single top-down pass, directly generating LLVM IR without relying on external dependencies or heap allocations.

What are the limitations of Nibble?

It can cause stack overflows with certain Clang optimizations and is currently limited to the features demonstrated in initial demos. Broader application testing is still needed.

Is Nibble suitable for production use?

Currently, Nibble appears to be experimental and primarily a proof of concept. Its stability and performance in production scenarios are yet to be established.

You May Also Like

New features in GCC 16: Improved error messages and SARIF output

GCC 16 releases with enhanced error diagnostics, hierarchical error messages, and advanced SARIF machine-readable output, aiding developers in debugging.

Building a web server in aarch64 assembly to give my life (a lack of) meaning

A developer creates a static HTTP server in Aarch64 assembly on MacOS, exploring low-level system calls and server mechanics without libraries.

macOS needs its grid back

A developer advocates for restoring macOS’s original grid-based virtual desktops, citing lost efficiency and spatial memory with recent updates.

Zig ELF Linker Improvements Devlog

Zig’s new ELF linker now supports fast incremental compilation on Linux, allowing rebuilds in milliseconds, with ongoing development for DWARF debug info.