Why Zig over C for Systems Programming

(mtsoukalos.eu)

103 points | by torutofu 2 hours ago

11 comments

  • uecker 6 minutes ago
    Zig is a nice language, but those articles always compare new languages against old-style C without use of modern tools. Most of the listed advantages you can have in C as well if you are willing to adopt modern tooling and style: signed overflow checking: sanitizers, errors you can not ignore: [[nodiscard]], slice type which know their size: variably-modified types or span types.

    Defer will also appear in C compilers soon, but personally I still think goto-error handling is clearer.

    (Rust has an advantage for temporal memory safety, but this does apply to Zig.)

  • kombine 19 minutes ago
    D and Nim have had the same features for years btw.
    • tcoff91 10 minutes ago
      God I loved playing around with D back in the day when I was in high school. It seemed like a no-brainer that it was going to be huge. It's such a shame it never took off. Incredible language.
  • drnick1 5 minutes ago
    All these new languages are unreadable relative to C. If, like me, you like explicit stuff like for (size_t i = 0; i <= n; i++) total += a[i]; all these new languages won't do it.
    • epolanski 3 minutes ago
      Anything is less familiar when you come from a certain background.

      Study after study has shown that in coding we tend to fall back to conflate simple with familiar.

  • pron 48 minutes ago
    Also, Zig is as at least as expressive as C++ (but without the implicitness and general language complexity that makes reviewing some sensitive code, where you need to see exactly what operations are performed, hard), and it supports arenas better than C/C++/Rust.
    • positive-spite 30 minutes ago
      To anyone interested in arena allocators.

      Rust just stabilized its `Allocator` API in version 1.100.0. Definitely worth checking out!

      • Bigpet 14 minutes ago
        Seems like a long way to walk though. Retrofitting this will take time (if it'll ever complete). Zig made it a core part of the language and library. I'll assume Rust will make it farther than C++ ever made it, but just take a look at how retrofitting custom allocators is going there.

        Seems like it will be useful for use-cases like embedded where you're restricted to certain parts of the library anyway. But the battle is kind of already lost for support at the level of Zig or Odin. Even if they retrofitted support for the whole standard library, they'll never be able retrofit all crates or make people even bother adding support for all new crates.

    • coolThingsFirst 31 minutes ago
      show me operator overloading in Zig
      • pron 15 minutes ago
        In critical low-level code, any kind of overloading - operator or otherwise - is something you'd rather not have.

        By expressivity I don't mean conrecte syntax, but the number of lines needed to express an algorithm (up to a small constant). C doesn't have C++'s expressivity because it lacks templates, and while you can sort of express that kind of thing with macros, it's not all the way there. Zig, however, gets you all the way (you might need to write matrix_plus instead of +, but the expressivity is the same).

      • melodyogonna 12 minutes ago
        Many people are against operator overloading, imo my only issue with C++ operator overloading is that you're allowed to overload the the assignment operator. From what I can see this is the root of many issues
      • u8080 18 minutes ago
        please no
      • nvme0n1p1 25 minutes ago
        Yes! And exceptions and inheritance and RTTI too. Bring back all the mistakes! Let's party like it's c++99
  • pipeline_peak 1 minute ago
    Zig will never be successful.
  • program 36 minutes ago
    > Errors you cannot ignore

    It's okay for me to declare a macro with `__attribute__((warn_unused_result))` for GCC and Clang, and `[[nodiscard]]` when the C code is later compiled with C++ (or nothing).

  • mogoh 33 minutes ago
    Is Zig stable yet? No.
    • ginko 31 minutes ago
      I like Zig but having to fix a bunch of version issues each time I touch an old zig project of mine really put a damper on my enthusiasm.
      • mi_lk 11 minutes ago
        to save your enthusiasm, tell your clanker to fix version issues instead
  • fithisux 14 minutes ago
    C is far behind the sate-of-art in C and Go families. True, but not bad.

    It is what it is, but can work on what it already has, while keeping its tradition. Small changes, add common extensions, conservative additions, improve coherence and correctness of the standard while keeping easy to implement and small.

    No crazy things.

    Keep in mind that it is standardized and targets things others do not target.

  • raverbashing 53 minutes ago
    Yeah

    The lack of a native slice is the most glaring C fault I think exists

    (And of course the committees won't implement it, and of course C is going to remain broken)

  • nvme0n1p1 1 hour ago
    AI slop. Every article on this site has "The honest tradeoff" as a header. Looks like it was generated to promote a book which is no doubt also just slop.
    • eatonphil 16 minutes ago
    • raincole 20 minutes ago
      I don't know if this Zig over C article is generated, but the Zig over Rust one [0] is painfully AI-written.

      I'm not ideologically against AI, but I'd certainly not buy a book from someone who needs to use AI to write like an article like that...

      [0]: https://www.mtsoukalos.eu/2026/04/why-zig-over-rust-for-syst...

    • ivanjermakov 11 minutes ago
      Doesn't read AI generated at all.
    • AlexeyBrin 48 minutes ago
      Let's not exaggerate, it took me 2 seconds to find another recent article from the same website without the "The honest tradeoff".
    • ibn_khaldun 38 minutes ago
      > Every article on this site has "The honest tradeoff" as a header.

      This is a hallucination. I'm sorry. This is what we call these kind of statements these days. Unless you can prove your humanhood, that's how it is now.

  • llm_nerd 1 hour ago
    I wrote recently about a weird issue I encountered with Zig, though to be fair it was related to using Zig to compile C code, humorously in a Rust project (which touches on all of the languages mentioned in this post).

    https://dennisforbes.ca/blog/microblog/2026/10/the_accidenta...

    While I did just dismiss it as an edge issue, it turns out that this same rather clumsy sort of mistake has happened repeatedly in Zig's pure rewrite of MUSL. And despite being an absolutely catastrophically bad problem, by my judgment, the problem is still in main at this moment, across a wide number of musl function rewrites.

    Which gives me pause about the whole zig project. If you're rewriting a critical library, making such simple but consequential mistakes shouldn't happen, and if they do happen it should be a red alert type situation.

    • lukaslalinsky 24 minutes ago
      When working with Zig, you are a beta tester. The development process is unfortunately not great, so bugs slip in fairly easily. You need to be ready for it and test your application properly. Large Zig projects don't target the latest version. That said, if you can deal with that, you get a great language that is fun to use and very practical. I think it's worth it, even if it can be frustrating at times.
    • stateoff 1 hour ago
      Why not adding the link to the issue in the blog post?

      https://codeberg.org/ziglang/zig/issues/37402

      Looks like it is being worked on.

      Personally I think it's not that catastrophic for zig < 1.0. Just a performance regression, and one can always link to other libc implementations, or is their own implementation enforced now?

      • dleslie 1 hour ago
        If errors like this are acceptable because of the version number of an otherwise decade old project, then that's ample evidence of why Zig is not ready and should not be used for any software that needs surety.
        • Joker_vD 56 minutes ago
          You know that GNU libc to this day essentially calls strlen() on every call to sscanf(), which is pretty much the same issue? And that this behaviour, present in many other implementations of standard C library (including Microsoft's), was responsible for e.g. slow JSON parsing in some very popular online games [0]? Does that mean glibc is still not production-ready?

          [0] https://news.ycombinator.com/item?id=26296339

          • dleslie 34 minutes ago
            sscanf is quadratic in the worst case, and has been flagged along with the bulk of the rest of the libc string support as being hazardous or potentially harmful. Its continued existence is for compatibility, but new projects should not use it.
        • stateoff 58 minutes ago
          https://blog.jetbrains.com/blog/2026/06/05/why-zig-isn-t-1-0...

          I did not say it's acceptable, just not catastrophic, especially since workarounds exist.

          I've used zig in similar capacity in production in the past and personally I would take the slowdown just to avoid dealing with MSVC :)

        • nvme0n1p1 1 hour ago
          When you're setting expectations about a project, it's never a bad idea to listen to the creators themselves.

          https://ziglang.org/download/0.17.0/release-notes.html

          > Zig has known bugs, miscompilations, and regressions.

          > Even with Zig 0.17.x, working on a non-trivial project using Zig may require participating in the development process.

          > When Zig reaches 1.0.0, Tier 1 support will gain a bug policy as an additional requirement.

    • drdexebtjl 52 minutes ago
      strchr has no time complexity guarantees, by the way. This behavior is strictly correct.
    • dnautics 1 hour ago
      > Which gives me pause about the whole zig project

      The whole zig project is like six people in a trenchcoat. You can't expect them to prioritize your one thing after 3 weeks

      Did you make a PR?

      • MonstraG 1 hour ago
        I'm not the poster, but I found the related issue:

        https://codeberg.org/ziglang/zig/issues/37402

      • llm_nerd 1 hour ago
        It isn't my thing though. It's quite literally, by choice, their thing. They are the ones who decided that rewriting musl in zig was something they need to do and was such a priority. Only it's a serious regression.

        But I mean, the six people in a trenchcoat comment is basically precisely what should give people pause. In my project I simply eliminated zig from the stack entirely because even if I worked around the problems, what comes next? What's the next showstopper that gets waved away as oh well six people in a trenchcoat...

        Eh, whatever.

        • nvme0n1p1 1 hour ago
          It's a 0.x project, let them cook. Building things takes time.

          https://ziglang.org/documentation/master/std/#std.mem.findSe... didn't exist then, now it does.

          And if i may quote from https://ziglang.org/download/0.17.0/release-notes.html:

          > Zig has known bugs, miscompilations, and regressions.

          > Even with Zig 0.17.x, working on a non-trivial project using Zig may require participating in the development process.

          > When Zig reaches 1.0.0, Tier 1 support will gain a bug policy as an additional requirement.

          If you're not willing to participate in the development process, then you should wait or use something else.

          • simonask 39 minutes ago
            Isn't that exactly what they're saying?

            Some people (not its creators) talk about Zig as if it's anywhere near production ready. It's fine to be excited about it (there's a lot to be excited about), but we gotta be realistic.

            • dnautics 30 minutes ago
              No, the framing "give pause" is the sort of framing that people create FUD create
            • nvme0n1p1 25 minutes ago
              Zig team: "Zig is 0.x and has known bugs"

              llm_nerd: "I found a bug. This gives me pause about the whole zig project"

              I don't see how the latter is a fair reaction given the former. Especially since they only recently started working on the libc port (although it had been talked about for much longer)

          • diffxx 31 minutes ago
            They have been cooking for over ten years. It is more than fair to say at this point that they are not capable of shipping a stable, reliable, fast and efficient compiler. It is fundamentally flawed and I could easily write thousands of words explaining why from the architectural design to the development process.

            Zig hides behind its pre 1.0 status to justify poor decision making while simultaneously actively trying to attract attention through marketing. That attention translates to resources and influence that are undeserved on the technical merits.

            • nvme0n1p1 16 minutes ago
              > I could easily write thousands of words explaining why from the architectural design to the development process.

              Alright then go for it, hotshot. We're waiting.

          • acedTrex 31 minutes ago
            The dudes name is "llm_nerd" its not worth engaging lol. These are the same people that saw the bun rewrite in rust break tls and fail open and shrugged.