Live data from Hacker News

Callback Hell (2016)

callbackhell.com

51–60 of 170 posts

Re: Callback Hell (2016)

#51

Lot of blabbling for a simple concept: do not abuse nesting. It's the case with control statements, it's still the case with functions, and even more with async functions. Oh, and callbacks definitely exist in other languages, like C. What's the deal with this trend of setting up a whole website for a (basic) blog post?

Detailed posts like these help beginners.

Re: Callback Hell (2016)

#52
post #6

> In other languages like C, Ruby or Python there is the expectation that whatever happens on line 1 will finish before the code on line 2 starts running and so on down the file. As you will learn, JavaScript is different. A lot of beginner guides to various programming languages make this mistake of associating a certain property with a language as if it's inherent. In this case, async code - while sold as a main fe…

> A lot of beginner guides to various programming languages make this mistake of associating a certain property with a language as if it's inherent. In this case, async code - while sold as a main feature of the NodeJS platform - is in no way exclusive to, or even an inherent part of, Javascript/ES the language. Exclusive no, but considering JS's original environment and constraints it is in fact pretty inherent. `se…

Actually `setTimeout` is not part of the core language, it's a Web API.

Re: Callback Hell (2016)

#55
I agree with the structure the author is putting out there and have been using it myself.

It was honestly a mystery whey people would use this hard to read nested structure when you can write things in a more readable way.

The best theory I can come up with is that it is easier to write that way if, for instance, you are answering a question on StackOverflow, and these examples just find their way into production code via copy/paste without people understanding how they work.

Re: Callback Hell (2016)

#56

Lot of blabbling for a simple concept: do not abuse nesting. It's the case with control statements, it's still the case with functions, and even more with async functions. Oh, and callbacks definitely exist in other languages, like C. What's the deal with this trend of setting up a whole website for a (basic) blog post?

I would've loved an article this well written and explicit when I was first learning JS (or even any language, really). Really well done with good, practical examples.

Re: Callback Hell (2016)

#57

Lot of blabbling for a simple concept: do not abuse nesting. It's the case with control statements, it's still the case with functions, and even more with async functions. Oh, and callbacks definitely exist in other languages, like C. What's the deal with this trend of setting up a whole website for a (basic) blog post?

Callbacks exist in C. But inline functions (where a parameter to another function would be placed), don't. Actually, we don't even have closures in standard C (there is a non-standard extension provided by Apple that maybe you can use to recreate JavaScript's callback hell if you're so inclined...)

Re: Callback Hell (2016)

#59
post #7

Not sure this problem goes away by giving names to anonymous functions, which seems to be his suggestion

Agreed. It tags the complexity with identifiers, which is of some use, but it doesn't change anything about the execution path which can still get wildly out of hand.
Post reply on HN