18 December 2006
Now that JRuby is getting more and more mature, several people are thinking of finally doing something to improve the world of build scripts by replacing ant with rake.
My former colleague Matt Foemmel has starting doing this for real and is writing up progress on his FoemBlog. Matt's written more build scripts than most and around 2000 we both made the mistake of thinking an XML based build file was the way to go. We also both now believe you need a full scripting language.
The thing with build scripts is that you need both declarative and procedural qualities. The heart of a build file is defining tasks and the dependencies between them. This is the declarative part, and is where tools like ant and make excel. The trouble is that as builds get more complex these structures aren't enough. You begin to need conditional logic; in particular you need the ability to define your own abstractions. (See my rake article for examples.)
Rake's strength is that it gives you both of these. It provides a simple declarative syntax to define tasks and dependencies, but because this syntax is an internal DomainSpecificLanguage, you can seamlessly weave in the full power of Ruby.
A big issue with Rake for Java builds is that it was tricky to avoid lots of starts of the Java VM. JRake runs on top of JRuby which runs inside the Java VM, so this issue goes away.
One argument against using rake for builds that I often hear is that it adds another language that people have to learn. What this argument misses, is the point that ant is really its own language anyway. The fact that it's compliant XML doesn't alter the fact that you still have to understand how all the various ant tasks work and fit together. Of course if you already know ant, then it is extra effort to learn rake; but given a mind free of both I don't think rake + ruby is any harder, and there's lots of other things a scripting language can do for you. (I believe that every programmer should be comfortable with at least one scripting language - there's just so many useful things you can do with them.)
With so much invested in ant, it will still be around for a while, but we think rake is the better solution for the future.