Mutual help on zig gamedev

Hello everyone! I’m a professional game developer (I write C-like C++ for work, former AAA, now more like AA). I recently tried Zig and it seems to fit the programming style I’ve adopted for myself pretty well, so much that I’ve been able to learn the basics quite quickly. The toolchain is a beast!

Also had the chance to meet @MasonRemaley and the rest of the Core team at the recent Zig Day Milan and talk a bit about the game development prospects of Zig. In short, I think it’s really promising, way more than Rust, as a C/C++ replacement for this specific programming domain.

I was really inspired coding in the weekends and evenings some basic Vulkan code and seeing how ergonomic Zig makes to do the thing that I already know is right. This is why I really would like to start doing some personal projects in it.

One of the obstacles I found is that there doesn’t seem to be a dedicated space (that I could find) for game development in Zig. The information seems to be scattered all around, and the best source I could find is the zig-gamedev repository, which has a great set of starting libraries, although it leaves out some stuff.

What I think is missing is more of a mutual help space where people that are figuring out the same problems at the same time can offer and receive help. Maybe setting up a wiki or documentation on getting started on developing games, with example projects, etc…

So I have some questions: (a) is there such a space and I missed it? (b) if not, would it be helpful if I start working on something like this? Would you be interested in it?

26 Likes

There is a zig discord with a dedicated game dev channel that might be something? Is quite active as well. https://discord.gg/zig

4 Likes

I am a hobbyist who has played with the zig-gamedev repos. They are a lot of fun. I think posting here is the best way to contribute to the open Zig community, regardless of domain.

This is my favorite forum-style spot to get help in an open, searchable, asynchronous manner. I mostly lurk and favorite cool things I see, or I learn from questions people post, rather than being an avid poster myself.

There’s also a game tag that you could tag your game dev posts with so people looking for similar things will find your work!

5 Likes

If you do end up posting for help and posting work here, I’ll definitely be reading it myself! I can only speak for myself, but I imagine you’ll find lots of folks here who will check it out

1 Like

@IntegratedQuantum recently finished an update for this extremely cool voxel project they’ve been working on. The project thread is here: Cubyz: a voxel game written in Zig - #13 by tensorush.

2 Likes

Thanks for the resources! That helps.

I’m all for forums and asynchronous, searchable discussion.

What I was thinking was more along the lines of a chat or discord server where people that are actively working on games go to motivate each other. The more immediate nature of a chat in that case helps. And as well, with the objective of producing helpful content for others, libraries, etc., and results or more thoughtful discussion being shared on the forums here.

I’ll start by getting my feet wet with a personal project, but the idea is brewing in my mind.

Some more projects you might like to check out

There is somewhat active work supporting spirv shaders with zig, which mach is contributing to, aswell as their own zig gpu abstraction layer also wip.

godot bindings GitHub - gdzig/gdzig: Zig bindings for Godot 4

raylib bindings GitHub - raylib-zig/raylib-zig: Manually tweaked, auto-generated raylib bindings for zig. https://github.com/raysan5/raylib
you can also use upstream raylib directly, it is a zig package GitHub - raysan5/raylib: A simple and easy-to-use library to enjoy videogames programming

a roguelike made in zig Dungeon Wizard by Nuno Das Neves

I can recall others games and tools, but can’t find them rn.

7 Likes

A couple of things.

(a) Maybe?

But regardless I suspect the part-to-full-time Zig gamedev community is currently very small.

Other than Mason Remaley, Samarth Hattangady, Emi, and myself, I don’t know anyone else working on games in Zig at a commercial level.

Note: We all have blogs… I tried linking them above but Discourse forbid me from posting due to “maximum two links allowed” since I’m a new user… lol.

(My knowledge is limited though. If anyone else knows others working on their own games / game engines in Zig at a level that goes beyond the hobbyist, please let me know!)

As such I’m somewhat doubtful of what benefit such a space could bring as opposed to something like a meetup. If it’s only a couple of us working on games in Zig, maybe we should just arrange a monthly meetup instead? (But maybe we do it like Dave Pacheco of Oxide suggests with “watercoolers” where there’s a different set of expectations around attendance than with a meeting.)

(b)

As for the format… I’m not sure what you have in mind, but I strongly discourage choosing Discord for this. As Andrew Kelley blogged back in 2023 (“So Long, Twitter and Reddit”): “Discord has been decent for a while. I suspect enshittification will commence soon, so we should be on the lookout for an alternative over the next five years.”

Kelley’s prediction has already become true. While I’ve personally got value from using Discord over the years, my opinions about it have changed as it has changed. See for instance, Abner Coimbre’s excellent post on why Handmade Cities is moving off Discord.

I haven’t thought enough about this myself to have any suggestions as to what an alternative would be though. Maybe Revolt, maybe not.

6 Likes

