← Home ← Back to /g/

Thread 105655980

15 posts 4 images /g/
Anonymous No.105655980 >>105656028 >>105656071 >>105656327 >>105656404
What's the point of async/await?
Anonymous No.105655991 >>105656050 >>105656267
Concurrency.
Anonymous No.105656001
the function immediately returns a Promise object so you can do other stuff while it waits on other Promise objects to resolve
Anonymous No.105656028 >>105656050
>>105655980 (OP)
Doing stuff and not blocking the main thread.
Anonymous No.105656050 >>105656102 >>105657179
>>105655991
>>105656028
But does the await keyword not block the thread?
Anonymous No.105656071 >>105656123
>>105655980 (OP)
> await delay
Anonymous No.105656102
>>105656050
JS only has a single thread and the runtime manages the job queue switching between tasks in an non-deterministic manner
Anonymous No.105656123 >>105656164
>>105656071
Yeah I pulled it straight from my scip so it's gotta go ok right?
Anonymous No.105656164
>>105656123
I mean, it will, the whole point of await though is you can start some processing somewhere else and then come back and get it later, not to immediately get the result. I guess if there was a GUI running in the background it wouldnt block during the delay 1s.
Anonymous No.105656267
>>105655991
javascript is single threaded
Anonymous No.105656327
>>105655980 (OP)
monads = bad
algebraic effects = good
Anonymous No.105656404
>>105655980 (OP)
Cope for not using a real programming language instead of babbys first webshit
Anonymous No.105656458 >>105656552
>Write entire program as async
>Await every function call
>The entire program is now snychronous
Cope and seethe
Anonymous No.105656552
>>105656458
i write code like this
Anonymous No.105657179
>>105656050
Nope.