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

Ok, I understand that you don't use callbacks. But you forgot to mention what you use instead of them, in situations such as described in the article. Polling?

It depends on what the application looks like. The most straightforward and robust thing is to block on events. But if you are doing tons of this kind of thing, and the data is relatively self-contained and packageable, then I would do something like spawn a worker thread that gets the data and then puts the data into a result list (that, again, the main program blocks on).

If you are coding for the browser, neither of the options you suggest are available to you. Now what?

Answer: you do it with callbacks, because they are literally the only mechanism available. Welcome (back) to callback hell.

Hence my caveat about not being able to avoid it if an API forces you to use them.

But if I were making a replacement language that runs in the browser, among the highest priorities would be to make it not work via callbacks.

Guidelines | FAQ | Support | API | Security | Lists | Bookmarklet | DMCA | Apply to YC | Contact