3 ms·
I hate the async pyramid because explicit continuation passing ought to be a low-level representation generated exclusively by machines, instead of by programme
by ufo 14y ago
I hate the async pyramid because explicit continuation passing ought to be a low-level representation generated exclusively by machines, instead of by programmers.
For example, one of the great things about high level programming languages is that you can write composable expressions such as
f(g() + h())
but you can't do that if f and g are written in CPS style, since then you need to give an explicit names to all the intermediate "registers" used in the computation as well as baking down an specific order of evaluation for things
g(function(a){
return h(function(b){
return f(a + b)
})
})
> Also, if your pyramid is too deep, chances are you need to extract some of it into functions.
This sounds like that "if your method is more then 15 lines you should split it into subfunctions". I never liked this line of reasoning because the complexity (number of possible interactions) in a module increases quadratically with the number of functions in it. You fight this complexity by only breaking down a function on "natural" boundaries dictated by encapsulation and reuse, rather then by code size.