4 ms·
Exactly. This is the problem I have with the hype around the promises API, and if you're a Dart developer, Futures. They claim to solve "callback hell" but the
by tyleregeto 13y ago
Exactly. This is the problem I have with the hype around the promises API, and if you're a Dart developer, Futures.
They claim to solve "callback hell" but they can't. Callback hell is the result of poor programming style, not a limitation of the language. Callback hell is just as possible with promises, and there are plenty of examples of it on the internet.
I'm not saying promises don't have benefits, and can't result in some nice programming patterns, but generally they are just a different way of doing the same thing. It's not that callbacks are more tightly couples then promises, its that people write their code that way.
Their API's have some other nice benefits though.
- rubiquity 13y agoI think Callbacks, Promises and Futures are all more or less the same in terms of coupling. However, I do find Futures to produce the most readable code.
- woah 13y agoI would agree. I've found, in my own code at least, that callback hell only happens with code that is not modular enough. If you separate your logic out into small self-contained modules that do one thing, they never get too deep. Promises allow you to have monolithic code that's not superficially ugly.