logoalt Hacker News

dnauticstoday at 5:27 AM1 replyview on HN

> What do people use zig for, and why zig and not one of the others?

I'm the maintainer of zigler (https://zigler.hexdocs.pm/Zig.html), and I have my own pharma startup. I currently use zig in two contexts:

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.

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.

https://github.com/Vidala-Labs/opengenepool/tree/master/src/...

you can play with it at:

https://opengenepool.vidalalabs.com

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).

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 really 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.


Replies

aurahamtoday at 5:58 AM

Can you give more details about using zig along with elixir?

> microscope is mounted on a elixir nerves deployment!

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?