• solrize@lemmy.world
    link
    fedilink
    English
    arrow-up
    7
    arrow-down
    2
    ·
    2 months ago

    Sure you can spawn threads but now you have all the hazards of shared memory and locks, giving the 2.0 version of aliasing errors and use-after-free bugs. Also, those are POSIX threads, which are quite heavyweight compared to the in-process multitasking of Golang etc. So I would say that’s not really an answer.

    • Zykino
      link
      fedilink
      English
      arrow-up
      1
      ·
      2 months ago

      They are OS threads (so yes heavy).

      But I think if you manage to use-after-free or other memory error in safe Rust it’s a compiler bug. Or you used unsafe and have a soundness issue in the code you did.

      Note : as I understand it, unsafe is a way to tell the compiler you can check its safety guarantees yourself. But you may fail and get back other languages inexistent guarantees.

    • bamboo@lemm.ee
      link
      fedilink
      English
      arrow-up
      1
      ·
      2 months ago

      What exactly are the hazards of shared memory and locks? The ownership system and the borrow checker do a pretty good job at enforcing correct usage, and if you are clever you can even guarantee no deadlocks (talk at rustconf 2024 about the fuchsia network stack).