Interesting Build Tool for Clojure – Leiningen
I was looking at github this afternoon for examples of Clojure apps to see how they were using the language, and what problems they were solving. It's something that I find useful now that I'm half-way through Programming in Clojure from Pragmatic Programmers. It's a nice book, and while I'm not really thrilled with the order of topics, I think the second time through I'll pick up a lot more. But it's going to take a second trip through all this for a non-Lisp developer like myself.
Anyway, I was looking and saw that one of the most watched projects was a build system for clojure called Leiningen. Odd name, and they talk about it in the README, and I like their concise project.clj file:
(defproject leiningen "0.5.0-SNAPSHOT" :description "A build tool designed not to set your hair on fire." :url "http://github.com/technomancy/leiningen" :dependencies [[org.clojure/clojure "1.1.0"] [org.clojure/clojure-contrib "1.1.0"] [ant/ant-launcher "1.6.2"] [org.apache.maven/maven-ant-tasks "2.0.10"]] :dev-dependencies [[org.clojure/swank-clojure "1.2.1"]])
The question that first came to my mind was Why? I mean, I understand the need for a build system - but with Make and Ant and a hundred other lesser-used build systems, it's amazing to me that someone took the time to actually go and create another. So I started to dig into the code and I think it's helped me realize the place clojure has in the spectrum of software development languages.
When I first started reading about clojure, I was thinking it was a lot like Smalltalk - or Lisp, where you have a 'workarea' or 'sandbox', and you spend a lot of time essentially augmenting the language or environment - making it more powerful, more complete, more customized to your way of doing things. In the end, you have a place to do the things you need very efficiently and without loading up a ton of libraries, etc.
It's entirely different if you're writing Java code, for instance.
So... what's Leiningen all about?
I dug in and saw that it's got links into github - and now it starts to make sense. If you wanted to incorporate apt get or yum with a "sandbox" and custom code, you could... but it'd be platform-dependent. And you could only pull pre-built projects from the sources you had in your package manager.
It appears that Leiningen is a package puller in addition to a code compiler, and even a code pusher. It's tightly integrated with github, and that's not bad, it's just exclusive. But if I want to get something you've written in clojure, and we all use github for our code, then this is an interesting solution.
I can pull your code from github, use Leiningen to build it, and it'll pull in any needed projects that I don't already have from github and make sure they are properly integrated into my sandbox. You don't have to package everything in your project, and I don't have to mess with getting your dependencies - or even what they are! I can use pull it from github, build it and use it.
That's pretty impressive, I've got to admit.
But I'm not sure it's what I'd call a "build system" - it's more than that, and it's not going to really help you a ton if you're starting to work on something and want to put it on github for the first time. I'm going to have to get the code I need, or at least identify it - including the version of each, and then build the project.clj file. But at that point, I've already built my project. This helps you use my work, but not really me build it.
I think it's worth watching, as it might become more of what I'm thinking about, but in general, this looks to be a great tool when posting your code to github, but before that - or if it's not on github, it's not as useful.
But it does shed light on who uses clojure and how they use it.