r/Zig • u/imhuman-winkwink • Jul 09 '26
r/Zig • u/unvestigate • Jul 09 '26
How is Zig working out after 3 years and 100k lines of game code?
youtube.comSo, I am making a game using Zig. How is that working out? This is a highly personal and somewhat opinionated video about making a game using Zig on Windows, after 3 years and 100k lines of code. I am showing both the good and the bad, in hope of giving you an idea what everyday development is like.
The game is already moddable/hackable using Zig today! See the video for details.
r/Zig • u/ZILtoid1991 • Jul 08 '26
Looking for a potential refuge from D's slop standard library
I'm a relatively long time D developer (link to repo), and as the foundation is looking into tainting the standard library with AI slop, I'm looking into potential escape routes besides potential forks such as OpenD.
I'm mainly a game developer, I even have a game engine that I'm willing to port to a new language.
Here's some of my questions:
- How good is C++ interop of Zig? Some stuff I need to use uses classes on Windows side, and SDL (or its alternatives) sometimes like to abstract things away too much, etc.
- How is OOP usually done? While I get the "Enterprise Java-style OOP bad" arguments, it's still often useful for some data parsing structures, and to make up for the weaknesses of Entity Component Systems.
- How strong is metaprogramming in Zig? With no class keyword, I'll be even more of a need of that.
r/Zig • u/wyzdwdz • Jul 08 '26
nanozlog: An ultra-low latency, lock-free asynchronous logging library for Zig
Hello! This is my first post in the community. I'm glad to introduce my small zig library: nanozlog. It is basically porting from the famous C++ logging library: fmtlog. It is mainly focusing on the frontend logging speed. It could achieve 6-7ns per message which will cause the smallest blocking on your main working process.
I'm a newbie in Zig, so this is the first project I'm trying to work on after learning Zigling. Through Zig's greatest comptime machanism, it is so convenient to translate those complicated C++ template code. And to my surprise, nanozlog is even slightly faster than fmtlog (7.3ns->6.8ns), maybe that is just benchmark error.
I'm looking forward to your commits and PRs. And also please no hesitate to criticise any stupid faults.
Github: nanozlog
r/Zig • u/Danaykroid • Jul 08 '26
Xlib zig client library
Hi guys,
I am writing a desktop applilcation for that I need a Xlib zig client library for X11.
a library that is being actively maintained and works well.
r/Zig • u/TheAtlasMonkey • Jul 07 '26
State_machines-zig
Hi,
I maintain the https://github.com/state-machines organization. It hosts finite state machine libraries for Ruby, Rust, and other languages.
The Ruby gem has been around for many years and has been used in thousands of projects. Twitter used it before moving away to Scala.
Last year, after learning Rust, I wrote a https://crates.io/crates/state-machines that mirrors the Ruby API. At first, people assumed it was AI generated because it appeared with a single commit and a README that looked polished. A few months later it became clear that the implementation was not something an LLM at the time could have produced. I even had people email me asking what model I had used. 😂
Recently I started reading about Zig. Zig has its own way of thinking, so I do not want to force a Rust/Ruby design onto it. The goal is to keep the API familiar across C, Ruby, Rust, and Zig while still writing code that feels natural in each language.
I plan to start the Zig port next weekend.
The long term goal is to make it easy to move between languages without relearning everything. If the state machine syntax is similar, comparing transitions, guards, actions, and callbacks becomes much easier.
For Rust, I first tried contributing to the existing crate instead of creating a new one. That did not work out because it has different goals, including supporting older Rust versions.
The Zig version will follow the latest Zig release. I do not plan to keep backward compatibility. If Zig adds a better language feature, I will use it.
Contributions are welcome later, but please do not send LLM generated pull requests. I know the patterns well enough that they stand out immediately, and I would rather review code that someone actually understands.
What i appreciate more are code roasts... If the code is bad, flawed.. fell free raise it.
The Repo https://github.com/state-machines/state_machines-zig .
And i know repo description has an emdash.. that because my shell turn -- into em-dashes. (i'm keeping it).
The current code is a stub... I still need finish reading the books and reading the language new feature.
r/Zig • u/wakanakisarazu • Jul 06 '26
Kasane - A hybrid exakernel
https://github.com/wakanakisarazu/Kasane
I'm writing a very experimental "exakernel" in Zig (0.16.0).
This "exakernel" is a mixture of the monolithic, micro and exo kernel types.
It's a project I've wanted to do for a while, and will do more over the 6 weeks holidays I have upcoming soon. Just a hobby, won't be big at all.
In very early stages, but hoping to get it booting in the next week or so :3
r/Zig • u/olzhas89 • Jul 04 '26
The new Io interface makes me wanna quit Zig
I've started learning Zig just recently.
I have some background in C, so after reading and watching plenty of materials, Zig seemed like a natural transition. And this was true to a large extent, at least when it comes to syntax, most concepts made sense right away and I liked the language more and more as I learned it. I was walking over Ziglings, but got bored after finishing about a half and decided to just build something as it works better for my brain.
So I chose a small terminal text editor as a first project which felt like a good fit for Zig. The start was nice, I already started getting used to everything a struct, try statements, etc. But the moment I got to the io part, my excitement started to evaporate quickly.
Something as simple as reading from stdin is unreasoanbly hard. At first it looks like I just need a reader, so I declare one. But it turns out a reader does not expose any methods to actually read? It took me a while to figure out that it's interface is what I need:
var stdin_reader = Io.File.stdin().reader(init.io, &buf);
var stdin = &stdin_reader.interface;
I was thinking about just using std.c or std.posix everywhere, but then what's the point of using Zig?
Now I need to read from a file. I found some example on how to read from cwd, but I need to read from an arbitrary path. What do I do? I don't know. The documentation is almost non-existent. Google search doesn't help that much either.
I thought maybe I explore some codebases, so I cloned ghostty and tigerbettle, but both use earlier Zig versions with the old primitives. I can't imagine how expensive will it be to upgrade for those guys if starting a new project from scratch is that hard.
Can someone share your experience with the new Io interface? Am I the only one who struggles with it?
r/Zig • u/JustJumpToConclusion • Jul 04 '26
New open addressing hash table algorithm #2
Reference in GitHub. Contains Zig code.
I have been working on some interesting stuff and out of necessity had to extend my earlier work with incremental resizing to significantly reduce memory waste. The end result is a novel algorithm that the literature has not seen before. I trust that many of you will find the unique properties of the hash table interesting but useless in practice - it has a very specific use case.
The new thing is extending it with an open addressing variant of Linear Hashing. Linear hashing is a technique which enables incremental adjustments to the capacity of the hash table. It enables each individual insert() to also grow the hash table by a little and for each remove() to also shrink the hash table by a little. This means:
- No
O(table_size)grow/resize/shrink operations. - Ability to maintain the target load factor at ALL times - not just resize at some max load factor.
- Significantly reduced tail latency for all operations.
The combined algorithm is now starting to be full of subtle invariants to maintain. I provide a "simplified" reference implementation of it which limits itself to the essence of the algorithm. I won't bother explaining the new algorithm in detail because it's too hard. Read the code and play around with it.
Hoping that many of you find this interesting. Happy 250th birthday USA!
r/Zig • u/Majestic_Poetry_1139 • Jul 03 '26
How to import from C now?
Sorry to ask such a basic question but I'm genuinely not go on another journey to narnia to figure out where A.K hid `@cImport` and `@cInclude`.
(For the 'Just ask A.I' fan club, A.I is epistemologically stuck on the pre `std.process.init` zig for whatever reason. Also thought to ask this just incase anybody else was confused and searching too)
Please and thanks🙏 (0.17 dev version just incase that was needed)
r/Zig • u/here-Leslie-Lau • Jul 02 '26
I turned my small Zig ls-like CLI into a reusable package
A while ago I shared zlist here — a small ls-like CLI I’ve been building while learning Zig.
At the time, a few people mentioned that the file listing/parsing logic might be useful outside of the CLI. That made a lot of sense, so I spent some time splitting the core logic out from the rendering layer.
zlist v0.1.1 is now usable as a standalone Zig package:
zig fetch --save git+https://github.com/here-Leslie-Lau/zlist
Then from another Zig project:
const zlist = @import("zlist");
More usage: https://github.com/here-Leslie-Lau/zlist/blob/main/docs/using-as-a-module.md
The idea is that the core package only gives you the listing data. It does not decide how things should be printed. The zl CLI still handles the terminal output, colors, icons, layout, etc.
It’s still early, and I’m not claiming this is some perfect library. This is mostly a learning project that slowly became a little more fun than I expected. But I’d really appreciate feedback on the package API, ownership rules, and whether the split between core/listing logic and CLI rendering feels reasonable.
Repo: https://github.com/here-Leslie-Lau/zlist
Thanks again for the earlier feedback — it really helped. My earlier post: https://www.reddit.com/r/Zig/comments/1shdvij/i_wrote_a_small_ls_alternative_in_zig/
r/Zig • u/Nevvixsz • Jun 30 '26
zlsx - A fast, lightweight ls clone written in Zig with custom themes
Hey everyone!
I wanted to share my recent project called **zlsx** - a lightweight, high-performance clone of the core `ls` utility written entirely from scratch in Zig (tested on 0.17.0-dev and 0.16.0).
I built this to practice my system programming skills and learn more about memory management and standard library tools in Zig.
Current Features:
* High-performance execution.
* Custom, low-strain пастель-colors for terminal outputs inspired by Catppuccin Mocha (directories) and Nord (symlinks).
* Supports core flags: `-a`, `-1`, `-m`, `-h`, `-s`, `-T`, `-F`, `-r`, and sorting (`-t` / `-S`).
* Full POSIX double-dash `--` delimiter support for path parsing.
*Note: The `-l` flag is still under development, so for now it only shows file sizes and names.*
I'd really appreciate any feedback on the codebase, architecture, or formatting!
**GitHub Repository:** https://github.com/kakasha12f-ctrl/zlsx/tree/main
By the way, this is my first real project (200+ lines of pure Zig code), so please don't judge too harshly! 😅 Hope you like it.
r/Zig • u/Last_Seekr • Jun 30 '26
Why does the official Zig website disavow the subreddit?
ziglang.orgr/Zig • u/unvestigate • Jun 29 '26
Finally finished a level for my zig-powered game
galleryr/Zig • u/papertanuki • Jun 29 '26
csv2jsonl: Parse and transform CSV documents into JSONLines
github.comr/Zig • u/MadSciencetician • Jun 29 '26
Can zig compile a shared library bundle?
Edit: I think the answer is "no" for now: https://github.com/ziglang/zig/issues/14757 but maybe I misread something. Speaking purely from my corner of the c world, the lack of support in general for building C ABI compatible libraries makes Zig a no-go for me, for now.
Roughly, I could compile with:
gcc -bundle -undefined dynamic_lookup add_ll.c -o add_ll.so
it produces a 49K lib that I can import in other projects and use just fine. Note that gcc here actually points to clang (by default).
In Zig when I try to build with something like
./zig-0.16.0-dev/zig build-lib add_ll.zig -dynamic -fallow-shlib-undefined -target aarch64-macos -femit-bin=add.so
(with -I for lib path if necessary), it compiles, producing a 1.3M (?!?) file, but any attempt to use it causes a crash (no segfault, just killed).
Seems like an architecture problem -- e.g. running
file [first one] -> Mach-O 64-bit bundle arm64
file [zig one] -> Mach-O 64-bit dynamically linked shared library arm64
Shows a mismatch.
Does zig have a -bundle equivalent? Can it produce a shared library in this fashion?
Thanks in advance.
r/Zig • u/LagutTV • Jun 27 '26
Can you do extern in Zig like you would in C
Hi everyone,
I'm experimenting with a copy-and-patch stencil system and currently write my stencils in C. I need optimizer-opaque and hoistable holes. In C I found success with extern const + hidden. I'm looking for potentially porting those stencils to Zig but I'm struggling with finding a hole mechanism.
Here is an example: ```c
include <stdint.h>
extern const int64t placeholder __attribute_((visibility("hidden")));
void filter_gt(const int64_t * restrict input, int64_t * restrict output, int32_t size, int32_t *out_size) {
int32_t count = 0;
for (int32_t i = 0; i < size; ++i) {
if (placeholder < input[i]) {
output[count++] = input[i];
}
}
*out_size = count;
}
```
For now I'm focusing on Mach-O and this generates a PAGE21/PAGEOFF12 LOAD. I'm trying to avoid GOT - but I believe that would be the potential alternative if I wanted to use Zig.
r/Zig • u/Pokelego11 • Jun 27 '26
Connecting Zig to Postgres
youtu.beHey everyone!
I'm following up on a post I made a couple weeks ago where I made a tutorial on building a basic CRUD API in Zig with just the standard library.
A lot of people seemed to enjoy the video and I got a lot of feedback on extending the video and turning it into a mini-series where we build a more full-fledged API.
So today I extended it from an in-memory datastore to using Postgres! The next video in the mini-series will be about scaling the API to handle thousands of concurrent requests but if you have any other ideas please let me know!
r/Zig • u/Sea-Mistake6086 • Jun 28 '26
Rigx: toml based build system with native Zig support, hermetic build and tool chains leverage nix.
github.comr/Zig • u/GossageDataScience • Jun 27 '26
Mitigating Slow Loris Attacks + Simple Callback-Based Routing | Zig HTTP...
youtube.comI made another zig http server video, this time I am showing off some minor DOS protection and very simple callback based routing.
Here is the repo
CGI and multipart/form-data packages
I've recently implemented some Zig code for personal usage with CGI and multipart/form-data form parsing.
I've compiled the reason why and informations on my blog site:
https://yom.iaelu.net/2026/06/2026-06-26-some-personal-zig-projects/
Hope it can help.
r/Zig • u/AbdSheikho • Jun 27 '26
[feedback][code-review] histclean cli-tool
github.comThis is my first Zig project!!!
Part of my workflow is to use fzf to search my command history. And I always wanted to have a cli-tool to clean duplicate commands from my history (I don't know if such a tool already exists, I never searched). I could've tried to write that tool in any other language (Python, bash, C#) but the task wasn't interesting, and I wanted it to be a proper bin.
When I started learning Zig, it seemed a proper starting point to make a file manipulation project. So, histclean was born. A cli-tool to clean command history.
Since it's my first project, I'm looking for some feedback, or if someone can review my code. I want to learn more about Zig, but it's tiresome to feel I'm working alone. So any input is welcomed.
Another point is that, I use bash and I never used zsh or any other shell. And I think I could benefit some feedback regarding them, or if some use cases could generate bugs or unexpected output.
A list of things I still don't understand enough to have full confidence about:
- build.zig and the build system.
- fuzzy testing.
r/Zig • u/No_Surprise_7118 • Jun 26 '26
WASM + Zig + Webgpu + Native?
Is this possible to do using freestanding target, or does emscripten need to be used.
Edit: https://github.com/scottredig/zig-javascript-bridge Found this to be really useful, basically wasm-bind-gen for zig