I think many of us would enjoy a gamedev focused space to talk about zig. Even if we’re not active on the gamedev scene at the moment.

I have high hopes for zig becoming a fantastic language for gamedev.

3 Likes

While I am not using Zig for commercial game development yet as our current game is still in development which keeps me locked into Unity, I am already planning my escape from Unity once we are done. Zig feels like one of the strongest language options for game dev given a long term perspective, together with Odin and potentially Jai (though I haven’t tried it myself). I am going through Handmade Hero using Zig here, as way to collect more ideas and techniques beyond the thoughts I have collected from almost 10 years in Unity. Some of these ideas are starting to take form in this project.

Personally I would prefer something more like Ziggit over Discord because I find thread based communication more approachable than a chat. Collecting the disparate sources of information and ideas that currently exist about game development in Zig would definitely be useful, but I’m not sure what that would look like exactly.

5 Likes

Very cool. I love the watch filesystem, rebuild, reload… Once you’re hooked by unity all other game tools falls short. They can add a play button to godot, but I’d be surprised if they get anywhere near the good old Unity 4/5 days where things were still fast.

If only Unity hadn’t been coded by C++ developers they might have been better at making C# apis. Instead of making something that looked awesome in C++ and then using some playdough to make a C# api for the minimum viable sample.

With zig I’m hoping to have both game engine and game logic in the same language… I consider zig slightly harder than C#, especially in it’s current unforgiving state, with quite a few gotchas.

But to make C# run smoothly you have to… really know what you’re doing and essentially build your own memory management inside it to avoid the garbage collector… at which point Zig ends up being a LOT easier.

1 Like

I’m saying this as a former professional engine developer— C# isn’t a viable language for performant game engine development. Zig or Jai might be. I might be misunderstanding you, but I wouldn’t put all of this “programmed by C++ developers” ideological weight on Unity. I would suggest staying practical. Unity, like much software, has a lot of compromise solutions.

The idea of having engine and game logic in the same language is sound, but someone might prefer a scripting language for high-level game logic, depending on use case and how that specific team works.

I’m actually in the beta for Jai (Jon tends to let in game industry people). It’s quite awesome, really seems like a great fit for game development, if it ever releases. I think where Zig has the edge is in the toolchain, standard library, and cross compilation capabilities.

4 Likes

That was not a jab at C++ developers, it was a jab at having an engine language so far apart from the platform language… If you’re the kind of developer that are capable of writing a game engine in C++ while at the same time being an expert in C# well… I met very few of those when I worked at Unity ten years ago.

Awesome, I’d love to have access to play with Jai, I’ve enjoyed many of his ideas and there is a part of his comptime paradigme that resonates well with me, at least in theory. My main concern with Jai is that it rides on the whim on a single individual, but it certainly has potential.

Zig also has a BDFL governance model, which I’m fine with, so I don’t really see a difference. Obviously with the Zig foundation having been set up and everything, its governance structure is in a much more advanced stage. Jai at this point is proprietary code owned by a single business. Although, Jon has said he’d eventually open source it and set something up when he releases the language.

I’m all for adding a scripting language into a game, excellent for mods and level design, but if you want to build a voxel system in your game I’d hate to do it in Lua. :wink:

I don’t think making a game engine in C# is that much more dumb than writing an engine in C++ which then bridges into C# hundreds of times per frame… but you’re absolutely right, now that a bunch of new and better languages exists I’d choose any one of those over C#.

Zig is open source, it’s resistant to the bus factor and if people disagree too much we will have both Zig and Zag. BDFL has the strong advantage that it keeps the train going without being bogged down by committee. Any open source community is lucky to have dedicated people like Andrew and the rest of the foundation putting in so much hard work.

I have a few concerns with Zig particularly the current limitations in dynamic loading… but dynamic loading doesn’t rhyme particularly well with comptime lazy compilation in the first place, so I can appreciate that it’s not high on the priority list.

I asked for stronger contracts and interfaces, I didn’t get interfaces but looking at the new IO I’m not seeing anytype all over the place like candy instead it uses a struct for the contract. Perhaps that’s all I’ll get, but that’s the most important one.

I feel an interface keyword even if it was syntactic sugar powered by the current anytype logic would be better. As it would actually make anytype much more valuable. Almost no methods that has an anytype parameter will accept any type… an interface could articulate the expectations much better, leaving less need for the overly vague (yet insanely powerful) anytype.

This ended up sounding like Jon and his people isn’t doing the same for Jai. That was not my intention! I believe that when he says he’ll open source it that means he will, it just has the unfortunate legal distinction that it’s not open source yet. It’s not immune to the bus factor and I can’t play with it yet. :wink:

1 Like

Oh, fully agreed there.

Unironically, I really like IRC, but it’s not very popular with the cool kids today. I see the same problems as you see with Discord; I’ll have to think about what to choose.