DEV Community

Weekly Typed
Weekly Typed

Posted on • Originally published at weekly-typed.com on

First Thoughts on Zig - Getting Started and Learning Resources

First Thoughts on Zig - Getting Started and Learning Resources

This post originally appeared on Weekly Typed.

In January 2023, I delved into the Zig programming language. If that's unfamiliar, check out the website for a rundown of what it's about. The Road to Zig 1.0 is also a great talk by Andrew Kelley explaining why he created it. I had heard about Zig a while back but only got interested enough to learn it because the Bun runtime for Typescript/Javascript piqued my interest. And that project is written in Zig.

Anyway. Here are some initial thoughts I had trying to get started and learn the language.

Getting started

The getting started guide was beneficial. It was easy to install the zig compiler and toolchain on Mac (via Homebrew) and Windows (via Chocolatey).

I did run into one snag when installing extensions on VS Code. The guide mentions several options, but most people will probably want zls-vscode. I installed another extension by mistake, which only gave me syntax highlighting and a small amount of linting. Which is what the guide actually tells you if you read it. zls-vscode is a frontend for the Zig language service (zls). When you install it, you will be prompted to install zls. This gives you all the features of the other extensions and more.

Learning resources

Ziglings is a great way to learn the basics of the language. It is a repository with a series of one-file programs. At the top of each file, comments give you information about one concept in Zig. Each program is broken in some way related to that concept. Your goal is to fix it with the help of the comments.

There are a few things to know before going in.

First, Ziglings needs to be updated in places. Zig is not yet to version 1.0. So don't be too surprised if some field names of common types have changed, and Ziglings still needs to catch up.

Second, Ziglings only covers some things. Once you are done with it, give the docs a look. They are great and cover everything.

Because Zig is still so young, there are few other resources to learn from

Next

That's it for now. In a future post, I will discuss my thoughts on some features of Zig. Some of them are familiar, but Zig does them differently. Others are very unique.

  • Error handling
  • Optionals
  • Unions
  • Types as values
  • Comptime

Top comments (0)