JavaScript was conceived to be a single-threaded language where asynchronous tasks are handled with events. When there are only a few potential events, event-based code is much simpler than multithreaded code. It’s conceptually elegant, and it eliminates the need to wrap up data in mutexes and semaphores to make it thread-safe. But when a number of events are expected, with state that needs to be carried from one event to the next, that simplicity often gives way to a code structure so terrifying that it’s been dubbed the Pyramid of Doom.
| step1(function(result1) { |
| step2(function(result2) { |
| step3(function(result3) { |
| // and so on... |
| }); |
| }); |
| }); |
“I love async, but I can’t code like this,” one developer famously complained on the Node.js Google Group.[4] But the problem isn’t with the language itself; it’s with the way programmers use the language. Dealing with complex sets of events in an elegant way is still frontier territory in JavaScript.
So, let’s push the frontier forward! Let’s prove to the world that even the most complex problems can be tackled with clean, maintainable JavaScript code.
13.58.187.240