11 ms·
Zig gamedev project – left my job to build games in Zig lang
- michal-z 5y agoI'm using Zig language full-time to create an indie game. Also, I've created zig-gamedev project to build game development ecosystem for this language. Using DirectX 12 for rendering, Bullet for physics. I'm ex-AAA game developer and graphics programmer.
- SrslyJosh 5y agoAny plans for multi-platform in the future?
- michal-z 5y agoNo, sorry, it will stay Windows 10+ only. I want to focus on building interesting stuff (demos, games, audio-visual experiments) I don't have bandwidth to support and maintain code for several platforms.
- Rygu 5y agoWhy Zig?
- indymike 5y agoWhy not Zig? Its a pretty fun language...
- AnIdiotOnTheNet 5y agoWell there are still quite a lot of compiler bugs. I personally have open issues going back as far as 2018. Knowing the compiler has bugs and that new ones are constantly being discovered makes debugging a pain because you have a lot less confidence that the problem is your code. I have many times blamed the compiler for my mistakes, something I've almost never done with C.
- indymike 5y ago> I have many times blamed the compiler for my mistakes, something I've almost never done with C. Early on, I remember dealing with lots of bugs in C compilers in the mid and late 80s. It takes time.
- pjmlp 5y agoPersonally I dislike the @ love, feels a bit like being in Objective-C land, imports feel like JavaScript AMD modules, and still use-after-free issues. Otherwise it is pretty much Modula-2, with C flavoured syntax and compile time execution. Overall, the use-after-free is what irks me.
- dnautics 5y agoNot OP, but here is what I can think of: - Low level - great C interop - Good toolchain ergonomics, except for no pkg manager yet - Great cross-compilation - Fast compilation (incremental coming soon) - Ideal for things where ownership rules can get complicated (ECS e.g.)
- genocidicbunny 5y agoThe C interop is especially useful for gamedev since so many libraries have a C interface and thus can be relatively easily used in Zig.
- collegeburner 5y agoIntersting, some follow up questions: - Fast compilation: isn't it llvm? So how faster compared to C++/Rust/others that use it? - Ownership rules/ECS: what about zig makes this especially good? The only language that comes to mind in this respect is Rust and its borrow checker, is it similar in Zig?
- runevault 5y agoPart of Rust's problem last I knew was it throws a lot more than it necessarily has to at the LLVM backend. So a front end that takes the time to lessen the burden could run faster despite using the same tooling.
- actuallyalys 5y agoPart of it (perhaps the majority) is excessive intermediate code. But at least some of it is that Rust's abstractions are more complex/involved. The "zero cost" doesn't refer to compilation time.
- runevault 5y agoIs that part paid in the Rust or LLVM portion of the compiler chain?
- klyrs 5y agoBecause zig needs better game development tooling!
- zarzavat 5y agoZig is like C but better. It fixes all the pain points of C without adding any extra complications (Rust - borrow checker, Go - GC, C++ - everything).
- pcwalton 5y agoMemory safety is a pain point of C, and Zig doesn't fix that. There is no free lunch: you either accept garbage collection or deal with something that resembles the borrow checker.
- kristoff_it 5y agoYou could build the same argument for all other types of correctness: either your program is formally validated to be correct, or it's broken. While there is some truth to that, if that's the only analysis you're willing to do, then you're going to fail spectacularly hard at recognizing the advantages of TypeScript over JS, for example. Zig and C share a similar relationship across many axes, including memory safety.
- pjmlp 5y agoFrom my point of view in terms of memory safety with Zig, we could just use Modula-2 or FreePascal/Delphi instead, but they aren't as fashionable.
- speed_spread 5y agoAs much as I love Delphi, the language syntax hasn't aged well. Single pass compilation was great to have in the 1980's but nowadays even the humblest Raspberry Pi will chew through thousand of lines of C++ and link an optimized executable within seconds. We deserve and can afford a lot more comfort than Pascal (and siblings) provides. Incidentally, modern language ergonomics also adds much in the way of coding safety, making usage of explicit allocation control a more manageable problem than it was 30 years ago.
- pjmlp 5y ago
- klyrs 5y agoThis is really looking great! You say you left your job... do you have income yet, or is that an item on the todo list? Any clues about the game you're working on?
- kristoff_it 5y agoMichal has a GitHub Sponsors profile, people that are interested in what he's doing should consider supporting him there. https://github.com/sponsors/michal-z https://github.com/sponsors/michal-z
- Shadonototra 5y agoCongrats! Full time indie is a fun and scary adventure at the same time, good luck! One question, why DX 12? i'm kinda sad when i see indie choose proprietary non-portable tech.. Not to say that vulkan is better (i hate it), but i'm curious
- genocidicbunny 5y agoIf the OP is an ex-AAA graphics programmer, DX12 is probably more familiar than Vk. AAA likely means consoles which at the very least means you end up doing DX12x for Xbox, and at that point you may as well also do DX12 for PC.
- Shadonototra 5y agoWell the most popular consoles doesn't use DX at all Switch uses GL/Vulkan And the PS4/5 uses something akin to Vulkan On PC Vulkan is probably more used than DX12, i can't remember the time i seen DX12 in a setting.. i think i only seen it once..
- skocznymroczny 5y agoCould be personal preference. I worked with OP at Intel during the early days of Vulkan and he was the go-to person for anything Vulkan related, so he's certainly familiar with the API.
- Shadonototra 5y agoWell, that is not a pragmatic approach to make games, specially for indies, to just target one graphics API, that limits the audience you can reach We solved this issue already with WebGPU, it uses what ever is native to the platform you target.. https://devlog.hexops.com/2021/mach-engine-the-future-of-graphics-with-zig https://devlog.hexops.com/2021/mach-engine-the-future-of-gra... Everyone wins
- slimsag 5y ago(I'm the author of that post) Michal is a seasoned AAA dev who has worked at AMD, Frostbite, EA DICE, Intel - I'm sure he knows exactly what tradeoffs he's making. Different folks have different goals, and that's OK. My goal with WebGPU is to aim for a future where we have truly cross-platform graphics. I suspect your goal is similar. But I don't think it's wrong to aim for the present, to use an API you're familiar with, or to want to get as low-level as you can get. That's pretty admirable, honestly, and I'm happy people are doing that in the Zig ecosystem. Heck, maybe one day Michal's work with DirectX here leads to a DirectX backend for a Zig WebGPU implementation. :) Experimentation is good.
- losvedir 5y agoWhat's the game? I guess based on DirectX it will be for Windows only?
- cyber_kinetist 5y agoThe tech looks really great. What kind of game (genre) are you planning to make?
- cardanome 5y agoZig is a really interesting language for game dev. I was thinking about using Zig with raylib for my next project. The show stopper was that C ABI compatibility is not yet complete: https://github.com/ziglang/zig/issues/1481 https://github.com/ziglang/zig/issues/1481 I could have probably worked around it but decided to go the C and Lua for scripting route for now which works great but I can totally see Zig as a decent C replacement. I am not interested in Windows but I am wishing you best of luck with your project. Seems quite interesting.
- dralley 5y agoOne of the nicer things about Zig is that the unoptimized debug binaries are still pretty fast, often only 2 or 3 times slower than the optimized ones rather than 10+ times slower. Presumably because Rust and C++ have a lot of abstractions that have to be sent through the optimizer to be truly "zero-cost". That, combined with generally really fast compiles (again relative to C++ and Rust) is a nice combination for game devs.
- fallat 5y agomichal-z, how do you survive month to month having left your job?
- fouc 5y agoI think most people in that situation would have saved up a lot of money so that they can support themselves properly during that period of time between jobs or between sources of income.
- egypturnash 5y agoNo actual games yet, just a few rendering tests. I suggest starting with something simple but actually playable, like a clone of Zero Wing.
- unwind 5y agoIf anyone thought this was an oddly specific remark (as I did), I looked it up. The 1989 Namco/Toaplan side-scrolling arcade shooter "Zero Wing" [1] is has two notable facts that make it a fun reference here: 1. It's the game from which the "all your base" meme comes. 2. The fighter craft that the player controls is called "the ZIG". [1]: https://en.wikipedia.org/wiki/Zero_Wing https://en.wikipedia.org/wiki/Zero_Wing
- egypturnash 5y agoI cannot believe I had an opportunity to make an AYB reference in 2021 but here I am. The fact that nobody else had made one, or has made one, in reply to this post leaves me feeling old. Move every ZIG; you know what you doing.
- gavanwilhite 5y agoGame dev is a great move with this. Async stuff is interesting to see
- haberman 5y agoI think Zig is great and I'm following it with interest. But I think people should be aware that it is not really stable yet, at least in my experience from trying it earlier this year. I ran into a compiler crash: https://github.com/ziglang/zig/issues/7865 https://github.com/ziglang/zig/issues/7865. I attempted to fix the compiler crash myself (https://github.com/ziglang/zig/pull/8372 https://github.com/ziglang/zig/pull/8372), and I found a fix that worked, but apparently it was not the right fix, and I was told the correct fix would be "quite hard" and "To fix some of the bugs you would need to rewrite quite a bit of code." It sounds like a big milestone will be when Zig's stage1 compiler is self-hosting, written in Zig instead of in C++. I got the sense that the C++ code I was modifying is somewhat crufty, and the Zig version of it will be better designed in many ways (ie. https://github.com/ziglang/zig/issues/89#issuecomment-382110023 https://github.com/ziglang/zig/issues/89#issuecomment-382110...), which will make fixing bugs like the one I encountered will be more tractable. I personally will be interested to revisit Zig when this migration occurs. I also found that the language was changing from release to release in ways that made me update the code. This is all totally reasonable for a language in development, and I mean no disrespect to the Zig devs -- it's an extremely interesting language. I only say this because stories I saw on HN gave me an impression that Zig was farther along than it is, at least in my experience.
- bagels 5y agoWhy would they spend the effort on writing the zig compiler in zig?
- TheApexTheater 5y agoThere are a couple of reasons why creating a self-hosting compiler can be good idea: 1. Shows to others that your language is capable of a project of moderate complexity, as well as display what an "idiomatic" version of writing code is 2. Remove dependencies on parts you can't control (once you rewrite it in Zig, rather than C++, you don't need to worry about new C++ features or deprecations between versions) 3. Writing code in the language helps catch bugs in the language specification and in the compiler's implementation of the language. These are just the ones off the top of my head, but people with more PL-Design experience may be able to elaborate.
- DeathArrow 5y agoAs a former game developer, I don't get why the people start from scratch by developing their own rendering engines or even game engines. Using Unity, Unreal or even Godot is helping you to launch your game 100x faster. I know it might be fun to develop your own engine but it will take a lot of time and it still won't be as usable as an engine developed by 100x more engineers.
- dgb23 5y agoAs with everything it would depend on the type of thing you’re making and whether you rather deal with problems of an existing solution or the ones you imposed yourself. Even ignoring that. I think there is a more fundamental question here as well. What type of maker do you want to be?
- mbrodersen 5y ago100% agree. I don’t know why you were downvoted. I assume that some people hate it when you dare to talk reality. I have run my own successful game biz for 5+ years and have written more than one commercial game engine that was used to release commercial games on consoles and PC. And I 100% agree with you. Unity (for example) will make you at least 10 times more productive than writing a 3D engine from scratch.
- michal-z 5y agoIt depends on many factors. You are describing your experience and then extrapolate for everyone. My game will be pretty small, not fully 3D. I don't need 90% of Unity features and Unity bugs :) Before making my decision to go with Zig I've built small game in UE5 (https://michalziulek.itch.io/upacman https://michalziulek.itch.io/upacman). I've also used UE5 and Unity at AMD. I simply don't like those engines. Different people have different approaches and mindsets. I'm much faster building my small, minimal codebase that does only what I need. Also, I'm improving my low-level programming skills and experimenting, doing things differently than most people (not using Unity) might lead to very original game.
- 5y ago
- lelanthran 5y agoI don't really get the "I Left My Job to write $FOO in $BAR language" reason. I can understand if someone left their job to write $FOO - you see an opportunity and you take a risk on it. What does the language have to do with it? To me, taking such a risk, and then adding further risk (using a language you weren't using daily) seems to be a recipe for disaster. If I were taking a risk (by leaving my job) on a new product, I would do my best to reduce all the other risks (use a familiar and popular tech stack, for one).
- mbrodersen 5y agoAgree. If you want to create games for a living then you need to think game design/business first and tools second. The hardest part of doing games is coming up with compelling game designS that people actually want to pay $ for. Tech is very low on the list of what’s important.
- ramblerman 5y agoAs someone who did something similar in my youth my argument was that the new language presented unparalleled productivity opportunities vs the “old” The real reason was of course that I wanted to play with the new thing. You are right, Market fit and the idea matter most (when assessing a new company) But not all ideas should be weighed purely on profit. If op is in a healthy financial state and can shoulder the risk for a year, it’s hard to weigh the opportunity risk for him as a person. It might reinvigorate a love for programming or lead to a job in this new language. And ofc it may also just work ;)
- _vvhw 5y agoYou're not factoring in the fairly huge opportunity cost of missing out on a major technological wave, not being one of the early domain experts, not to mention all the benefits that come with riding the wave. Zig is perfect for game developers, and being one of the first in the space is going to be an advantage. Also, the product here is actually defined as "Building gamedev ecosystem for @ziglang!" — Zig itself is part of the strategy here.
- dragonelite 5y agoSometimes you just need to do something different then working for a boss. We are in a privileged position that some can work 1 month and use it to live 2 comfortable months off it. Why not take some risks in life.
- travisgriggs 5y agoIs anyone using Zig on embedded micros yet? M0/M3 or so? I do a bit if C code on st micros and Atmel chips, I’d love to have a modernized C in this world.
- mpbeauj 5y agoAm I missing something? What makes this an "opportunity"? How isn't this just 100x worse than using Unity?
- HugoDaniel 5y agowill it work on iOS?
- bodge5000 5y agoI do a bit of game dev, and whilst I've been really interested in getting into a framework rather than using an engine, so far I haven't been able to budge from Godot. So my question is, why is Zig so good for game dev specifically (thats by far the most common use I've seen for the language so far, in my limited dealings with it)?
- michal-z 5y agoHi Guys, OP here. > Why not Unity or UE5? Why Zig? I'm building relatively small game, I don't really need full game engine. I try to write simple code that does only what I really need. I want to push Zig forward, I want to promote it. I was working with UE5 and Unity at AMD - those engines are really huge, bloated and they are changing very fast. I want to keep control over my code. Again, I don't need 90% of their features. I like low-level stuff and I want to master my skill. > Why zig-gamedev project? I want to help others learning Zig. I want to create demos, audio-visual experiments and even some art stuff. I'm interested in intersection of art and science. I want to prototype and experiment with ideas that potentially will be used in game (tech, algorithms, etc.). > Why Windows and DX12? DX12 is really well supported by Microsoft. They have great tools. They have interop with Direct2D and DirectWrite. They have DirectML (built on top of DX12). Windows itself has builtin decoders for most video formats (I will need this and I don't want to include entire ffmpeg). I'm most familiar with DX12. DX12 is a bit less verbose than Vulkan. I don't have a bandwidth to care about other platforms. Focusing only on Windows lets me write simpler and often more optimized code. Also, drivers are really mature and stable. > Why to take risk? I was working for big corporations for ~12 years now. Money is good but you don't really realize your ideas there. You don't own what you build. Now, I want to create my own stuff, my way, using my ideas. Money will come later.
- FieryTransition 5y agoHow is zig compared to nim, where you can also disable safety(even disabling the gc)? To me nim seems more "ergonomic", but they both try to hit the same problem space.
- FieryTransition 5y agoAsking since I want to build a ray tracer and voxel engine in nim as a side project at some point. But I really like the approach of high level safety and optional low level performance from both languages. I was considering Rust, but I don't like having to deal with the borrow checker all the time.
- megameter 5y agoNim is a little bit more straightforward for writing application code, by dint of simply having more features to throw around. Both languages can be pretty darn fast, enough that I would not rate it as a factor for most applications, including rendering side projects - the speed difference we are talking about really has to do with how detailed your resource allocation methods are, and if you want that form of speed you have to invest time researching memory access patterns for your use case to get beyond educated guessing. So you would have to turn your voxel engine into full-time work to get to the point where it has both usefully broad functionality and top-end performance. Expect some maturity/stability issues with either one. Zig is much earlier in its lifecycle and I have seen showstoppers, but it's also been moving faster. Nim has struggled in the past with stabilizing its high-concept features - use it mostly like C and it's fine. Zig's biggest appeal is in how close it is to a fully bootstrapping environment - low level, clearly defined control over all resources is just what you want if you are writing a kernel.