• qqq@lemmy.world
    link
    fedilink
    English
    arrow-up
    51
    ·
    edit-2
    2 years ago

    Async features in almost all popular languages are a single thread running an event loop (Go being an exception there I believe). Multi threading is still quite difficult to get right if the task isn’t trivially parallelizable.

    • vext01@lemmy.sdf.org
      link
      fedilink
      English
      arrow-up
      9
      arrow-down
      2
      ·
      2 years ago

      Exactly.

      Also every time I’ve used async stuff, I’ve pined for proper threads. Continuation spaghetti isn’t my bag.

      • kunaltyagi@programming.dev
        link
        fedilink
        English
        arrow-up
        2
        ·
        2 years ago

        Which language? Usually there’s a thread pool where multiple tasks are run in parallel. CPython is a special case due to gil, but we have pypy which has actual parallelism

        • vext01@lemmy.sdf.org
          link
          fedilink
          English
          arrow-up
          1
          ·
          2 years ago

          I’ve only ever used it in those lua microcontrollers and in Rust with the async keyword.

          In lua I doubt they use proper threading due to the GIL. Rust probably can do async with threads, but it just wasn’t fun to work with.

          • kunaltyagi@programming.dev
            link
            fedilink
            English
            arrow-up
            1
            ·
            2 years ago

            Tokio has support for multiple threaded async in rust. As for micro controller, I don’t think you can have multiple threads in flight anyways, so that’s the best you’ll get

    • brian@programming.dev
      link
      fedilink
      English
      arrow-up
      3
      arrow-down
      1
      ·
      2 years ago

      A lot of languages have an asunc/await facade for tasks run on a background thread for result (c#, clj, py, etc), but it’s certainly not the default anywhere, and go most goroutines(?)/other csp implementations are probably going to be yielding for some io most of the time at the bottom anyway

      • qqq@lemmy.world
        link
        fedilink
        English
        arrow-up
        1
        ·
        2 years ago

        Yes I’m mostly familiar with this in Kotlin. Sometimes this is kinda a footgun because you’re writing multi threaded code without explicitly doing so.