‹ 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. delamon · · focus · HN ↗
      They don't play nicely with arena allocators. And arenas is what you reach for if you have clear lifetime bounds: e.g. a single request with arena never de-allocates individual objects, nukes arena when done. That gives you an easy verifiable protection against leaks, data (and cache) locality and deallocation that cost zero cpu cycles.
      1. delifue · · focus · HN ↗
        Rust supports arena allocator <a href="https:&#x2F;&#x2F;docs.rs&#x2F;bumpalo&#x2F;latest&#x2F;bumpalo&#x2F;" rel="nofollow">https:&#x2F;&#x2F;docs.rs&#x2F;bumpalo&#x2F;latest&#x2F;bumpalo&#x2F; and the dropping plays well with arena as long as you use bumpalo::boxed::Box
Open on Hacker News to reply ↗

Unofficial Hacker News client; not affiliated with Y Combinator.