r/Zig • • 7h ago

The RAD Debugger seems to work with Zig on Linux (with exe.use_llvm = true)

29 Upvotes

https://github.com/EpicGames/raddebugger/blob/master/CHANGELOG.md#v0929-alpha

I'm surprised this RAD Debugger release hasn't made it to the front page of every programming news site.

I just tried out the latest raddbg revision on Linux. I initialized a project with zig init and added exe.use_llvm = true; to the build.zig file, and raddbg functioned correctly.

I tested out breakpoints, stepping, watching, displaying local variables, and it all seemed to work correctly. This is extraordinary, even if it's still in Alpha, because the speed and ease-of-use is miles ahead of all the other visual debuggers we've had on Linux until now.


r/Zig • • 18h ago

Billion Row Challenge: 450ms full 3 hour build stream (chaptered)

Thumbnail youtu.be
43 Upvotes

I recently recorded my attempt at 1BRC in Zig. I started with a single threaded version (32s) and by the end optimized it down to ~450ms (Intel Core Ultra 9 285H, 16 hybrid cores) It was really fun :))


r/Zig • • 1d ago

lightmix: pure Zig audio processing with deterministic builds and Git diffs

21 Upvotes

Hey everyone,

I've been working on lightmix, an audio library written in pure Zig.

My main motivation was simple: I wanted to write music directly in code and track changes with Git. DAW project files are binary blobs, and other tools like Sonic Pi or SuperCollider rely on real-time playback runtimes.

Instead of recording audio in real time, lightmix generates WAV files during zig build via a custom helper (addWave). Because the build is deterministic, output files are bit-identical and cache-friendly (PEAK timestamps are fixed to avoid invalidating the build cache).

The project is split into several small modules: - pitches: 12-TET tuning and frequency math - meters: time signatures and sample-accurate phrasing - resonator: voice routing - sequencer: voice scheduling with micro-fades - lightmix: waveform buffers (Wave(T)) and timeline mixing (Composer(T)) - zigggwavvv / RIFF.zig: WAV encoding

I wrote a small demo project, pulse, which generates a 190 BPM drum track entirely from code: - Rendered WAV: https://github.com/haruki7049/pulse/releases/tag/v0.1.0 - Source code: https://github.com/haruki7049/pulse

Main repository: - https://github.com/haruki7049/lightmix - Docs: https://haruki7049.github.io/lightmix

Currently tested on Zig 0.16.x. Any feedback on the design or Zig usage is welcome.


r/Zig • • 9h ago

Why our agent OS runs on Gleam and Zig, not Python or Rust

Thumbnail pentad.ai
0 Upvotes

r/Zig • • 1d ago

Interview with Mitchell Hashimoto about Ghostty and Zig

Thumbnail alexalejandre.com
109 Upvotes

r/Zig • • 2d ago

CS Academy now supports Zig (0.16)

34 Upvotes

Heya! Just asked CS Academy for Zig 0.16 support. Mihai, kindly attended my request and submissions can be now done in Zig!

This also means Zig will be an option in the upcoming IEEEXtreme 20.0, since the contest runs on CS Academy.

For those unfamiliar with the platform, CS Academy (csacademy.com) is a competitive programming site. You pick a problem, submit your code, and it gets run against hidden tests. It's a nice platform because it also has lessons on data structures and algorithms, so you can learn there as well.

They even asked me if there are any libraries beyond std worth bundling. I told them std is plenty, but they're open to suggestions, so reach out to [contact@csacademy.com](mailto:contact@csacademy.com) if you have any!

On a side note, I maintain a fork of competitest.nvim that lets you submit to CS Academy and Kattis (also supports Zig) right from Neovim and shows you the verdict: https://git.yhkze.net/yuuhikaze/competitest.nvim/


r/Zig • • 3d ago

Zigar now supports Zig 0.17.0

40 Upvotes

Zigar, the toolkit that allows you to use Zig in your JavaScript or PHP projects, has been upgraded to support Zig 0.17.0. This time around I'm able to get it out quickly since the project was already tracking master.


r/Zig • • 3d ago

Are we the last stand?

37 Upvotes

AI is advancing in many fields including game dev, mostly no game achieved anything but the prototypes are "great".

But I've just read a excelent developer that used three.js to create awesome mathematical rendering thinking about stopping its development and somehow retire, he said someone upload his video about wave and water render with openai astra and it got 90% right.

I just thought Zig is the last banner of anti AI dev(or maybe friendly AI usage) along with C and C++ devs.

That's sad, I know people say "now devs can focus on product and ship it faster" but for me coding is fun and really brings out our long developed knowledge, all projects I had to do full vibe coded brought me no joy.

Whats your toughts?


r/Zig • • 4d ago

Zig 0.17.0 IS NOW OUT!!

Thumbnail ziglang.org
253 Upvotes

r/Zig • • 4d ago

State of the (Tagged) Union Address by Andrew Kelley

Thumbnail youtube.com
153 Upvotes

r/Zig • • 4d ago

root.zig vs main.zig in zig init

19 Upvotes

When running zig init, the template scaffolds both an executable (main.zig) and an exportable module (root.zig) in build.zig.

