Why Zig could end C dominance
Zig tries to combine the security of Rust with the ease of C. The programming language can score with special features such as comptime – a keyword with the help of which code can be explicitly evaluated at compile time.
The programming language was created by Andrew Kelley back in 2016 and now seems to be gaining in popularity. According to the developer, Zig is “a more modern language that tries to absorb the best of those languages and offer comparable performance with a better, more reliable developer experience.”
Contents
When is Zig 1.0 coming?
While Zig hasn’t made it to version 1.0 yet, that could change in 2025, as Kelley confirmed in a roadmap update a few months ago. You just can’t rush art, he explained.
And Zig can indeed be compared to art, because as Jarred Sumner, the creator of Bun, revealed, Zig is “similar to writing C, but with better memory safety features in debug mode and modern features like Defer (similar to Go)”. The language has very few keywords, so it’s much easier to learn than C++ or Rust.
This puts Zig well on its way to replacing C, both as a portable low-level language and as the standard against which other languages are compared. Zig is currently used to implement the Bun.js JavaScript runtime as an alternative to Node.js.
In many other languages, such as Python, data must be specially transformed for C and C++ interoperability. Zig is much more modern because it can directly import C and C++ libraries thanks to the built-in Clang compiler.
The compiler can generate header files for this language in order to be able to use program parts written in Zig in C or C++. The output of Zig libraries is an .o file that can be injected directly into GCC.
- No hidden flow of control
- No hidden memory allocations
- No preprocessor, no macros
- First class support of an optional standard library
- Adjustable runtime security
- Code execution at compile time
Zig is an imperative, procedural, functional, object-oriented, modular, multi-paradigm language and helps programmers to write fast and clear code that can handle all error conditions. It is a modern approach to metaprogramming based on compile-time execution and lazy evaluation.
Loris Cro, a member of the Zig team, revealed to Fastly: “Zig has a very simple purpose: to be (at least) as efficient and portable as C, while circumventing all of its usability issues and limitations that C’s own (and adjacent) ecosystems have traditionally created do it.” In contrast to C, however, Zig does not need a runtime environment.
Editor’s Recommendations
Zig also differs from most other languages in its limited range of functions. Kevin Lynaghwho usually works with Rust, wrote: “The language is so small and consistent that after a few hours of learning I could load enough of it into my head to get the job done.”
He recently converted his keyboard firmware from Rust to Zig and found it was a language he could master.
Nathan Craddock, a C developer, could only agree with this opinion. Programmers seem to particularly like the smallest possible feature set because they find it advantageous when there is only one obvious way to do something.
Zig’s developers took this goal so seriously that Zig abandoned for loops for a while because they were seen as unnecessary syntactic elaboration of the already adequate while loops.
The error handling concept is also impressive. Because exceptions are simply returned and not thrown – for one simple reason: thrown exceptions are often misused as a hidden control flow.
Zig also needs a direct way to allocate memory. But there is no direct malloc. Memory allocation is left to the standard library and is done via a request to an allocator object. This is intended to prevent hidden allocations.
If you want to take a close look at Zig: On the Zig’s home page There is a learning area that allows anyone who wants to delve deeper into the subject.