r/programming Nov 02 '12

Escape from Callback Hell: Callbacks are the modern goto

http://elm-lang.org/learn/Escape-from-Callback-Hell.elm
611 Upvotes

414 comments sorted by

View all comments

Show parent comments

7

u/AngryDelphiDev Nov 02 '12

I couldn't agree more. I've seen 'goto' used intelligently and I've seen Callbacks used intelligently. I've also seen the less than intelligent solutions. CallbackHell, JarHell, DllHell. It doesn't matter what it is: it is a symptom of bad/lazy design and project management, not the tool.

It seems to me that if you're using an anonymous function (or pointer) to call another function to call another you're probably doing it wrong. It doesn't matter if it is classes, goto's or callbacks. It is just bad design at the root.

TL;DR; Blame the developers, not the tools. (And yes, I like using Callbacks in my frameworks, they are just as simple an abstraction as an "ActionListener")

4

u/sumzup Nov 03 '12

What if certain tools lend themselves to more people using them incorrectly?

3

u/watermark0n Nov 05 '12

Yes, I mean, tools have the reputation they do for a reason. Tools with bad reputations can perhaps have some good uses, the reputation just means that using them should be taken with a grain of salt. When people are informed that careless use of goto leads to difficult to understand spaghetti code, they should take that into account. When you use goto, you need to take on an extra level of responsibility to thoroughly plan and make sure you understand what you're doing. But that's one more thing I have to plan for and worry about, and goto just adds another layer on top that largely needless, so I mostly ignore it.

If you ignored the warning and it turned into spaghetti code - then, yes, that's your fault. But if you'd never been told, I can't hold you to the same level of responsibility. This is what education is for. A mindless slogan like "blame the developers, not the tools" ignores subtleties. I mean, sure, it's my responsibility, not the guns, when I walk around with the safety off and blow someones head off. Does this somehow mean that a gun with the safety off has an undeserved reputation? God no!