Tinkering with Clojure

Some day I read this blog post and thought to myself “why not Clojure?” …so here are my notes, after a dozen hours or so of tinkering with it guided by the famous tutorial of Mark Volkmann.

One thing hit me from the beginning. I’ve seen discussions on the net about what language syntax is more beautiful: semicolons and round brackets, or spaces and square brackets. What?! Come on, none is “beautiful”! Just another computery jargon you have to get used to. Since when is “beautiful” similar to adhering to some (self-inflicted) convention?!? Even the tutorial talks about “syntactic sugar” – which means in this context using “^(” …well no risk developing diabetes from that much sugar.

Leiningen (Maven based) and REPL were fine but somewhere in the middle of the “tutorial” and after developing a headache I said…


Learning is for me good if I can also see what I’m doing, and by “seeing” I mean some web application – that’s why I ‘m here right? I mean, the environment is so much more than a language… As I was already a fan of Spring Roo I decided to check Luminus: installed it, tried their first app steps and had a look through the generated sources. Hmm handler.clj was certainly an interesting read (has also a redefinition forgotten there, oops). The Luminus stack looks based on quite a few technologies, how about checking them to see what we can expect and what not (this is how recursion started)

Soooo…. there’s Noir (here only for middleware = modifying handlers) with Compojure (map requests) and Ring (servlet wrapper and some more); it’s logging with Timbre, with Rotor as appender, and not at least uses Korma (including c3p0) for JDBC. The view? Well, the templates are processed by Clabango but look written in Markdown (note to self: remember the difference the {{ for variables and {% for tags), with JSON support from Cheshire and internationalization via Tower. After digging through sources and dependencies I noticed these technologies were mentioned also on the Luminus web site – I just had to click the topic names… 🙂 oh well, you know what they say:


While playing with code I really appreciated the clear error messages – my first mistake was to forget to add the require directive for the DB schema and there was the error immediately. I could have liked the routes definition not that separated from where theyre used but well, one can live with it.

Next step: generate all kind of app profiles and compare the sources with windiff. By design or not, the mysql or postgres backends look not finished yet. Their schema init test always fails so you either gotta remove the schema test completely – in case you ever had one, or write the implementation yourself. Clojurescript or bootstrap profiles have no db backend at all by default, but work if you add the db by hand. I was relieved to see that doing “+h2 +cljs” or “+cljs +h2” didn’t seem to matter – my worry was triggered by reading that “latest one will overwrite the files from the preceding” (anyway, to be kept in mind). The generated html is also surprisingly different in formatting between profiles, not that it really matters because after all Luminous is there only to build you a first skeleton for a quick start.

Aaaannnndddd… that was it for the moment. Did I learn Clojure? Certainly not 🙂 come on, after only a few hours tinkering??? I just had a look at what the environment offers and stomped away some fears. Not that many though, the language itself still IS something much different from what I know but the environment works pretty much familiar. There will be an episode 2 to this adventure, just not now. I still plan to figure out what’s its concurrency approach and I got the feeling it’s going to be tough




Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s