I really love everything about zig except the language itself. The governance, the culture, all of it seem really cool, but reading <a href="https://ziglang.org/learn/why_zig_rust_d_cpp/" rel="nofollow">https://ziglang.org/learn/why_zig_rust_d_cpp/</a> I still don't get _why_ I would use it. To an untrained eye, it seems like go, but with manual allocation. Or an imperative-only rust. Like it has some features of all the languages it competes with, but not the ones that would make me reach for them.
What do people use zig for, and why zig and not one of the others?
I have the same feeling about Zig. In this interview [1], Andrew Kelley, creator of Zig, explains a lot of the features of the language; compares it against c, rust, go; and basically why he created the language. It is a really interesting interview. However, Zig code is a bit hard to read for me.<p>[1] <a href="https://www.youtube.com/watch?v=iqddnwKF8HQ&t=10s" rel="nofollow">https://www.youtube.com/watch?v=iqddnwKF8HQ&t=10s</a>
> What do people use zig for, and why zig and not one of the others?<p>I'm the maintainer of zigler (<a href="https://zigler.hexdocs.pm/Zig.html" rel="nofollow">https://zigler.hexdocs.pm/Zig.html</a>), and I have my own pharma startup. I currently use zig in two contexts:<p>1) wraps a proprietary .so file that is used to communicate with a scientific (microscope) digital camera, in a nice BEAM-module-shaped interface. Sorry, code is private.<p>2) I have a vue.js component that does DNA editing, and one of the features is DNA sequence alignment, and so I had claude write the smith-waterman lalign algorithm in zig, and it compiles to wasm, and this plus going from O(N^2) to O(N) dropped the runtime of an alignment from 30s to a few hundred ms, in both cases so much better than ~5m using a web SAAS, good enough that I can render alignments on-demand, and I don't have to do a storage layer for alignments.<p><a href="https://github.com/Vidala-Labs/opengenepool/tree/master/src/wasm" rel="nofollow">https://github.com/Vidala-Labs/opengenepool/tree/master/src/...</a><p>you can play with it at:<p><a href="https://opengenepool.vidalalabs.com" rel="nofollow">https://opengenepool.vidalalabs.com</a><p>Two sequences may be aligned by right-clicking a sequence name when a sequence is loaded, it will align the two sequences (you'll have to create a second sequence as it forbids aligning a sequence with itself).<p>Why zig? Because it just makes things like cross-compilation easier (microscope is mounted on a elixir nerves deployment!), and has less footguns, and doesn't hide away things you might care about. Most of the things i build with zig don't <i>really</i> have a concern about memory safety, or have such trivial memory patterns that it's easy to verify by eye that they're memory safe.
Can you give more details about using zig along with elixir?<p>> microscope is mounted on a elixir nerves deployment!<p>What do you mean? I imagine that there is an Elixir application running on an embedded system and maybe it relies on an external binary application (compiled using zig). If so, how do you manage the communication between them?
I think this blog post has a great description of the "Modern C" niche Zig fills: <a href="https://vfoley.xyz/hare/" rel="nofollow">https://vfoley.xyz/hare/</a>. I tend to think of Zig in this way. If you found yourself reaching for C, you could instead reach for Zig. You'd get optionals instead of null pointers, comptime instead of macros, a real facility for handling errors, etc. It's like C but with some of the sharp edges sanded off.
> why zig and not one of the others?<p>I think one of the selling points is that the language does not come to your way and allows unsafe constructs. So, I think the target audience is roughly at C and C++ users.
Try reading zig code. For me its much more readable than the other languages, and does not suffer the fact go doesnt have language level errors. Local allocators are very useful and if you dont think so, perhaps you havent dwelved too deeply into systems programming or the language isnt targeted for you.
C is over 50 years old, but it is still more or less the lingua franca of computing. The world benefits from having "C with some improvements from 50 years of learning". The world also benefits from having featureful languages that are a huge divergence from C, but it also just needs a language that provides a thin cross-hardware abstraction over the asm layer and some conveniences over writing raw asm. We don't need every language to be massively featureful, and we hopefully won't all have to reach for C for the rest of human civilization when we need a language that isn't massively featureful.