Faking Co-Routines, or Why Callback Hell Is Over (2014)
pandastrike.com
Faking Co-Routines, or Why Callback Hell Is Over (2014)
1–10 of 24 posts
Re: Faking Co-Routines, or Why Callback Hell Is Over (2014)
#2Re: Faking Co-Routines, or Why Callback Hell Is Over (2014)
#3Re: Faking Co-Routines, or Why Callback Hell Is Over (2014)
#4These days I write JavaScript using only functions, literals, variables, and the occasional prototype and it's amazing.
I think many programmers have a desire to believe they are working on complex problems that demand sophisticated tools. I remember learning Ruby and being excited whenever I found a reason to write a DSL. In retrospect it was unnecessary every time. In every case the code would've been clearer if I had just stuck with functions and kept refactoring until I had the right interfaces and data structures.
It helps to remember
function a() {
b(function() {
//etc
})
}
is equivalent to function a() {
b(c)
}
function c() {
//etc
}
which is not particularly more verbose. And as a side benefit, refactoring that way gives you an opportunity to make c() self-documenting.Re: Faking Co-Routines, or Why Callback Hell Is Over (2014)
#5Re: Faking Co-Routines, or Why Callback Hell Is Over (2014)
#6I have yet to see an "improvement" on callbacks, whether it's promises or fibers or generators, where the benefit in readability is worth the havoc it wreaks on my ability to debug the program. These days I write JavaScript using only functions, literals, variables, and the occasional prototype and it's amazing. I think many programmers have a desire to believe they are working on complex problems that demand sophist…
> function a() { b(function() { //etc }) } is equivalent to
> function a() { b(c) } function c() { //etc } which is not particularly more verbose. And as a side benefit, refactoring that way gives you an opportunity to make c() self-documenting.
It's not always equivalent, since you can have closures.
Re: Faking Co-Routines, or Why Callback Hell Is Over (2014)
#7I still don't get why async/await is inherently better than using Promises/Streams. Is it purely a syntax difference or is there a semantic difference as well?
Re: Faking Co-Routines, or Why Callback Hell Is Over (2014)
#8This makes it impossible, for instance, to write a nice I/O library that is to be called from within a generator (the library is supposed to yield on a blocking situation).
Re: Faking Co-Routines, or Why Callback Hell Is Over (2014)
#9I have yet to see an "improvement" on callbacks, whether it's promises or fibers or generators, where the benefit in readability is worth the havoc it wreaks on my ability to debug the program. These days I write JavaScript using only functions, literals, variables, and the occasional prototype and it's amazing. I think many programmers have a desire to believe they are working on complex problems that demand sophist…
Re: Faking Co-Routines, or Why Callback Hell Is Over (2014)
#10I don't understand why he talks about a javascript problem being solved, then goes on to show us examples in coffee script.