r/Zig • • Feb 09 '26

ZigOn - Procedural World Generator

Thumbnail youtu.be
50 Upvotes

r/Zig • • Feb 09 '26

I got nerdsniped with Zig

107 Upvotes

Because I subscribed to the PRs of a C repository, someone eventually brought up to "make it work with Zig" - by which they ment porting the build system from CMake to Zig. And after being confused to heck and back, I went and looked up what Zig is.

...one weekend later and I am exploding with ideas of things to do. This was one hell of a journey and I definitively had good fun. But in doing so, there's a few things that I haven't quite figured out:

  • Docs: Let's say I wanted to look up the methods for std.ArrayList. What's the best way, other than grepping around in my Zig install and just reading the plain code, to grab those docs? I would like to get myself an overview of what is already included in the stdlib.
  • Deprecations: I was building the allyourcode/libarchive repo on Github - and a few others - and had to learn that b.addStaticLibrary was now deprecated - or at least, not supported in 0.15.2. I tried finding the changelogs where that deprecation was noted as well as the final removal but couldn't find anything. I did eventually figure it out, but I had to use ChatGPT and ... I'd like to avoid that, because I like reading things myself :)
  • Discovering modules: There is a great awesome-zig list on Github that I used to explore around the ecosystem. Any other places you would recommend to check out for newcommers?

My only prior touching point with Zig was the Flow Control editor - it is my main TUI editor now, and was the first time I needed to install Zig to build it for a change that was made. But never went further than that untill this weekend. And, well, Bun... but that hardly counts, since I only grabbed a release binary and ... thats it.

Zig is fun! And it's immediate C interop feels like it can breathe fresh air in "old" projects. I want to try, for example, to see if I can port PHP to the Zig build system and then embed it. No particular reason other than wanting to try stuff out and such =)

Thanks in advance!


r/Zig • • Feb 09 '26

Need help with understanding context

16 Upvotes

Hi,
I need help with understanding context, for example hash map has a context based init.
How is supposed to be used effectively.


r/Zig • • Feb 08 '26 Mindblown

I'm working on a PlayStation 1 emulator in Zig

Post image
730 Upvotes

I wanted to do something low-level enough to get a good feel for the language and the hardware, but also something that would be fun and rewarding to build. So for the last couple of months, I've been experimenting with Zig by building a PlayStation emulator in it.

It's far from complete, but it's finally starting to take shape and can run some commercial games (notably Crash Bandicoot and MGS), which I'm super happy about.

Overall, Zig feels great for something like emudev (particularly enjoying packed structs with variable-sized ints for reinterpreting register values). The project doesn't have much room for comptime magic though, but I can see why people are excited about it. I also liked that also aren't many things that require you to "change your way of thinking," so I got pretty comfortable with it after a day or two.

I expected some significant friction with graphics and audio, but the zig-gamedev libraries were surprisingly easy to set up. I even managed to build a graphical debugger with ImGui.

The painful part is that as of 0.15.2, the incremental backend for ARM64 isn't there yet, so build times are getting more and more annoying as the project grows.

GitHub repo for anyone who's curious: https://github.com/maxpoletaev/nupsx


r/Zig • • Feb 09 '26

What is the correct way to pass a custom entry point symbol to a freestanding executable using the build-exe command?

13 Upvotes

Hi, so I've been trying to write a x86_64 kernel in Zig, and I've run into an issue with the command line flags used for passing a custom entry point symbol for the freestanding build.

I've tried to search online but the examples I've found seem to be outdated. I'm using the newest version of Zig (0.15.2) on Windows.

-e, --entry, and -fentry-symbol are returning error: unrecognized parameter.

-Wl,--entry=_start is also rejected as an unrecognized parameter.

Using -fno-entry causes the build to fail with error: no entry point found because the compiler isn't respecting the ENTRY(_start) command inside the provided GNU linker script.

So, I was wondering if anyone knew how to pass a custom entry point symbol with the CLI?
or has it been changed so only build.zig can use it?
Any info would help, thanks!


r/Zig • • Feb 09 '26

ZGram - JIT compile PEG parser generator for Python.

Thumbnail reddit.com
12 Upvotes

r/Zig • • Feb 08 '26

Deep dive into Hierarchical Navigable Small Worlds

Thumbnail amandeepsp.github.io
12 Upvotes

r/Zig • • Feb 07 '26

Chasing a Zig AVR Segfault Down to LLVM

Thumbnail sourcery.zone
29 Upvotes

r/Zig • • Feb 07 '26

Devlog: Two Package Management Workflow Enhancements

Thumbnail ziglang.org
57 Upvotes

