UPDATE [2012-05-07]: clutch-clojurescript is now deprecated, as its functionality has been rolled into Clutch proper in toto. Documentation for the feature can be found here.
While I was in San Fransisco for JavaOne, I was lucky enough to be invited to speak at the Bay Area Clojure User Group (thanks, Sean and Toni!). It was a great time, and gave me the kick in the pants I needed to finish hacking away at my first project involving ClojureScript: using it to write view functions for CouchDB.
The result is clutch-clojurescript, which naturally builds on top of the Clutch library that I've collaborated on with Tunde Ashafa for some time now.
My motivations for doing this were manifold:
- I quite enjoy using CouchDB, as its model and general philosophy meshes very naturally with my (and my tools') disposition and the data I work with most often.
- The operational hassle associated with maintaining a Clojure view server (which Clutch provides) configuration alongside my CouchDB installs was always a hassle.
- I've been wanting to do more and more with Cloudant, but a Clojure view server is just not an option with a hosted database-as-a-service like that.
Feel free to go check out clutch-clojurescript: beat on it some, and let me know if it breaks on you. I would eventually like to fold it into Clutch proper. Beware some limitations though — repeated here from the README in part to draw attention to them:
- To my surprise (and shock/horror), the version of Spidermonkey that is used by CouchDB (and Couchbase Single, and Cloudant) does not treat regular expression literals properly — they work fine as arguments, e.g.
string.match(/foo/), but e.g.
/foo/.exec("string") fails. Using the
RegExp() function with a string argument *does* work. This was reported a long time ago, but has had little attention (though I'm trying to stir it up a bit).I'm hoping to get to the bottom of this sooner or later, but I wonder if it'd be worthwhile to change the ClojureScript reader to emit
(js/RegExp "foo") calls instead of
/foo/ literals (and hope that gClosure doesn't optimize the former into the latter)? After all, there's lots of CouchDB deployments out there with apparently broken spidermonkey installs/configurations, and likely lots of other apps/servers/environments in similarly dire straits.
Finally, here are the slides from my talk at the BACUG (download/view PDF):