Short and Sweet Disclojure
After experimenting and bouncing back and forth on several relatively new languages, I was undecided on what new language I wanted to commit myself to. It wasn’t until I began reading Clojure in Action that I really started to grok and see through its otherwise intimidating syntax. Admittedly, Clojure just looked and sounded too exotic at first glance. Do I really want to learn Lisp? Aren’t those parentheses crazy? Shouldn’t I be programming the next million dollar idea for the iPhone?
It turns out that the answers to those questions are: Yes. No. What money?
I wanted a challenge. I wanted something that would transcend the way I’ve been thinking about programming. I wanted something that I knew would make me a better software engineer. I wanted something more expressive and powerful.
Luckily, the past two weeks I’ve had an excellent opportunity at work to apply and push my learnings of Clojure further. I thought it would be an opportune time to share the good, the bad, and whatever else in between. A reflective and honest “disclojure”.
It seems that the best way to learn a new language is finding well documented source code and blogs from likeminded people. Clojure is a “newer” burgeoning language so it goes without saying that there are far fewer comprehensive online resources to tap into. The blogosphere is actually a bit sparse on Clojure. I’d strongly recommend having a couple Clojure e-books at your fingertips for reference. Speaking of books, don’t expect to learn Clojure by reading a stack of books for 5 months and think that it will magically flow from your digits. It’ll never ever happen. The best recipe for me has been a 1:1 ratio of time spent reading and coding. If you’re in pursuit of books that might help you on your quest to learning Clojure, remember Clojure is a Lisp. The Little Schemer and The Seasoned Schemer have been priming Lisp programmers for decades. If anything reading these two books will make you hungrier for more, wink wink nudge nudge.
Github has been an invaluable asset when looking for good source code examples. One of the questions I continue to ask myself while coding, “Is the code I’m writing idiomatic?” That is important to me because one of my main objectives is to transcend my thinking and programming style. So before you add that dependency to your Leiningen project.clj have a peek at the author’s source. In reality, you might often find yourself sifting through source because of the lack of documentation or examples. Actually I read other developers source code daily for this very reason. So let me re-phrase that, while you’re trying to figure out how the heck some library or “clojar” works, be mindful of the coding style. Undoubtedly you will pick up something useful.
I had a perplexing problem the other day and for the life of me I couldn’t figure it out. I simply lacked the context necessary that other more advanced Clojure developers have. I found my answer after posting my question on the Clojure forum hosted on Google Groups. More specifically, I was using lein run to execute a simple database preparation task, but the process was hanging on well after it completed. It wasn’t until someone informed me that I should use (shutdown-agents) after the task I was running finished because of the way the agent thread pool delays shut down. See my gist here. The turn around time on the Clojure forum varies. I think it took 2 or 3 days before my post was moderated and then received a response. Most if not all of the Clojure core developers answer questions in this forum so the responses are of high quality and are super helpful.
Sometimes you’re totally stuck. Even after using your e-book as a reference and reading the source code it just doesn’t make sense. Enter Clojure IRC! During the daytime it is bustling with chatter. Lots of the folks who answer questions on the Clojure forum hang out here too. In my experiences, the community that gathers here is friendly and willing to help.
Clojure is as expressive, powerful, and succinct as advertised. The Java interop with Clojure is about the simplest and cleanest I’ve seen thus far and that includes JRuby and Scala. I’m impressed with the clean HTTP API Ring has to offer and using the Clojure JDBC API is really nice. If only JDBC were that easy in Java there would be no need for heavyweight clunky ORMs. In terms of testing, speclj is a pretty awesome testing framework that mirrors Ruby’s RSpec API. I also have enjoyed rolling my own solutions for things that aren’t available yet. And one of the most important parts…it is fast and performs very well under load. I don’t make these claims falsely either, we ran a load test today at work and we were absolutely thrilled with the response times and throughput. I look forward to posting more about Clojure in the coming weeks. Stay tuned!
Follow me on Twitter
My github repository
My LinkedIn Profile