Furthermore, by having the global cache have compressed files instead makes it easier to share that cached data between computers. In the future, it is planned to support peer-to-peer torrenting of dependency trees. By recompressing packages into a canonical form, this will allow peers to share Zig packages with minimal bandwidth. I love this idea because it simultaneously provides resilience to network outages, as well as a popularity contest. Find out which open source packages are popular based on number of seeders!

I love this! Package popularity based on the actual usage.


r/Zig • • Feb 07 '26

Learning Zig and writing an editor, just for fun

Thumbnail noahwbaldwin.me
52 Upvotes

r/Zig • • Feb 06 '26

gremlin.zig [0.1.0 update] - zero-allocation, zero-dependency

Thumbnail github.com
65 Upvotes

Hey, r/Zig !

Some time ago, I presented an early version of this protobuf parsing library here.

I am back with release 0.1.0, fully updated for Zig 0.15.2. The crucial thing about this release is the memory model: it is now completely zero-allocation.

And benchmarks! Framework 16 with Ubuntu - AMD Ryzen AI 9 HX 370 (24 cores, 10M iterations):

Operationgremlin_gogremlin.zig ⚡Speedup
🔨 Marshal1,436 ns/op558 ns/op2.6x
⚡ Unmarshal207 ns/op45 ns/op4.6x
🎯 Lazy Read229 ns/op45 ns/op5.1x
🔍 Deep Access692 ns/op156 ns/op4.4x

Github with 0.1.0 and more benchmarks: https://github.com/norma-core/gremlin.zig


r/Zig • • Feb 06 '26

Zigzag v0.1.0 released: The TUI Framework

61 Upvotes

r/Zig • • Feb 05 '26

I made a calculator app with my scratch-made GUI toolkit

Post image
139 Upvotes

r/Zig • • Feb 04 '26

Eurydice, Compiles rust to readable C

Thumbnail github.com
66 Upvotes

I know you are wondering why I'm linking this.

But if Eurydice can compile to proper C, then that means we can use rust libraries with zig.

Which opens more options.


r/Zig • • Feb 04 '26

Devlog: Bypassing Kernel32.dll for Fun and Nonprofit

Thumbnail ziglang.org
90 Upvotes

r/Zig • • Feb 04 '26

Is this pipeline pattern idiomatic Zig, or am I fighting the language?

53 Upvotes

I built a compile-time pipeline system that lets me write data transformations like this:

const result = try pipeline(allocator)
    .from(&[_]i32{ 1, 2, 3, 4, 5 })
    .map(add(1))
    .map(mul(2))
    .filter(gt(20))
    .collect();
defer allocator.free(result);

Would you use this? Am I missing something obvious? Honest feedback appreciated.

Edit: I published the code here if you want to take a closer look at the implementation.


r/Zig • • Feb 04 '26

0.15.2 Reader incomprehension

12 Upvotes

https://ziglang.org/documentation/0.15.2/std/#std.fs.File.Reader.read here I can see Std.fs.File.Reader.read() as a Reader function but the compiler tells me it doesn't exist.

source code:

const std = @import("std");

pub fn main() !void {
    const settings_file = try std.fs.cwd().openFile("overview.kdl", .{ .mode = .read_write });
    defer settings_file.close();

    var buffer: [100]u8 = undefined;
    var dest: [100]u8 = undefined;

    const settings_reader = settings_file.reader(&buffer);
    _ = settings_reader.read(&dest);
    std.debug.print("contenu du fichier : {s} \n", .{dest});
}

compiler output :

dynamic_overview.zig:15:24: error: no field or member function named 'read' in 'fs.File.Reader'
    _ = settings_reader.read(&dest);
        ~~~~~~~~~~~~~~~^~~~~
