Asynchronized programming seems to be natural in Javascript - it is the "first choice" to do many things.

But in most other programming languages, asynchronization is more like a second choice rather than first choice.

What makes asynchronizated programming so popular and natural to Javascript?

closed as too broad by gnat, Jim G., user40980, Corbin March, BЈовић Aug 5 '13 at 6:58

Please edit the question to limit it to a specific problem with enough detail to identify an adequate answer. Avoid asking multiple distinct questions at once. See the How to Ask page for help clarifying this question. If this question can be reworded to fit the rules in the help center, please edit the question.


Especially when used in a browser environment, there are no threads (let's ignore the rather new WebWorkers for now) available - all JS runs in a single thread which is usually the same one that also handles e.g. rendering of the page.

So performing actions in a blocking manner is simply not an acceptable option - especially since most actions that involve IO in JavaScript usually cause network IO which, unlike disk IO, is usually rather slow and thus blocking everything until a request finished is not acceptable.

  • WebWorkers seem to be useless for the purpose they were created anyway, the serialization/deserialization overhead is insane – Esailija Aug 4 '13 at 23:31
  • @Esailija: I've found them useful occasionally within Firefox extensions. However, on a normal website I think they'd introduce more issues than they'd resolve. I think this might change over time. The overhead isn't a big deal if you're doing something non-trivial. And to be fair, threads are pretty expensive in most other languages, too. – Brian Aug 5 '13 at 1:02
  • 1
    @Esailija Note that WebWorkers transferable objects solve some of the serialization issues, by allowing a worker to relinquish its hold on some memory space and give it to the main thread (thereby avoiding the need to do a copy at all). I believe the usefulness of this technique is limited by the fact that only a few object types can be passed in this way. – apsillers Aug 5 '13 at 13:13

Not the answer you're looking for? Browse other questions tagged or ask your own question.