InfoQ

News

When Ruby Builds Faster Than Java: Buildr

Posted by Sebastien Auvray on May 07, 2007 12:30 PM

Community
Java,
Ruby
Topics
Build systems
Tags
Rake ,
Buildr ,
Maven

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.

So? by Jakob Vad Nielsen Posted May 7, 2007 3:45 PM
Re: So? by Sebastien Auvray Posted May 8, 2007 8:30 AM
Not surprised by Tom Nichols Posted May 7, 2007 7:04 PM
  1. Back to top

    So?

    May 7, 2007 3:45 PM by Jakob Vad Nielsen

    New ideas are always welcome. And Buildr is no exception. I'm am sure that it performs better than maven in the tests. If it can replace maven without any problems it's cool. But what about integration into common IDE's? What about proper documentation? What about the fact that Java programmers can make java plugins, ruby plugins, groovy plugins (soon) in maven? What about the fact that a common build solution will save companies from teaching consultatnts++ new build systems? Speed is always an issue, and should be. But as far as I know contributions to the Maven project is welcome in order to speed things up. If not, then Maven will die sooner or later anyway. I like the idea of a "real" language in my build config. But I think that Buildr will have to deliver much more than speedy build to convience me to switch.

  2. Back to top

    Not surprised

    May 7, 2007 7:04 PM by Tom Nichols

    I can't say I'm surprised. Maven seems to be quite a beast. If they're replacing XML POMs with Ruby scripts, I'm not surprised that Ruby parsing & execution would be faster than XML parsing + Java execution. Obviously the most important point is if Buildr can use existing Maven plugins, then you might have a winner. Maven relies heavily on Plexus, which as I understand is something like an IoC container (probably to handle the plugin architecture). I imagine that's where a lot of the slowness comes from. In Groovy they are currently able to write Maven plugins. Now if they created a Maven POM builder in Groovy - that would be complete interoperability with Maven. That would be cool.

  3. Back to top

    Re: So?

    May 8, 2007 8:30 AM by Sebastien Auvray

    But what about integration into common IDE's? What about proper documentation?
    You're perfectly right, but well Buildr is a few week old baby.
    What about the fact that Java programmers can make java plugins, ruby plugins, groovy plugins (soon) in maven?
    Well, as far as you go out of the maven2 schema, you have to write plugins, and they aren't as easily developed... Zillions of plugins is not really the solution to handle special cases.
    What about the fact that a common build solution will save companies from teaching consultatnts++ new build systems?
    Well the interaction of developers with the build systems should be limited anyway: only extending it, with new libs, new file, new tasks... So once they know how the build system works (and Buildr uses generic concepts), the basic extensions can be written with few lines of script in a small learning curve language. And the more complex one will be handled by plugins. Concerning "common build systems", what about Maven itself when it switched from v1 to v2 ? Didn't the consultant needed to learn again ?... At the end this no real argument.
    But I think that Buildr will have to deliver much more than speedy build to convience me to switch.
    Agree on that one, it should come with time and adoption.

Educational Content

Bindings, Platforms, and Innovation

This presentation focuses on the Internet and separating myth from fact, history from the future, and the mundane from the imaginative. Bob Frankston presents a vision of what could and should be.

Orchestrating Long Running Activities with JBoss / JBPM

This article explores the use of JBoss and jBPM to implement design solutions that effectively address the issue of orchestrating long running activities.

Neo4j - The Benefits of Graph Databases

This presentation covers the use of graph databases as an optimal solution for data that is difficult to fit in static tables, rapidly evolving data or data that has a lot of optional attributes.

Realistic about Risk: Software development with Real Options

This session introduces Real Options and shows how it can help in running your project. Real Options is a decision-making process that can be used to manage risk.

Communication Flexibility Using Bindings

This article discusses the use of bindings on services and references (including the instance of non-configured bindings) as the means to implement SCA communications in a Web and SOA environment.

Writing DSLs in Groovy

After a short introduction to DSLs, Scott Davis plays with the keyboard showing how to approach the creation of a DSL by typing working snippets of Groovy code that get executed.

Scaling Agile with C/ALM (Collaborative Application Lifecycle Management)

IBM Rational and InfoQ present, Scaling Agile with C/ALM, an eBook showing organizations how to become “finely tuned software delivery machines” by enabling team integration and scaling.

Concurrent Programming with Microsoft F#

Amanda Laucher presents a real life enterprise application written in F#. She shows actual code snippets, explaining design decisions and suggesting how to use some of the F# constructs.