JRake: Ant-Killer Combo of JRuby and Rake
The closer JRuby gets to being usable in real development efforts, the faster the pace of innovation gets in the realm of solutions combining the best of Java and Ruby technology. Case in point: JRake, pet project of notorious ex-ThoughtWorker Matt Foemmel, which replaces Apache Ant build files with Rake scripts running in JRuby.
The ant-killing combo is getting caned by Martin Fowler himself, a long-time fan of Rake, who explains why he finds JRake desirable:
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.JRake goes beyond being a simple replacement for Ant scripts. It actually speeds up the development process significantly. Matt explains his motivation was achieving the productivity of dynamic languages:
What we really want is for Java code to work the same way that dynamically typed languages do: you change your code, hit "save", and view the results in the browser.According to Matt, having to use Ant drove him crazy:
The Java virtual machine takes time to start up. Since most tools that deal with Java code (e.g. javac) are themselves written in Java, this means there is a rather annoying interval between when you invoke them, and when they start doing actual work. This delay may seem insignificant, but on a large project where a build consists of many calls to many tools and gets run many times a day, all that wasted time can really harsh your flow.The solution leverages Jetty in an innovative way:
I think I've managed to achieve something close to this, by setting up a Jetty server to act as a kind of proxy for my main application. Whenever a request comes in, it performs the following steps:Projects like JRake paint a vivid future for Java and Ruby combinations.The upshot is that I can now make changes in my IDE, and see those changes (almost) immediately in my browser. No new virtual machines are started up along the way, no extra alt-tabs are needed, and I don't have to worry about hitting the web page before the deploy is complete. These may seem like minor points, but when you're doing this stuff eight hours a day, those little annoyances can add up.
- Calls out to the JRake script to compile any out-of-date code.
- Creates a new classloader, and uses it to reload the application's main servlet class.
- Creates an instance of the servlet and forwards the original HTTP request on to it.
Constructive criticism
by
Hani Suleiman
The post, as can be expected given who posted it, does not serve the java community at all. It's a thinly disguised gloaty piece about how great ruby is. Now, Ruby might well be great, but do I now need to unsubscribe from the Java feed on infoq too because some idiot thinks that ruby related content belongs here?
Aside from the idiocy of the response, it's mildly offensive to have a thoughtworker post about something an ex-thoughtworker did, and then say that another thoughtworker finds it great. It's surprising to say the least to see what amounts to a bunch of people from one company applauding each other being considered 'content'.
Also, if you're so keen on maintaining that infoq is a cut above tss and has more to offer, it's inexplicable why a news article would say things like 'bat-shit', when even TSS on a bad day manages to churn out news items on a daily basis while still sounding at least vaguely professional.
Finally, the article seems to say one thing, then discuss another. I'm still utterly perlexed as to why we need an explanation of how to reload a servlet (something which any idiot can do these days, if you're rebuilding just to update a servlet you're a loser) as part of a news item about a new build tool. Last time I checked, build tools and hot-redeployment weren't exactly codependent features.
The Java content on infoq is usually pretty good, I hope this isn't the start of a new trend where we get more objectionable content that serves nobody in a cheap attempt to encourage more 'discussion' (read: flaming).
Additional systems
by
Tom Ayerst
Re: Constructive criticism
by
Martin Gilday
Re: Constructive criticism
by
Kevin Williams
So, Java community, will you get all uppity and turn up your nose at this just because it's Ruby? What if it were done in Haskell? C#? D? If it helps you, use it! If not, move on. Java already integrates with many other languages (SQL, HTML, JavaScript, C, Python, etc.) so what's the big deal? Java and Ruby do work quite well together already, and it's only going to get stronger. Remember, Sun hired these guys, and they haven't buried the project like Microsoft would.
I do agree on the un-professional tone that things like "bat-shit" lend to an otherwise eye-opening post.
Re: Constructive criticism
by
Hani Suleiman
I'm all for new and innovative ways to build stuff, a servlet reloader as implemented in this example is certainly a nice niche toy that's worthy of mention for the 1% of projects that are trivial enough for it to work with, but let's not pretend it's relevant for the majority of Java developers, and lets call it what it is, a neat, albeit fairly useless for practical applications, little gizmo. I prefer the 'info' bit of 'infoq' to be info, not religion.
I'm assuming that most readers of the Java community on infoq are Java developers. Would you trust your news to some random guy who has sworn off Java, writes poorly, and spends most of his time babbling on about how amazing ruby is? Isn't that what the ruby community is for?
Re: Constructive criticism
by
david m
However, it is a distraction to have to set up and learn the basics of a new language (of which there are a zillion, each with its own special features) just for one task, and the article is very badly written. Rather than putting together scraps of attitude and background, which I really don't care about, a better article would have some background on the issue, would explain the solution and considerations for those of us who don't know everything there is to know. For example, from what I can tell (and I'm deferring to the experts), this solution reloads the entire app for any small change, which seems excessive.
Would be even nicer if the better article included a native Java solution.
Re: Constructive criticism
by
anjan bacchu
"
JPython, which was created by Jim Huggunin languishes today while IronPython sees more uptick after MS hired him. Let's check our facts, shall we ?
BR,
~A
Re: Constructive criticism
by
Obie Fernandez
How does this compare to Eclipse, etc.
by
Porter Woodward
Having said that I also realize that it's usually a far cry from the ease of development in Eclipse (quickly seeing the effects of changes) - and actually packaging up an application for deployment to the data center.
Educational Content
Co-making Great Products
Jeff Patton May 22, 2013




Hello stranger!
You need to Register an InfoQ account or Login to post comments. But there's so much more behind being registered.Get the most out of the InfoQ experience.
Tell us what you think