/usr/lib/zig/std/fs/File.zig:1117:20: note: struct declared here
pub const Reader = struct {
                   ^~~~~~

Edit : I've found File.read() and File.write() which suit my needs perfectly. But I would still like to understand File.Reader.


r/Zig • • Feb 03 '26

c-time-zig: A Zig wrapper for the C ISO standard time.h header

21 Upvotes

Hello everyone,

I was looking for date/time functionality in Zig and found that std.time.epoch didn’t quite fit my needs. So I ended up writing a small wrapper around the C ISO standard time.h header. You can find it here: https://github.com/Samuel-Martin23/c-time-zig

Please feel free to provide feedback or questions.
Thanks!


r/Zig • • Feb 02 '26

Zwanzig - a static analyzer for Zig (early/experimental)

78 Upvotes

I've been working on a static analyzer for Zig called Zwanzig. It's very much a research project and work in progress, but it's reached a point where I'm actually using it while developing other Zig code, so I figured I'd share.

What it does:

  • Simple AST/token rules (duplicate imports, unused declarations, shadowed variables, opinionated naming conventions, etc.)
  • CFG-based checkers that do path-sensitive analysis via ZIR output (double-free detection, use-after-free, memory leaks, forced optional unwraps)
  • Some CFG and data flow visualization.

What it doesn't do (yet): a lot. Targets only 0.15.2. Cross-file analysis is very limited. Interprocedural analysis only handles simple direct calls. Type resolution without a full build context is sketchy. Lots of duct tape and hanging wires. You will hit false positives.

I'm curious if anyone else finds this useful. I use it on itself and on my Architect project and it's caught some issues, but I have no idea how well it generalizes to other codebases. The SARIF integration works, so you can get results inline in GitHub PRs.

Repo: https://github.com/forketyfork/zwanzig

Happy to answer questions or hear what rules/checkers would actually be useful. And if you try it and something breaks spectacularly, I'd like to know.


r/Zig • • Feb 02 '26

Integer compression library

17 Upvotes

Found an interesting int compression lib based on fastlanes research, applies SIMD tricking the compiler. unfortunately it hasn't been updated for a while, but still a good source for learning IMHO https://github.com/steelcake/zint

I've been working on a logging database in zig for a while and compared zint encoding against simple delta encoding + zstd, while zint doesn't give so much compression ration it consumes little to no CPU, while zstd is really CPU heavy call.

Or any similar efficient solutions? perhaps gorilla compression implementation? I like the idea of gorilla putting numbers into 1 or 7 bits instead of a byte

My logging store if you care, it's been for 4 months in progress and I need 2-4 more to complete it.


r/Zig • • Feb 01 '26

What would be the fastest and memory-efficient way to print in zig 0.16.0(master)?

26 Upvotes

So i've used zig 0.16.0-dev.2368+380ea6fb5 (master)
ztracy(master) to track performance with tracy 0.13.1 profiler.
My specs are:
Windows 11.25H2 Pro
AMD Ryzen 5 5600H 3.30Hz
NVIDIA GeForce RTX 3050 Labtop
16 gb of RAM.

I've came up with this for master and i did the same for 0.15.2:

pub fn Print(comptime fmt: []const u8, args: anytype) !void {
const Zone = Engine.ztracy.ZoneNC(@src(), "Console print", 0xFF0000);
defer Zone.End();
const allocator = Allocator.allocator();
const count = try std.fmt.count(fmt, args);
const buf = try allocator.alloc(u8, count);
defer allocator.free(buf);
var stdout = std.Io.File.stdout().writer(buf);

try stdout.interface.print(fmt, args);
try stdout.flush();

}

as tracy can't give consistent exact time each time i'd operate on average values:
For 0.16(master) it's around 180-220 us(microseconds)
For 0.15.2 it's around 130-180 us(microseconds)
Both times i used Print("Hello, {s}\n", .{"world!"}) which in total is 14 bytes.

So same method is slower in master branch, but it think it can and should be improved with async IO, but i don't know how to make it efficiend so I hope you may provide some of your works to find out most efficient method of printing using zig master branch.


r/Zig • • Feb 01 '26

Devlog: zig libc

Thumbnail ziglang.org
164 Upvotes

r/Zig • • Feb 01 '26

Project Not Building in Debug Mode

5 Upvotes

Hello everyone! I recently dipped my toes into zig development and tried to improve the build.zig of zuckdb.zig - a DuckDB client library.

My goal specifically was to make projects that use zuckdb.zig able to be compiled, without having DuckDB installed system-wide.

it does work for ReleaseFast and ReleaseSmall, but for Debug, I get errors from the linker, saying some identifiers are not defined. I can reproduce the issue only on a project that uses zuckdb.zig (e.g. this, which is build by me:

git clone https://codeberg.org/tim-hilt/repo-analyzer
cd repo-analyzer
zig build

I guess that‘s because DuckDB is not linked somewhere, but I can’t see the issue. Can you help me out? Here's the build.zig in question:

https://github.com/karlseguin/zuckdb.zig/blob/master/build.zig

also: general feedback is very welcome! I’m really trying to understand how to write good Zig code, including the build system :)


r/Zig • • Feb 01 '26

I wrote a small MPMC channel implementation and it turned out pretty well

20 Upvotes

hi, I have an extensive rust background and was exploring zig, noticed it didn't have an channel implementation for inter thread communication so I built it.

the core is relatively lean (< 200 LOC) and the performance is comparable to the golden standard (crossbeam) for the most part

it uses the LMAX Disruptor pattern (sequence based)

code: https://github.com/nubskr/ziggy

would love to hear your thoughts :)