Why is Zig so Cool?
by Nilo Stolte
Foreword
I can’t think of any other language in my 45 years long career that
surprised more than Zig. I can easily say that Zig is
not only a new programming language, but it’s a totally new way to write
programs, in my opinion. To say it’s merely a language to replace C or
C++, it’s a huge understatement.
In this article, I will present the features that I found to be most
seductive in the language, and I will also present a brief overview
about it. The goal is to present simple features for
programmers to quick start in the language. Be aware, though, that many
more features are affecting its acceptability in the industry.
The compiler
It compiles C and it cross
compiles
Probably the most incredible virtue of Zig compiler is its ability to
compile C code. This associated with the ability to cross-compile code
to be run in another architecture, different than the machine where it
is was originally compiled, is already something quite different and
unique. These features alone, completely
out-of-the-box, are causing an incredible impact in the
industry already. In spite of that what we want to concentrate on is how
to program in Zig and why should one choose Zig instead of any other
language.
Installing the compiler
Installing the compiler is quite simple. In Zinglang’s download page one
finds the compiler in several formats, depending on the processor or
OS:
On Windows 10, for example, one chooses the
x86_64 zip file and copy its decompressed content in
the desired directory. For example, in “Program Files”. I modified the
root directory name to “zig-windows-x86_64” because in this way I can
just copy another version of the compiler with no need to modify the
path in Path environment variable.
Next, one adds this root directory path to the Path
environment variable using Advanced System Properties (clicking on 1-4,
pasting path on 5, and clicking “OK” on 6-8):
