Celebrations: Happy Thanksgiving to all our American readers!
Challenge accepted?!

Tired of C? New programming language Zig aims to be more pragmatic and readable

Jane Elizabeth
© Shutterstock / T.Dallas

Zig is a pragmatic, optimal, and safe alternative to C; it offers another alternative to those brave enough to try something new. Let’s see what it’s all about.

Sometimes, you get a little bored of the old favorites. C has been around for decades; maybe it’s time to try something new? And in Zig, developers have a chance to try out a new programming language that aims to be more pragmatic and readable than C.

Designed by Andrew Kelley, Zig is supposed to be more pragmatic than C. This is something of an ambitious task, to say the least. Or, as Kelley puts it, “This is like trying to be more evil than the devil himself.”

So, what does Zig bring to the table in this first beta release? C is one of the grand old dames of programming; it’s going to take a lot for a challenger to push it off its throne.

Zig was intentionally designed for a number of priorities. First and foremost: pragmatism. The whole point of choosing one programming language over another is that it works better for your goal. And so, Zig is intended to be that kind of language.

Zig’s code is optimal and expressible as well as safe. And, importantly, it’s readable, avoiding difficult syntax whenever possible. This language encourages developers to be explicit and verbose for the sake of making the code readable for humans as well as computers.

With or without (existing) C (code)

Zig can be used to integrate closely with existing C code, or independently, without libc. It’s a small, simple language that lets you focus on debugging your own code rather than reading up on the intricacies of whatever programming language you’re using.

Edge cases matter in Zig with manual memory management. You actually have to support corner cases and out-of-memory situations. In Zig, you must explicitly handle or ignore the error in some way. (You should probably handle them. Users are “encouraged to handle memory errors gracefully through syntactic sugar”.)

Additionally, Zig promises a fresh take on error handling that resembles well-written C error handling. Except Zig does away with the boilerplate and verbosity.  Also, Zig lacks a preprocessor. Instead, Zig has a few features that carefully allow you to accomplish whatever a preprocessor would.

Other features include:

  • Debug mode optimizes for fast compilation time and crashing with a stack trace when undefined behavior would happen.
  • ReleaseFast mode produces heavily optimized code. What other projects call “Link Time Optimization” Zig does automatically.
  • ReleaseSafe mode produces optimized code but keeps safety checks enabled. Disable safety checks in the bottlenecks of your code.
  • Export functions, variables, and types for C code to depend on. Automatically generate .h files.
  • Nullable type instead of null pointers.
  • Cross-compiling is a first-class use case.
  • Friendly toward package maintainers. Reproducible build, bootstrapping process carefully documented. Issues filed by package maintainers are considered especially important.


Zig works on Linux, Mac, and Windows. Since this is a new language, developers are wanted to help with expanding the language. Interested in trying this new language out? Find it here and on GitHub.

Jane Elizabeth
Jane Elizabeth is an assistant editor for JAXenter.com

comments powered by Disqus