# Cool, new language for 2020

A lot of new programming languages pop up here and there. It’s a very interesting moment to pick a new one up. The ones I’m interested in are Rust, Nim and Zig.

Rust? Might be a good choice but it’s intimidating. I’m not convinced yet that what it brings to the table justifies its difficulty… Nim is pretty cool. Don’t have that much experience writing Nim though. It has a garbage collector, which you can turn off and use your own memory management system. I’m not a fan of garbage collection. Zig? C without its problems. At least that’s how it markets itself. I’m intrigued. There is actually a lot of interesting things Zig does. I’d like to mention some of those here and explain we Zig is my pick for what to learn 2020 edition.

## Zig’s features

### Simplicity

Small, simple language. Focus on debugging your application rather than debugging your programming language knowledge.

That’s an interesting way to put problems programmers face. Simplicity is always good. Good design is always less, not more. What’s nicely put in this quote is the debugging your language knowledge part. That’s a big part of the job. How well do you understand consequences of each line of your code? You write a line and you make a lot of assumptions. Those are the mix of your codebase knowledge and the programming language knowledge. We have to test those assumptions again and again. While assumptions regarding the code you depend on always need testing, assumptions regarding the language… shouldn’t really be an assumptions. You should know the tools of your craft well. It’s very hard to know a language inside and out. The simpler the language is, the easier it is to be correct in your assumptions.

### Compile time magic

Most of the languages bring their own take on meta programming. That’s the logic around your logic. For C that’s the preprocessor parsing macros. Nim has a very powerful meta programming features with its preprocessor. Zig?

There is no hidden control flow, no hidden memory allocations, no preprocessor, and no macros.

No preprocessor, no macros. You want simple? Remove, don’t add. Zig doesn’t need a preprocessor layer. It’s intelligent enough to look at the code and decide if something can be evaluated during compilation. When it’s not, then you can help it with a comptime keyword.

### Zig’s compiler

Zig’s compiler seems to be a very powerful tool. It has its own caching system, it can easily cross compile for other architectures and it’s a very powerful C/C++ compiler… Recently the creator of the language posted an article about zig cc, here. The ease with which this compiler can pick a different architecture or libc implementation is pretty impressive.

### Smaller goodies

• something I’ve also noticed in Nim is an idea of embedding a file in the source code during compilation. For Zig you can use the @embedFile built-in function. That means you can skip opening a file and reading its contents during run-time.
• pointers can’t be NULL. It seems a lot of newer programming languages embrace the idea of optionals. Optionals can be either NULL or something, where something can be any type. The idea here is to take NULL out of the set of possible values that a pointer can store. Normally NULL is a valid value for a pointer, even though technically NULL is not a value… it’s the lack of value. Optional wraps a pointer in a question: does the pointer point to something valid?. NULL means there is nothing valid there. In Zig you basically can’t assign NULL to a pointer because the types don’t match. NULL is a value reserved for an Optional.
• parameters of a function are immutable. Just a few days ago I had to work with a code which copied the passed parameters into local variables and then modified the original parameters… You can do crap like that with Zig.

## Future of Zig

Is it worth learning Zig? Will it exist in a year or two? Will it reach a wider audience? It’s hard to tell… the creator seems to be committed. You can support him on Patreon.

Zig is open source. That means that someone else can pick up if the creator chooses to leave the project. It’s hard to keep a project like this if its creator leaves. Zig being open source is undeniably a great thing.

Will you get a job as a Zig programmer? Not any time soon. You can see Rust job opportunities pop up here and there. You can’t expect that to happen for Zig. Certainly not before the language gets close to 1.0 release… and that will be just the start of gaining some proper recognition.

I chose Zig because I like C. Since Zig wants to be C without its drawbacks it seems like it might be an enjoyable direction for me. No question I’ll learn a lot. Programming is not about languages the same way drawing is not about pencils. Learning a new language gives you new perspectives.