Bootstrap Core Async

May 15, 2016

It seems that, for the longest time, there has been interest in core.async support in self-hosted ClojureScript. And, try as we might, for one reason or another, it has eluded us.

Certainly, the most complex macro with the shortest name I've ever encountered is go.




Now, more than half a year later, it's finally working!

Here's a small demo, using it from Planck:

cljs.user=> (require '[cljs.core.async 
                       :refer [chan <! put!]])
nil
cljs.user=> (require-macros '[cljs.core.async.macros 
                              :refer [go]])
nil
cljs.user=> (def c (chan))
#'cljs.user/c
cljs.user=> (go
       #_=>  (let [x (<! c)]
       #_=>   (prn x)))
#object[cljs.core.async.impl.channels.ManyToManyChannel]
cljs.user=> (put! c :hi-there)
true
:hi-there

The revisions needed to make this work are in a fork of the official core.async repo. Things are still rough around the corners, but I see no reason why this can't lead to something solid.

Would support for self-hosted ClojureScript end up in the official core.async release? My thoughts are that the rearrangements needed to make this work might make an official patch unlikely.

But, regardless of what ultimately happens, its good to get the bugs ferreted out with community efforts like these. If you are interested in core.async for boostrap, please give this fork a spin, report bugs, and even submit PRs.

Bootstrap ClojureScript holds a lot of promise related to its reach. In my opinion, the core.async library is an important one to have along for the ride!

Tags: ClojureScript Bootstrap