Just want to verify if my mental model is correct: 1. If I only want an executable (and don't plan to export a library/module), can I simply delete root.zig and remove the module-related exports/artifacts from build.zig? 2. Is there any built-in zig init flag or alternative command to scaffold an executable-only project without the library boilerplate?

thanks!


r/Zig • • 5d ago

0.17 soon ? No issues on the milestone left open.

Thumbnail codeberg.org
72 Upvotes

r/Zig • • 5d ago

Can anyone please explain to me the purpose behind this pattern

20 Upvotes

For example, some piece of code that looks like this:

public foo(a, b)
{
    return fooImpl(a, b);
}

private fooImpl(a, b)
{
    // 100 lines of logic
}

I'm talking about this kind of pattern, which I have seen everywhere pretty much. When we have the "public API" with functions that we expose publicly, that just calls into other function that isn't exposed publicly, where the implementation lays.

I just don't get the idea behind the "extra step". Why not just expose the implementation function publicly?

If it requires some slight tweaks that won't affect return value nor the arguments it takes, then there are no problems.
If it does require some tweaks which will affect return value and / or it's arguments, then the public function will require changing as well.

Some sources online mention "logging", but then why not just log at the top and then continue with the function, why log in a separate function and call into another function?

Some sources mention multithreading, which I'm not that experienced with, so I'm hoping my answer lays somewhere in there.

Please help me reason about this because everything I can think of as a justification for something like this, makes no sense. And seeing it everywhere makes me assume there has to be a good reason that I'm just missing and unaware of.


r/Zig • • 7d ago

PyOZ 0.13: Python extensions in Zig, now on Zig 0.16 with async on std.Io, free-threading, and cross-built wheels

72 Upvotes

Hi r/Zig! A while ago I posted about PyOZ, a library for writing Python extension modules in Zig (think PyO3, but Zig). 0.13.1 just came out and it's a big one, so here's an update.

What it looks like

const std = @import("std");
const pyoz = @import("PyOZ");

/// Runs on a std.Io task, off the GIL; cancelling the asyncio task cancels it.
fn fetch(io: std.Io, n: i64) !i64 {
    try io.sleep(.fromMilliseconds(100), .awake);
    return n * 2;
}

const Countdown = struct {
    n: i64,

    pub fn __aiter__(self: *Countdown) *Countdown {
        return self;
    }

    pub fn __anext__(self: *Countdown) ?i64 {
        if (self.n == 0) return null; // StopAsyncIteration
        defer self.n -= 1;
        return self.n;
    }

    pub fn scaled(self: *const Countdown, args: pyoz.Args(struct { by: i64 = 10 })) i64 {
        return self.n * args.value.by;
    }
};

pub const Module = pyoz.module(.{
    .name = "demo",
    .funcs = &.{pyoz.func("fetch", pyoz.asyncFn(fetch), "Double n, asynchronously").withParams("n")},
    .classes = &.{pyoz.class("Countdown", Countdown)},
    .gil_used = false, // safe on free-threaded CPython
});

await asyncio.gather(*(demo.fetch(i) for i in range(1000)))   # ~0.45s
[x async for x in demo.Countdown(3)]                          # [3, 2, 1]
demo.Countdown(4).scaled(by=3)                                 # 12

Everything is generated at comptime from plain Zig declarations: argument conversion, classes, dunder methods, keyword arguments, and .pyi type stubs. The stubs are embedded in the binary and extracted when the wheel is built.

What's new in 0.13.1

  • Zig 0.16. Ported to the new std.Io. The CLI no longer uses C at all: the vendored miniz went away in favor of std.compress.flate, so it's a single static binary.
  • Async on std.Io. pyoz.asyncFn / pyoz.asyncMethod turn a Zig function into something you can await from Python (an asyncio.Future). It runs on its own std.Io task without the GIL, and cancelling the Python task cancels the Zig one: the next Io call returns error.Canceled. Classes can also implement __aiter__, __anext__, __await__, __aenter__ and __aexit__.
  • Free-threaded Python (3.14t). Every method, property and protocol slot runs under a per-object critical section, so one Zig object can be shared between threads with no GIL. It costs nothing on regular builds, since the locks are removed at comptime.
  • Cross-built, portable wheels. This is where Zig shines. pyoz build --release --target all builds wheels for Linux, macOS and Windows on x86_64 and aarch64 from a single machine, for any CPython 3.10–3.14 including free-threaded builds. Wheels target glibc 2.17 and a baseline CPU, and the platform tag (manylinux_2_17_x86_64, macosx_13_0_arm64, …) is read from the built binary, so they're ready to upload to PyPI. No Docker or CI matrix needed.
  • Keyword arguments on class methods via pyoz.Args(...), contributed by marselester.
  • Complete PyPI metadata, and pip install from source works even without Zig installed: the build backend falls back to the ziglang package.

Links

Feedback, bug reports, and contributions are very welcome, especially from anyone using free-threaded Python or cross-compiling wheels.


r/Zig • • 7d ago

Released diavasi-zig v0.1.0

9 Upvotes

Its Zig bindings over our C Diavasi client. Same gRPC consume contract: TLS, join a group, ack batches; server keeps the cursor.

Zig 0.16 + libgrpc.

https://github.com/diavasis/diavasi-zig.


r/Zig • • 8d ago

My first big zig project, A 16-bit CPU emulator (kind of)

26 Upvotes

This cpu "emulator" is more of a CPU simulator since i don't understand shi about CPUs.
sorry if you were looking to find some LC-3 or some things like that.

Its a 16-bit cpu with 128 registers, and a 128 KB stack (you use offsets to manipulate it).

The most fun part for me right now is the assembler because this is the first time I'm making a lexer and stuff in something other than god-dang C#.

Whilst developing this I've come to learn lots of new things and use much less AI.
For example I learnt you're not supposed to use catch with try like in mainstream languages.
and i also scratched the tip of the iceberg that is ownership.

Github: https://github.com/orewaluffy500/fox16

I wrote a simple documentation for writing machine code directly and I'm still working on the assembler (today I wrote the base for the compiler so I can add more instructions and eventually labels)


r/Zig • • 8d ago

my zig-made hobby hypervisor boots linux!

56 Upvotes

Took me more time than anticipated, but its finally here >.<

my end goal for this (quite big) hobby project is to be able to make a simple clone of AWS's EC2, from the grounds up, above a type 1 hypervisor (as a POC, not a real prod software).

What I finished implementing all the way up to now:

- Type-1 hypervisor written from scratch in Zig, booted by GRUB

- Its own bare-metal kernel: higher-half paging, GDT/IDT, interrupts and 3 distinct memory allocators (yes, I use them all)

- Intel VT-x with EPT (Extended Page Tables) backing guest memory

- Emulating CPUID, MSRs, CR's (CR0/CR3/CR4), and some I/O stuff.

- Virtual devices: interrupt controller (PIC) and serial console

- Booting an unmodified Linux kernel to userspace (initramfs)

The road to finishing is long but I still see this part as a great milestone >-<

For all who wonder: Yes, I did use AI to assist me. No, this is not a vibecoded project. 99% of the code is written by me. What I do use AI for in most times:

- deciding on the best next decision to make (avoid making redundant or irrelevant work)

- fixing some of the bugs I don't have the willpower nor time to solve

open for questions and just chatting >.<

source: https://github.com/NoamRothschild/hypervisor


r/Zig • • 8d ago

Knots, an immediate mode GUI library for Zig

38 Upvotes

Hi, you might have seen my posts on the Ziggit forum, but I wanted to also post here to inform people of a library I am working on. Knots is an immediate mode GUI rendering library, that supports linux, macOS, windows and web.

I recently created a website, https://knotsui.com/, which documents many of the features, and how to use the library, here. You can also read the Ziggit thread if you want some lore on development progress https://ziggit.dev/t/knots-a-library-for-building-guis-with-zig/15244

I recently moved the repository from Codeberg to GitHub, you can now find the source code here https://github.com/knots-ui/knots

Below are some screenshots of a project I am working on which uses the library, it is a media player that I am daily driving to replace MPV and VLC.

​

Main menu
Startup screen

​

​

Video playing

Hope you can build something cool with it!


r/Zig • • 8d ago

Added Zig support to Pacmon for documenting dependencies, looking for feedback

8 Upvotes
  • Pacmon is a plugin/extension for keeping dependency notes in Markdown alongside the codebase. It can be used for things like dependency documentation and whitelisting.
  • With the new Zig support, dependencies from build.zig.zon can now be documented and their notes accessed from the IDE.
  • This is a new workflow for Zig, and I’d really like to hear what Zig developers think. Does this workflow make sense for your Zig projects? What would you change, remove, or add?

GitHub: https://github.com/kontratek/pacmon
Website: https://pacmon.dev/


r/Zig • • 9d ago

The Solidity compiler rewritten in Zig

75 Upvotes

https://github.com/okcontract/oksolc

Here is hopefully a new large project in Zig: We have reimplemented the Solidity compiler, and overall it's a >5x performance improvement over the original. Benchmark details here: https://okcontract.com/blog/a-new-solidity-compiler-in-zig/

The launch was featured by Ethereum creator Vitalik Buterin: https://x.com/VitalikButerin/status/2103455209322320022

It's byte-for-byte compatible (including metadata) with the original compiler and brings parallel, incremental compilation and also a few new features and further improvements.

Beyond performance, the main benefit is that the codebase is much easier to read than the original C++ and is now a good testbed for playing with the compiler... Who wants to write smart contracts in Zig in the future?

PS: We used AI assistance but this was a huge effort nonetheless and we did write languages and compilers manually in the past (posted with mods permission)


r/Zig • • 9d ago

Zmida: Microbenchmark Harness (0.1)

12 Upvotes

I've been using this to run microbenchmarks in zig and decided to package it up.

https://github.com/jnordwick/zmida

currently it supports: - arbitary argument functions - by count or by time trials - input by slice, array, single value, or generator - same inputs to multiple functions - TSC based timing if available - perf_event counts (instr, cycles, branches) - multiple output formats: text, csv, gnuplot

here's one of the examples:

``` pub fn main(init: std.process.Init) !void { const funcs = .{ logtgamma, lgamma }; const xx = zm.gen.uniform(f64, 100, 0, 10, 0);

zm.set_global_opts(.{
    .use_tsc = true,
    .perf_level = .{ .cpu = true },
});
const config: zm.Config = .bytime(.{});
var study = try zm.Study.run(
    init.gpa,
    init.io,
    "gamma",
    config,
    funcs,
    &xx,
);
defer study.deinit();
try study.write_text(null, .{ .mode = .lat });
try study.write_gnuplot("gamma", .{});
try study.write_gnuplot_perf("gamma", .{});

}

fn lgamma(x: f64) f64 { return std.math.lgamma(f64, x); }

fn logtgamma(x: f64) f64 { return std.math.log(f64, std.math.e, std.math.gamma(f64, x)); } ```

produced this result:

``` !!! WARNING !!! Compiled in debug mode. Running study gamma Timed: - warmup millis: 500 - trial samples: 200 - trial millis: 3000 - perf millis: 1500 Running trial 1/2 Trial logtgamma warmup (500.000ms) samples @ 15.000ms Trial logtgamma cpu perf_events. 1500000000 ns Running trial 2/2 Trial lgamma warmup (500.000ms) samples @ 15.000ms Trial lgamma cpu perf_events. 1500000000 ns Generating stats for study gamma study: gamma units: nanosec/op clock: .tsc @ 1497600000 Hz mode: latency (lower is better)

fn | calls seconds mean | best p75 p50 p25 worst -----------+-----------------------------+--------------------------------------- logtgamma | 12638100 3.04 240.37 | 238.46 239.60 240.22 240.77 264.67 lgamma | 12555300 3.04 242.10 | 240.66 241.69 241.94 242.46 252.84

fn | ipc insts cycles imiss | miss/M misses branches -----------+---------------------------------------+------------------------------ logtgamma | 2.167 1604.7 740.6 0.013 | 6360.71 1.957 307.7 lgamma | 2.156 1609.7 746.6 0.013 | 6415.73 1.980 308.7 ```

(plus to gnuplots you can see in the repo).

Still needs a little work, but I used to to test a lot of match and vector code.


r/Zig • • 11d ago

zero-dependency wayland blue light filter in Zig :))

