• FizzyOrange@programming.dev
    link
    fedilink
    arrow-up
    4
    ·
    2 days ago

    Zig is way better than C in many other respects, so if you want a modern sane language and you’re either a Rust luddite or working on a project where memory safety isn’t that important, it might be attractive.

    Like, if the choice is C or Zig, then Zig is pretty much a no-brainer (or it will be when it hits 1.0). It just fixes so many insane things about C that have been broken for literal decades.

    • SorteKanin@feddit.dkOP
      link
      fedilink
      arrow-up
      2
      ·
      2 days ago

      working on a project where memory safety isn’t that important

      I can’t really imagine anything where this is not the case, unless you’re doing like… I dunno, small scripts for personal use or something? But why would you use Zig or C or even Rust for that, just do Python or even bash at that point? Python is memory safe and perfectly suitable for very small programs where static analysis gives little benefit.

      • FizzyOrange@programming.dev
        link
        fedilink
        arrow-up
        3
        ·
        1 day ago

        There are definitely some cases where memory safety isn’t especially important:

        • Single player games
        • Apps that don’t process external data (e.g. a simple calculator).
        • Lots of things running on microcontrollers, where the form of input could never possibly cause any security issues. E.g. a motor controller or a basic syringe pump or a (non-smart) washing machine or something.
        • Tests, e.g. I’ve considered writing RISC-V tests in Zig. They’re traditionally written in C or assembly.

        In cases like those, memory unsafety mainly leads to non-security bugs and annoying debugging sessions. But I wouldn’t say it’s as much of a deal breaker compared to e.g. writing a video codec or font renderer or web browser or DNS server or whatever.

        I still think Rust is a better choice than Zig in most cases anyway, even ignoring memory safety. But in these cases it’s at least a defensible choice.