Clojure in the Field

Recorded at:

Summary
Stuart Halloway presents what makes Clojure different and, in his opinion, better than Java, plus some real-life lessons on Clojure development including BDD for functional code, wrapping Java APIs, third part libraries worth knowing, writing code without an objectual context, and the learning curve for a team new to the language.

Bio

Stuart Halloway is a co-founder of Relevance, Inc. and is the author of “Programming Clojure, Component Development for the Java Platform and Rails for Java Developers”. He regularly speaks at industry events including the No Fluff, Just Stuff Java Symposiums, the Pragmatic Studio, RubyConf, and RailsConf.

QCon is a conference that is organized by the community, for the community.The result is a high quality conference experience where a tremendous amount of attention and investment has gone into having the best content on the most important topics presented by the leaders in our community. QCon is designed with the technical depth and enterprise focus of interest to technical team leads, architects, and project managers.

Though I am a fan of LISP, I think the learning curve issue is the biggest challenge. LISP has been around for a long time, but it's never really had wide acceptance in the developer community. In the AI field, it's still popular.

When I try to teach others about LISP and how to use it, I find that many people simply can't think in LISP. The whole declarative S-Expression approach of LISP makes it very hard for most developers. Since Clojure is LISP, many developers will get frustrated at first. My advice is to stick with it. It will eventually pay off.

It's worth nothing that in the ~6 months between when this talk was given and when it was posted here, some of the information has become out of date.

Specifically, what Stuart says about Emacs is no longer really true. Setting up emacs within your own setup is fairly simple using ELPA. Throwing out your old setup is not really necessary. Using SLIME and swank is very easy if you use either Maven or Leiningen to manage your project. In fact, I think that if you're using emacs using swank is now easier than not using swank. Leiningen itself is mentioned in this talk as "just announced"; it is now fairly widely used in the Clojure world.

16:30 - QuestionsQ1 - How do you use Java objects in Clojure?Q2 - Why not Scala? (18:00)Q2.a - "I can't imagine what I would write Java for. I would instead use Scala for those few things."

20:00 - Pain points1. "We struggled to be effective with the testing framework for a while." (22:45)2. "Ruby kicks everybody else's ass with its testing tools" (23:30)3. To wrap or not to wrap (24:00)3.a "Mocking in a lisp is beautiful." (25:15)3.b "What to do when you want to mock out some Java stuff?" (26:00)4. The learning curve (26:45)4.a "There's more to learn that's new than to another dynamic language." (28:00)4.b "Switching over to a functional style isn't trivial."4.c "The model for dealing with state is arguably revolutionary."4.d "We mitigate the learning curve this way." (28:30)4.e "Knowing where to find something. You often write it yourself before learning that it's already there for you somewhere."

30:00 - Libraries1. Those you need!2. Other libraries we've used (32:45)2.a Clojure frees you from dealing with in-process state (34:30)2.b Survey: "About 1 line in 1000 lines of Clojure code instantiates some mutable reference."3. Java libraries (36:00)3.a "We don't use Compojure's html template mechanism - we use StringTemplate for that." (37:15)3.b "A lot of Java libraries are not well aligned with Clojure." (38:15)3.c "Hibernate is an extraordinary bad fit for Clojure." (38:45)3.d "The libraries' stuff has generally been very satisfying." (39:00)

43:00 - Shipping It1. "The other thing for which Ruby kicks everybody else's butt is at tools for automating deployment."2. "We use the Ruby tools to manage our Clojure deployments."3. "I hate Maven. Some use it." (44:00)4. "All JVM-based languages are crap for operating differently with each operating system."4.a Still, some people are building stuff for this in Clojure! (45:30)

46:30 - Other pain points1. Convention over configuration: right now Clojure projects copy conventions from other languages, which are not adapted to Clojure's own idioms, which are not yet all discovered.2. "Error messages are horrible on all the advanced JVM languages (Clojure, Jruby, Scala, Groovy)." (47:30)2.a Mitigated if you do TDD.3. "Some people don't like living without objects, but I'm fine with it." (48:00)3.a "Let your data be your contract." (48:30)3.b Anyway, it's how it always works as soon as it gets out-of-process. Get over it.4. Editor support (50:00)4.a "Paredit is very important. I wasn't using it. Rich Hickey wasn't either. We were out in the darkness."