clojurecore.async

When to use core.async in Clojure?


When should I use Clojure's core.async library, what kind of applications need that kinda async thing?

Clojure provides 4 basic mutable models like refs, agents, atoms and thread locals/vars. Can't these mutable references provide in any way what core.async provides with ease?

Could you provide real world use cases for async programming?

How can I gain an understanding of it so that when I see a problem, it clicks and I say "This is the place I should apply core.async"?

Also we can use core.async in ClojureScript which is a single threaded environment, what are the advantages there (besides avoiding callback hell)?


Solution

  • You may wish to read this:

    The best use case for core.async is ClojureScript, since it allows you to simulate multi-threaded programming and avoid Callback Hell.

    In JVM Clojure, core.async can also by handy where you want a (lightweight) producer-consumer architecure. Of course, you could always use native Java queues for that, as well.