3 ms·
I've never really understood the problem with "callback hell" that people talk about. The biggest annoyance I've seen from it is that indentation can get a litt
by mistercow 13y ago
I've never really understood the problem with "callback hell" that people talk about. The biggest annoyance I've seen from it is that indentation can get a little out of hand, but the examples I've seen could be fixed with smarter coding rather than new language features.
- kaoD 13y agoI love asynchronous programming and prefer callbacks over other forms of asynchronous flow control... but callback hell is a real problem. It's easy to lose track of the logic flow and hard to coordinate several parallel callbacks without external libraries such as node-async. Smarter coding does not fix the callback pyramid either, because then your callback logic is spread through the source and not where it belongs, making things even worse! And when your callbacks depend on each other it's REAL HELL, because it's easy to create a tangle of mutable closed variables far from the real logic which IMHO is not a very good pattern. I tend to prefer functional programming with pure functions, but callback-hell-code can quickly resemble the worst parts of OOP if you're not careful (without the good parts such as encapsulation). I love Node.js, it's my platform of choice, but big projects can quickly get out of control. I'm really looking forward to generators to fix the issue. I couldn't understand callback hell either, until I really got into Node.js programming for big projects.
- camus2 13y agowell, imagine you have 4/5 sequential db calls, and for each async call need to write a success callback and a failure callback ... async lib helps though defer/await programming style would be a better option.
- deleted 13y ago[deleted]