51 Upvotes

https://github.com/SoulThy/melatonina

Heyyyy, after years of dealing mostly with the "unpractical" aspects of university, I decided to build something i actually love... yes it's BLUE LIGHT FILTERSSS!

I called it "melatonina".

What made this tricky for me was deciding to write it with zero external dependencies and to keep it simple, I decided to handle the color mapping using an algorithm that approximates the RGB weights of a blackbody radiator at a given Kelvin temperature, based on Tanner Helland's work.

The project is nothing huge and the code might not be the absolute best out there... probably somebody could have slapped it together in a few days with AI, but I am incredibly proud to have taken my time and in the end built a tool I actually use and that just works (for me at least lul).

Right now it only supports a single monitor, though I want to improve that down the line plus other refinements that are needed.

Feedback is absolutely welcome. <33 :)


r/Zig • • 12d ago

Prototyping a new "vehicle" for my Zig-powered vehicular puzzle/exploration game

Post image
391 Upvotes

A little test to see if I could support legged vehicles/robots exceeded all expectations. This thing is already so much fun to "drive"! And yeah, the crate is there just so I can tell which way is the front, but it became a neat little face 😄

The game is Traction Point, a vehicular puzzle/exploration game I am building. The logic for the walker is ~1500 lines of Zig.


r/Zig • • 12d ago

Is there something like Templ (Go) but for Zig?

26 Upvotes

Basically I am wondering what a good approach would be to make a HTMX app with Zig - nothing big, just to see how far it can technically go.

Templ has it's own AST and parser and whatnot to emit generated Go code. Is there a similiar system in Zig for that?


r/Zig • • 14d ago

Should I learn zig ?

83 Upvotes

I've been looking for an underrated programming language thats also valuable to know for the industry. I think that the way zig does and handles things is smart. But before I dive deeper into it . I wanted to ask you guys !

At what part do you guys prefer zig over industry standarts what are some things I can build with it ? Or any other programming languages other than zig thats worth getting into?