←back to thread

Zig is hard but worth it

(ratfactor.com)
401 points signa11 | 10 comments | | HN request time: 2.124s | source | bottom
1. sarchertech ◴[] No.36151194[source]
I tried Zig for a few weeks but ended up choosing Odin for a game dev side project I’m working on. Odin feels a lot more high level, but still gives you low level control when you need it.
replies(1): >>36151810 #
2. 59nadir ◴[] No.36151810[source]
I've settled on Odin as well and I think it's currently way ahead for game development than Zig is. Even for other things I'm currently more likely to write it in Odin, despite writing Zig from 2019 to 2022. The reasons really come down to error handling being better in Odin overall with payloads being attachable to errors as well as the context system and zero values making it relatively painless to really only talk about the things that need talking about and letting the rest be unsaid.

There are also several similarities: Custom allocators as part of the ecosystem and language, no RAII, easy ways to propagate and handle errors the right way, tagged unions with table stakes like exhaustiveness checking.

I think Odin and Zig have some fundamental differences (and plenty of similarities) and when trying Odin out I was surprised to find that I preferred the Odin way overall.

For gamedev stuff Odin wins due to a few things; swizzling on a code level is super nice, array programming built-in to the language, vendor libraries shipped with the language that allow you to just get going almost no matter what you're doing, and so on.

replies(1): >>36152362 #
3. truckerbill ◴[] No.36152362[source]
I want to invest in Odin but I see the velocity and growing mindshare that Zig has and I wonder if it's not better to settle for that. Also how do you find the compile times?
replies(3): >>36152942 #>>36154264 #>>36158510 #
4. 59nadir ◴[] No.36152942{3}[source]
I think by the time I have a massive project where compile times could actually hurt the newest endeavor with compiling to an intermediate form, etc., will already be released so it's likely that I'll dodge that entirely.

For what it's worth I haven't found any language constructs that seem to make the compile time grow considerably, so I think the risk of adding a library and suddenly being faced with massive compile times is fairly low in comparison to some languages. With that said, I'm only using the core lib and vendor libraries.

JangaFX by way of GingerBill reports that their 200kloc EmberGen[0] project takes 5 seconds to compile:

> On my old machine, it took 5 seconds, and now it takes 2.2 seconds on my new machine.

Before some paths in the compiler had multithreading added to them that number was 15 seconds for the same project. As far as I know both of these numbers are for unoptimized builds, i.e. development builds.

5. mr_00ff00 ◴[] No.36154264{3}[source]
Just looked at Odin and I really like the syntax, but I feel the same way. I feel like the community and ecosystem is the key elements and zig seems to be headed in the direction to grab that.
replies(1): >>36154844 #
6. sarchertech ◴[] No.36154844{4}[source]
They’re very different languages despite having some similar capabilities.

I also found the game dev libraries in Odin far easier to use then the ones in zig.

replies(1): >>36155064 #
7. mr_00ff00 ◴[] No.36155064{5}[source]
Yeah I did briefly look for zig game libraries and couldn’t find much.

I see the basic differences, but I’ll have to dig deeper.

8. Tozen ◴[] No.36158510{3}[source]
Part of "mindshare" are organizations pushing it on social media and marketing. Choose the language that solves your problems and that you like. Don't make a choice because a group is telling you what to like, is bullying others because they like something different, or are trying to shove something down your throat for their profit or benefit. Perfectly fine to have an independent mind, and make decisions best for you.
replies(1): >>36174577 #
9. truckerbill ◴[] No.36174577{4}[source]
Yes I definitely agree with that sentiment. Some things unfortunately happen faster with community support. Platform integrations, toolchains etc that require a lot of busywork. But I think I'll cautiously move with Odin regardless as I like how it's designed. Probably will end up learning both.
replies(1): >>36174997 #
10. 59nadir ◴[] No.36174997{5}[source]
I think this is a great idea. I would suggest joining the Discord server if you want to talk to like-minded people and immerse yourself in the language: https://odin-lang.org/community/discord/