Thoughts on Zig
2024-09-30
Distributed-Systems · Programming · Programming · Raft · Swim · Zig · Zig · Ziglang
2 minutes
In continuation with my previous post about the new systems programming languages, I mentioned I was considering Zig as a potential complementary systems language to our main one, which is Go(lang). Well, for the past month or so, in my spare time, I tried writing something more substantial in it to understand the language more. For some time now, I’ve been “itching” to write something similar to Hashicorp’s memberlist library, but in a lower-level language for performance, smaller footprint and minimal network load. Now, I’ve used memberlist
before, and it is a superb piece of code, but I wanted something that supports a consistent leader across the whole fleet. It’s a requirement to a system I plan on building in the near future (more on this in a later post). My top choices were C, Rust, and Zig, and as I said, I took a liking to Zig due to its promised simplicity, so I wrote it in Zig. The project is called zgroup
, and you can check it out on GitHub if you’re interested. It’s still similar to memberlist
but with the added capability of electing a leader across the whole group. It uses both the SWIM Protocol, which memberlist
uses, and Raft’s leader election algorithm.
Anyway, so what do I think of Zig? I think it has a lot of promise. It still feels incomplete, which it is, especially the standard library. Which is expected of course for a < v1.0 software. But coming from C, and Go, I think Zig is the sweet spot for me between C++ and Rust. But I don’t think I will be introducing it to Alphaus anytime soon though; maybe when it’s tagged v1.0+, which I think is still years from now.