Zig_familiarity += 5; I love this feeling

I decided to dive deep into Zig on the 26th of October 2024 with an approach I've stumbled across and got inspired by others over the years of learning languages. It is quite simple a process, read the language reference, use the standard library and it's docs, do some advent of code, do things you already know how to in other languages like writing http servers and web sockets. I'll try to provide some good reasons why this is quite effective, from my own meandering experience. Decided to write it today as I felt quite comfortable writing Zig today (18 days later). So I guess it works.

Reading the language reference

I'll be candid, I don't fully follow the language reference. But I think it's getting better as the years go by and I understand some underlying concepts better. I only understood about 30% of the go language spec but effective go is quite useful and easy to follow. I still use it to this day. So why read the spec if you only get about 30% of it. Couple of reasons, it helps build familiarity with the language and sometimes when you come across issues you know you read something about this in some section of the spec, you don't know exactly what it is, but you know there is a doc about this somewhere in the spec.

Standard library

As much as the language reference talks about the idiomatic way of writing code in the language, it only sticks for me when I see such code in the standard library. I don't read the standard library for the sake of it. Let's say, I want to write an http server. I'll look up http, see what it needs and follow the links on how to get them. This gets easier the more familiar I get with the standard library. It also helps me understand patterns in the doc that's commonly followed, in turn helping you find things easier. It was a bit of challenge for Zig compared to Go, as the examples in the doc were helpful. But this had the unforeseen benefit of trial and error.

Advent of Code

Advent of code questions are perfect for learning a new language. As you have to figure out how to open and read files for all the questions. Know how to do pattern recognition, string manipulation and so on. After about three questions, you get quite fluid doing simple things in the language. I'd highly recommend you give this a try. The questions are a lot of fun to solve too, which helps.

Writing Http servers and web sockets

As this is something I've done quite a bit of over the years, it's a good way to see how the language I'm learning does things differently compared to the ones I know. The underlying concepts are the same, so you really get to see the preferences of the language and design choices that were taken in writing the language.

Do it daily

This I find to be quite crucial especially early on in the process of learning something new. Even if some days you only have about five to ten minutes, write something simple, or move the problem you are stuck on forward just a little bit further. It solidifies the concepts you understand so that you don't have to relearn it. Most importantly it build momentum and you can see and feel the learning happening. Small wins like this are quite important early on, especially that learning something new can be quite uncomfortable.

You can replace steps and the order to fit your learning better. This just works for me. I've been writing Zig for the last two and a half weeks daily. Today, I felt a certain familiarity about the language, I was doing things without having to look up any docs. As an added bonus, I was able to go through the standard library and write an Http server, and I was surprised at how much I was understanding. It's such a lovely feeling, when something felt really uncomfortable just a few days ago but now seems doable. I've avoided the things that scare me the most at this point, like memory allocation. It was a conscious decision. I'll tackle it once I'm quite confident in the language, so that I'm not tackling too many things at once. Like syntax and concepts on memory. It's been a while since I did C and did any memory stuff.

Overall it has been an awesome experience to learn a new language again.