>async / await

>async / await
Why is it so hard? How do you make sense of this concept?

Shopping Cart Returner Shirt $21.68

Tip Your Landlord Shirt $21.68

Shopping Cart Returner Shirt $21.68

  1. 2 years ago
    Anonymous

    its not, moron

    • 2 years ago
      Anonymous

      It's not hard when you use the readily-made executor like everyone. Try making your own executor from a minimal coroutine API like C++.

      • 2 years ago
        Anonymous

        >try reinventing the wheel!
        why?

  2. 2 years ago
    Anonymous

    Because it's stupid. Just use a modern language with concurrency at it's core aka elixir

    • 2 years ago
      Anonymous

      >aka Elixir
      thanks but I'll stick with Clojure

      • 2 years ago
        Anonymous

        Why not both?
        https://lfe.io

        • 2 years ago
          Anonymous

          Now you got me interested in Elixir. Thanks anon

    • 2 years ago
      Anonymous

      > Just use a modern language with concurrency at it's core aka Golang
      FTFY

  3. 2 years ago
    Anonymous

    I don't care, I just use use Fork::Manager;

  4. 2 years ago
    Anonymous

    >async: a function marked as async can use await, returns a promise
    >await: enter the named async function, when it returns its promise (which may be right away or after several more levels of nested awaitz) put it on the end of a queue then loop through the queue until one of the promises resolves (I/O is finished). Return to the function that awaited it, await now "unwraps" the promise.

    They are a way of combining coroutines, threads and promises with syntax that resembles normal code.

    • 2 years ago
      Anonymous

      Just build your language to handle coroutines and threads then promises and your extra syntax is normal code.

    • 2 years ago
      Anonymous

      What's the difference between threads and coroutines?

      • 2 years ago
        Anonymous

        coroutines are single threaded aka threads for children

      • 2 years ago
        Anonymous

        threads are an OS concept for a lighter-weight alternative to processes (they share memory and don't need to communicate via IPC) they're scheduled by the OS (and by the program if they're user threads)
        to run two different threads in parallel you need two hardware cores, the OS and the hardware interweave them

        coroutines are an abstraction for an operation that can (cooperatively) choose to pause itself and then be resumed
        to run two coroutines at the same time (debatable if it is "in parallel") you don't need multiple threads or cores

        basically: multiple threads are for things you can speed up by running more instructions, like computer graphics. (If you can) You divide the task between threads.
        coroutines for things you CAN'T speed up by running more instructions, like I/O. You can have a 1THz processor but it's not going speed up a disk drive or a packet going through the network. You pause the coroutine instead of waiting and go do something else.

        am i moronic or why does it feel so complicated? "returns a promise" what the hell is a promise?

        Instead of returning an X it returns a promise, from which at some point you can take out that X
        Like a bank transfer, your account isn't frozen until your transfer goes through, the money is removed and you get a confirmation (a promise) that that money will soon arrive at the account you sent to.

        • 2 years ago
          Anonymous

          >to run two different threads in parallel you need two hardware cores, the OS and the hardware interweave them
          *if you want to run more than the amount of cores you have, the OS and the hardware will interweave them

  5. 2 years ago
    Anonymous

    Depends where you use it. In dotnet where it was used first and built for, it's as easy as naming a variable. In JS it's implemented in a very moronic and unintuitive way.

  6. 2 years ago
    Anonymous

    >spin up the threads

  7. 2 years ago
    Anonymous

    It isn't that hard, even in JS. Why is it so hard for you?

  8. 2 years ago
    Anonymous

    I just make every call synchronous - if the content doesn't load, well, then it ain't gonna load.

  9. 2 years ago
    Anonymous

    Me? I just use Task for everything.

  10. 2 years ago
    Anonymous

    People werent meant to think in the 4th dimension

    • 2 years ago
      Anonymous

      >Hey Anon, can you clean the table why I prepare the food?
      Yeah, concurrency is HARD, lmao.

      • 2 years ago
        Anonymous

        More like can you clean the table unless I'm not cleaning and if I'm cleaning it mop the floor unless I'm moping the floor...

        • 2 years ago
          Anonymous

          Only if you program in a moron language that is not meant for concurrency.

  11. 2 years ago
    Anonymous

    am i moronic or why does it feel so complicated? "returns a promise" what the hell is a promise?

    • 2 years ago
      Anonymous

      an object that will hold the actual return value after the async function is done.

    • 2 years ago
      Anonymous

      Well first you make a promise and later on you have to resolve it.

  12. 2 years ago
    Anonymous

    play a funny game called Bitburner, it uses this functionality in its core gameplay

  13. 2 years ago
    Anonymous

    > make synchronous call
    > run for loop every second to check if the data is there
    OH WOW, THAT WAS SOOOOO HARD, I NEED AWAIT/ASYNC SISTERS!

    • 2 years ago
      Anonymous

      I tried making a multiplayer game in javascript and look at how it turned out
      https://pastebin.com/KNpjFtRP
      I'm never using nodejs as a backend ever again

  14. 2 years ago
    Anonymous

    You dont you just add await until it werks

Your email address will not be published. Required fields are marked *