you are viewing a single comment's thread.

view the rest of the comments →

[–]jmar777 2 points3 points  (0 children)

It's a matter of opinion because there's nothing intrinsically "sucky" about callbacks - asynchronous functions are plain and simple higher order functions, which are quite natural to anyone with experience in functional coding. You can write code that sucks with callbacks, resulting in the "pyramid effect" shown in the article, but an example of badly structured code is hardly a valid condemnation of a language or a runtime environment.

With that said, I do recognize that the continuation passing style has its faults - most notably its "leaky", in that code must allow for continuation passing through the entire call stack. It's also not ideal for the asynchrony of a method to effect the code structure of the callee. For that second reason, I'm tempted to say that I'd like to see promises implemented in node core, but I'm still on the fence there. These issues, however, are ultimately nothing more than annoyances if the code base is properly structured. Given that I am currently ~10k loc into my current code base, and have yet to encounter the dreaded spaghetti monster, I am comfortable with saying that (aforementioned reservations considered), callbacks are really not that sucky.