Facilitating the Spread of Knowledge and Innovation in Professional Software Development

Write for InfoQ


Choose your language

InfoQ Homepage News When Ruby Builds Faster Than Java: Buildr

When Ruby Builds Faster Than Java: Buildr

This item in japanese

The Java build system Maven 1.0 was released 3 years ago and has been widely adopted in the open source world and in the industry; Since then, the 2.0 new releases haven't been met with quite the same level of approval. At the same time, Ruby has become more and more popular, and the concept of internal DSL has proved to be very effective with tools such as Rake.

On the other hand, DSLs written in generic languages just work. You get the simplicity of the high level language with the ability to extend it as far as computers can compute.

Over time, entirely new build systems have been written in Ruby, such as Bake and Rant. Others extend Rake, such as Raven, which supports external repository ala Maven.

The new kid on the block, Buildr, is aimed specifically at simplifying Java builds. Author Assaf Arkin advocates simplicity over xmlized and over-engineered solutions -- you can figure that from his blog or the tumblr quotes he collects. It's why he tried to get rid of Maven 2 in his projects like Apache Ode.

We quickly dubbed it the Maven Uncertainty Principle, though in fairness we knew there was little uncertainty or doubt whether the build will work: it won't. Finally, one day we just had enough. The test cases stopped working. (...) Either way, we had to choose. Agile or Maven. One of them will have to go.

Assaf wondered about a return to Ant:

So we started imagining the happy life we could all live with Maven out of the way. Maybe we'll switch back to Ant? For all its shortcomings, at least Ant builds work. Sure, Ant is not "declarative", the holy grail of software developers everywhere. But declarative done badly is worse than any imperative spaghetti code.

...and finally land on Rake.

So we did it. We started with Rake. Let me spoil the surprise for you. It turned out to be an excellent choice. Rake was a good start, but not what we'd hope for. The typical Java application we work on consists of several modules, all of which have the same common lifecycle tasks: compile, test, package, deploy. Writing those over and over for each and every module would make it not much better than Ant. There's got to a a better way.

The saga resulted in the birth of Buildr, which comes with handy goals (ie to handle xmlbeans), and let you rely on usual Ruby code to complete basic tasks.
The performance could have been the last stopper for a wider adoption but the "Fast and Furious" Buildr proved it could compete with Maven.

We're building the same code, running the same tests, compiling the same XMLBeans, creating the same Hibernate schemas, sharing the same remote and local repositories. All this to say, they're black box equivalent. Feed them the same project, and they generate the same JARs, WARs and distro files.

It builds the same except that the scripts have been downsized by 91% from 52 XML abused files to 1 script. But that's not all, Buildr managed to cut the build time by 50%! Even on partial builds, Buildr performs similarly or better than Maven.

Of course, we're not measuring raw Ruby against pure Java. We're comparing one implementation against another, where they both do the same thing. Black box equivalent. That's a real life benchmark.

Assaf ends with a nice conclusion:

Ruby might be slow, but what you build with it can be devilish fast.

We think it would be interesting to see how Maven and Buildr perform head-to-head.

The documentation is currently limited to RDoc and an Apache Rakefile example, but a complete guide is in progress.

Rate this Article