Re:Escape from Callback Hell: Callbacks are the modern goto
by jblow on Friday November 02, 2012 @02:23PM
(#4734022)
I don't see it as fundamentally different. Callback means some or all of: "I don't know when or where I am being called from, or what the state is of the rest of the program at this time." All of those are bad things if you are trying to write robust software, so you want to avoid them unless there's a really good reason.
Re:Escape from Callback Hell: Callbacks are the modern goto
by wwweston on Friday November 02, 2012 @03:19PM
(#4734281)
> Callback means some or all of: "I don't know when or where I am being called from, or what the state is of the rest of the program at this time."
This sounds a lot like what function means.
Re:Escape from Callback Hell: Callbacks are the modern goto
by jblow on Friday November 02, 2012 @05:54PM
(#4734950)
Nope, because you can do static analysis (a.k.a search through your program text) to find out who calls a function and when. The whole point of a callback is that this doesn't work.
Re:Escape from Callback Hell: Callbacks are the modern goto
by Evbn on Saturday November 03, 2012 @02:30PM
(#4737453)
How does that help with program state, which changes based on user input?
Re:Escape from Callback Hell: Callbacks are the modern goto
by pkaler on Friday November 02, 2012 @03:04PM
(#4734224)
"I don't know when or where I am being called from, or what the state is of the rest of the program at this time."
Gotcha.
A parent object should own a child object. The parent can directly call a method on a child. The child object shouldn't really know about the parent. Hence, it uses a callback/delegate/protocol.
Callbacks are a mess if there isn't a clear parent to child relationship.
In Objective-C, the @protocol keyword gives the language first class delegation and works really, really well. More details here: http://developer.apple.com/library/ios/#documentation/Cocoa/...
With respect to the original article, he's talking about callbacks with respect to Node.js. That's not a callback issue. Async is unnatural for the mind to grasp. What did he expect?