How Do You Handle Async APIs and Callback Hell?

| by Werner Schuster Follow 7 Followers on May 23, 2014 |

InfoQ's research widget has been deprecated. It should continue to work however, and we hope to relaunch it at some point in the future.

While asynchronous APIs can bring advantages, they certainly complicate programming by forcing developers to manually string together sequential operations using callbacks, causing a phenomenon called "Callback Hell".

The increasing popularity of asynchronous APIs, partially due to the rise of JavaScript and Node.js, means that many developers are now faced with a prolonged stay in Callback Hell. As is usual, developers with enough of an itch will find a way to scratch it. In the case of Callback Hell, there's a rich supply of hacks, workarounds, and solutions.

InfoQ wants to know: how do you handle asynchronous APIs? How do you stay out of Callback Hell or how do you manage it?

Language features and related

These are solutions that are either straight up language features or are supported by language features (eg. macros, etc).

Extensions of the language runtime or bytecode


  • Reactive Extensions (Rx)
    An increasingly popular approach that started on .NET and has been ported to other platforms including Java and JavaScript. As an example, Netflix is behind the Java port RxJava; see Netflix' Ben Christensen interview on RxJava.
  • Promises or Futures
    Promises (and their namesakes) have been adopted by many (standard) libraries and make it easier to chain operations. 
  • Embedded DSL-style libraries
    Libraries that allow one to chain statements, often using Promises underneath, are particularly popular in JavaScript.


  • State machines
    Using libraries like ignite.js, Ragel, etc.
  • Just write callbacks!
    Is "Callback Hell" just bad developers complaining about their tools? Do you just grit your teeth and nest your callbacks rather spend weeks researching alternative solutions?
  • Synchronous APIs
    Do you avoid asynchronous APIs at all costs? 

Note: if we missed your favorite language, library or solution, please tell us about it in the comments. 


Hello stranger!

You need to Register an InfoQ account or or login to post comments. But there's so much more behind being registered.

Get the most out of the InfoQ experience.

Tell us what you think

Allowed html: a,b,br,blockquote,i,li,pre,u,ul,p

Email me replies to any of my messages in this thread

What other language with lightweight threads? by Yichao Zhang

If that other language is Erlang, then I think it's quite mature and widely adopted.

Protothreads by John Carter

At the intersection of light weight threads, C, evil abuses of language standards and state machines there exists Protothreads.

Law of Demeter by John Carter

Actually, call back hell is a code smell.

It's a stench of a Law of Demeter Violation in progress.

The solution is to Tell, don't Ask.

We use kontraktor :-) by Rüdiger Möller

Re: Law of Demeter by Ted Slusser

I'll Ask you to Tell me more about it :)

bad poll by Rüdiger Möller

You should abstract out general patterns (e.g. actors, csp, traditional multithreading, lightweight mt). It mixes up implementations, language and methodology. There are many terminologies for identical models.

check out this

Continuations? by Cameron Purdy

Surprised that "continuations" was not one of the options.

Async API in Java by Zhong Yu

Please also check out bayou Async API -

Re: Continuations? by Mark Sasler

Take a look at, this tool is capable of avoiding callback hell using continuations.
Its CallbackEvictor module works creating a proxy over invoked service, it pauses the application flow while is waiting the async reply and continue the execution when internal callback is executed with the expected result.
It allows the use of continuations and dynamic proxies in javascript thanks to an automatic Java to Javascript conversion. Since this conversion is based in generated bytecode and not the source code, libraries such as Javaflow are used to achieved this.

Surprised that "continuations" was not one of the options.

Allowed html: a,b,br,blockquote,i,li,pre,u,ul,p

Email me replies to any of my messages in this thread

Allowed html: a,b,br,blockquote,i,li,pre,u,ul,p

Email me replies to any of my messages in this thread

9 Discuss

Sponsored Content

Login to InfoQ to interact with what matters most to you.

Recover your password...


Follow your favorite topics and editors

Quick overview of most important highlights in the industry and on the site.


More signal, less noise

Build your own feed by choosing topics you want to read about and editors you want to hear from.


Stay up-to-date

Set up your notifications and don't miss out on content that matters to you