Yesterday I posted about spaghetti-free Javascript code. A lot of reactions followed.
As it turns out, most people misunderstood my point. That’s probably my fault. Here is at again, more concisely:
When you write Javascript you have to think ahead: in the code I’m about to write, is there going to be an asynchronous call at some point? If not, I can write Javascript in a nice, synchronous succinct style. If so, in many cases I cannot really use many of the regular language Javascript constructs, such as for-loops, but instead have to use one of the many Javascript libraries that implement asynchronous versions of loops, conditionals, etc.
If, like in my example, you do not plan ahead — and it turns out you need an asynchronous call somewhere, you have to go back and rewrite a lot of your code to use the asynchronous programming style.
The three tools I listed are ways around this problem. There you can keep writing your code in a synchronous style, no matter if you need an async call at some point.
Hope that clears things up.
Tags: async, javascript
Pingback: Three Routes to Spaghetti-Free Javascript « I am Zef