I spent the better portion of my weekend wrestling with Clojure. I’m currently working on a guess-who-like game after some mailing-list brainstorming. The game idea itself seems fun and the concept isn’t horribly complex, so I figured I’d use it to springboard the learning process for a new programming language. I chose clojure arbitrarily.
In general, the language seems — immature. Or rather, the community, tools, libraries, and documentation surrounding clojure are not very old; versions of tools and libraries tend to clash and it’s pretty difficult to find actual code examples. The web is, of course, full of documentation, but it tends to be spec-based. Abstract.
Example: I’m currently stuck in a spot where I’ve defined a POST handler. When I try to pass POST data to the handler via curl or in a browser, I get a 404. A 404. Not a 500. No exception are thrown. For some reason, the library I’m using (Compojure and Ring) can’t “find” this handler. Which obviously makes no sense. Asking questions on Stack Overflow takes days at best; what the hell am I supposed to search google for? The handler responds correctly to GET requests, but not POSTs.
I also ran into an issue with clojure-redis. I want to store the game state as a JSON object mapped to a unique game identifier (like a URL shortener or etherpad) but when I tried, in my ubuntu VM, to redis/set a key and value, it actually set the LENGTH of the string instead of the string itself. Inexplicable. Running the SAME code on my Snow Leopard host OS gave the expected, correct results. I can only conclude it was a version incompatibility. There are ZERO instances of this happening on the web.
Examples aside, my point is that I really do enjoy programming in Clojure. But the documentation and code samples are sparse at best. Most people who use it tend to have lots of lisp experience already, which leaves me in the dust. So that sucks.
Anyway, it’s been full of headaches so far, but the advantages of thinking in a functional language far outweigh (so far) the headaches.
Onward!