Diggin' Clojure and Compojure

Posted by: Pratik Patel on 2010-01-13 01:16:00.0

Over the xmas holidays I started learning Clojure. I'd been putting it off for a long time (since I saw Stuart Halloway present on it 9 months ago) so I read carefully through this lengthy article on Clojure, then the MEAP of Clojure in Action. The irony here is that I haven't read Stu's "Programming Clojure" book yet... but it's next on the list. Along the way I found some excellent screencasts by Lau Jensen on his blog. In particular, check out this one.

"Finally!"  I thought to myself, all those years of using Emacs will come in handy once again. I got all the Clojure-Swank-Slime-Emacs stuff working and started hacking. I thought I'd also try out some IDE support for Clojure, and found Enclojure, a nice plugin for Netbeans. I found myself actually using Enclojure more than Emacs, as I've become a slave to fancy IDE's like Netbeans, Eclipse and IDEA. If you're exploring Clojure, I highly recommend Enclojure - if for nothing else the syntax highlighting so you don't get lost among the parens. It also has a built in REPL like the one Lau was using in his screencast. I actually worked through his screencast in Enclojure with a few variations in his demo code. I'm hoping to have some time soon to put together a screencast to demo Clojure and Compojure using Enclojure.

Being an old Emacs hack, and having worked with LISP, albeit many years ago, I found that Clojure is in fact it's own beast. It is significantly different than the LISP I used back then. That's not to say it's "better" or "worse", it's just different. Of course, Clojure runs on the JVM and has full interop with Java, or any JVM language for that matter. And this is the most compelling thing to me about Clojure - the ability to run on the VM, use the vast amount of open-source Java libs.

Writing LISP code is different than anything you've ever written before, if you're not familiar with it. I'm still working on getting my head around some of the idioms of Clojure and altering the habit of imperative coding that I do with Java or Groovy. I find one thing cool already - not having to track variables and "cache" them in my brain as I code. The whole thought process for writing Clojure code is different (at least for me), but it's growing on me as I find that I'm able to be more expressive in code without having to be more complex - in fact I think the Clojure code is simpler than equivalent code in imperative langs.

I'm not about to give up on Java or Groovy and start hacking Clojure full-time, but much like Groovy, working with Clojure makes coding fun again. At this point in time, I'm not sure where this journey into the world of Clojure will take me, but I'm enjoying the ride. Screencast coming soon, watch this space!


About Pratik Patel

Pratik Patel

Pratik Patel is the CTO of Atlanta based TripLingo (http://www.triplingo.com/). He wrote the first book on 'enterprise Java' in 1996, "Java Database Programming with JDBC." He has also spoken at various conferences and participates in several local tech groups and startup groups. He's in the startup world now and hacks iOS, Android, HTML5, CSS3, JavaScript, Rails, and ..... well everything except Perl.

Pratik's specialty is in large-scale applications for mission-critical and mobile applications use. He has designed and built applications in the retail, health care, financial services, and telecoms sectors. Pratik holds a master's in Biomedical Engineering from UNC, has worked in places such as New York, London, and Hong Kong, and currently lives in Atlanta, GA.

More About Pratik »

SpringOne 2GX

September 9 - 12, 2013

Santa Clara, CA

Current Topics on the NFJS Tour

  • Core Java, JEE
  • Dynamic Languages: Groovy, JRuby, Scala, Clojure
  • RESTful Web Apps
  • Frameworks: Hibernate, Grails, Spring, JSF, GWT, more
  • Agility
  • Test Driven Design
  • Security
  • Ajax, Flex, RIA
View Event Details »

NFJS, the Magazine

2013-03-01 00:00:00.0 Issue Now Available
  • Having Fun with Play Framework

    by Nilanjan Raychaudhuri
  • Test-Driven iOS Development in Ruby with RubyMotion: Part 1

    by Brian Sam-Bodden
  • Java Unit Testing with Spock

    by Ken Sipe
  • Concurrency with GPars: Part I — Using Asynchronous Methods

    by Venkat Subramaniam
Learn More »