3 ms·
I think I'm the only one in this world who doesn't mind the async pyramid. To me, it is very intuitive. Also, if your pyramid is too deep, chances are you need
by nickporter 14y ago
I think I'm the only one in this world who doesn't mind the async pyramid. To me, it is very intuitive. Also, if your pyramid is too deep, chances are you need to extract some of it into functions.
- jakejake 14y agoI don't mind the async callback structure either, but I have to admit having only one error handler would clean up some code for me.
- ufo 14y agoI 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.