Zig is a modern, general-purpose systems programming language with a clear and pragmatic mission: to be a robust, optimal, and maintainable replacement for C. Its influence on Ribbon is significant, particularly in its formalization of modern C programming methodologies and its unwavering commitment to explicitness and developer control.
What We Admire and Share
Zig’s design philosophy is exemplary in its elevation of the “unwritten rules” and hard-won knowledge of experienced C programmers into first-class language features.
-
Making Implicit Knowledge Explicit: This is Zig’s greatest contribution. Where C relies on programmer discipline, Zig uses the compiler to enforce correctness. The most prominent example is its approach to memory management. The concept of allocator passing, a pattern used by expert C programmers, is a core, explicit part of Zig’s standard library. This prevents entire classes of bugs and makes code more modular and testable. Ribbon’s effect-based Composable Allocation Strategies are a direct evolution of this same core principle.
-
First-Class C Interoperability: Zig’s ability to directly import C headers (
@cImport
) and seamlessly link against C libraries is revolutionary. It treats C as a peer, not a foreign entity that requires complex bindings. Ribbon shares this goal wholeheartedly and aims for its C and Zig interoperability to be just as effortless. -
The Integrated Build System: The Zig build system is a monumental achievement. It replaces a fragile ecosystem of external tools like
make
and shell scripts with a single, declarative, and cross-platform way to build projects. This inspired Ribbon’s own Toolkit API approach, where the toolchain itself is a modular and extensible component of the platform.
The Philosophical Divergence
While Ribbon shares Zig’s commitment to safety and control, our philosophies diverge on who should be responsible for defining the boundaries of a system.
-
In Zig, the “walled garden” is constructed by the language designer. The rules are strict, universal, and baked into the syntax and semantics of the language. There is one correct way to handle errors, manage memory, and structure code. This is an incredible strength, as it guarantees a high degree of clarity, discipline, and maintainability for any project built in Zig. The type system is deliberately kept simple to favor explicitness and avoid hidden complexity.
-
In Ribbon, the power to construct the “walled garden” is given to the platform architect. Ribbon provides a more flexible, dynamic core language and a highly advanced type system. The platform developer then uses these powerful tools: Algebraic Effects, Type Kinds, Phantom Types, and customizable syntax; to define the precise safety guarantees, capabilities, and even DSLs for their specific ecosystem.
This means that while Zig offers one set of extremely well-designed safety rules for everyone, Ribbon allows you to create custom-tailored safety rules for your application’s users. We allow for more freedom at the language level, but use our advanced type system to provide even stronger, more domain-specific static guarantees.
A First-Class Friend
Ribbon does not view Zig as a competitor, but as a close philosophical sibling and a first-class FFI friend. The reference implementation of the Ribbon compiler and runtime is currently written in Zig, a testament to its power and suitability for building robust, high-performance software. Our goal is for the interoperability between Ribbon and Zig to be just as seamless as our interoperability with C, allowing developers to leverage the strengths of each language in a single, cohesive project.