‹ BackHN Continuity

Thread

What Zig felt like, coming from Rust

282 points · 351 comments · ksec

  1. Panzerschrek · · focus · HN ↗
    > Rust: Drop runs automatically at scope end, so this specific bug simply doesn’t exist.

    That's why having no auto-destructors is a dead-end. This is the greatest mistake of such languages like Zig or Odin.

    1. dnautics · · focus · HN ↗
      You can statically analyze for leaks.
      1. Panzerschrek · · focus · HN ↗
        But with static analysis it's still possible to miss some leaks or to have false-positives. That's why an integrated language mechanism preventing such leaks is much better.
        1. dnautics · · focus · HN ↗
          Yes, so you pick "false positives" instead of "missing some leaks" and you build a way to mark code as "unsafe".

          This is not fucking rocket science

          > That's why an integrated language mechanism preventing such leaks is much better.

          No categorical difference, except one is opt-in. You can even design your static analyzer so it analyses the code of dependencies that haven't opted in.

          1. estebank · · focus · HN ↗
            Making things opt-in means that it will happen less often, making them opt-out that they will happen more often. In this case, on the one hand you have destructors that don't run when they should, and on the other you have destructors running at a more granular level than you'd want sometimes. I know which human failure mode I prefer.
            1. dnautics · · focus · HN ↗
              In practice as long as you stick to using zig std, an analyzer can get quite far
Open on Hacker News to reply ↗

Unofficial Hacker News client; not affiliated with Y Combinator.