Hacker News new | past | comments | ask | show | jobs | submit login

"callback hell" is just a sign that you did not split your code into small functional chunks, nothing more. promises/async/await might have its place, but "callback hell" is developer's fault, who can't shake off linear coding past, not language's.



Relevant article :

http://journal.stuffwithstuff.com/2015/02/01/what-color-is-y...

The callback hell is here no matter how hard you try to hide it under some syntactic sugar. That's what makes Go CSP superior to Async IO by the way.


I am not talking about hiding anything. If anything, promises/async/await IS hiding.

When I see "callback hell mumbo-jumbo" - it just takes some time to untangle it, assign proper context to each function, and flatten out it inside proper object to keep that context in. And instead of anonymous functions in callbacks you just use object methods.

Bonus: you got something that is so easy to unit test.

I see a lot of callback-hellish code, but it comes from people who's experience was in python/java/php/etc, where typically you write linear code (threads are also linear code in essence) And in JS you have to think about frames of code - this is a bit different, but it is not a bug, it is a feature.




Join us for AI Startup School this June 16-17 in San Francisco!

Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: