3 ms·
I love async/await, but it's not because it's "aesthetically pleasing". It's because having execution jump around from the outer body to the inner anonymous fun
by ajkjk 9y ago
I love async/await, but it's not because it's "aesthetically pleasing". It's because having execution jump around from the outer body to the inner anonymous functions fucks with all my intuition and, especially, with the way debuggers work.
If I want a series of steps to execute in order, I should be able to write them down in sequential lines of code, and it's, imo, a historical artifact that I was ever not able to do that -- because (oops), JS was traditionally conceived to have sequential lines of code execute immediately after each other, instead of blocking until they're able to proceed.
That is, it's not required that "single threaded language" meant "non-blocking execution" and thus required "callbacks and promises to do asynchronous behavior". It just ended up that way -- and we're finally (almost) free of it.
- always_good 9y agoThinking that it's a historical accident that everything is async in Javascript is a fundamental misunderstanding of async-everything.
- ajkjk 9y agoWant to elaborate? I disagree, but I'm happy to be corrected. Anyway, what I said was that it's a historical artifact that JS has a single thread of execution, and by that I meant, "it was standard to do that at the time that JS was conceived, so that's how it was done". If you were inventing web browsers today I don't think you'd ever intentionally choose to do it that way.
- z3t4 9y agoI think jumping between functions makes JS fun :P It really clicked with me when I learned how closures work, and to use named functions.