Archive for January, 2006

In Search of Ruby’s Sweet Spot

In a recent post, Stuart Halloway wrote that his company bids up to 50% lower for projects done with Rails, compared to similar Java projects. For applications ‘nowhere near the Rails sweet spot’ they still bid 10% lower. So the question arises: what is that sweet spot? For what projects would you rather choose Rails (over Java or PHP or .Net or…)? These are my suggestions:

  • To start with, the project must be about building a web application (as we’re talking about Rails, not Ruby). But, with Profict, my employer, being specialized in EAI, I’m also interested in using Rails and Ruby for integration projects. I’m guessing Ruby can be used mostly for point-to-point integration (I’ve worked with BEA WebLogic Integration, at the other end of the spectrum, featuring a complete workflow engine and ready-made connectors to all sorts of data sources and applications); but point-to-point might be all you need sometimes. Needless to say I’m waiting for the release of Enterprise Integration with Ruby, a new Pragmatic Programmer book.
  • The existing PHP codebase may hold a useful indication. There’s a wealth of web application software available, written in PHP: content management systems, wikis, groupware, contact/communication software, host management software, blog software… In my opinion, anything to be coded in PHP can also be done in Rails, probably better, faster, more maintainable. Like PHP, Rails applications will be cheaper to host (either by yourself or by a third party) then Java/J2EE.
  • If you’re building a presentation web site (a site meant for web presence only) that has very little code, you would, up till now, probably have used PHP for the scripting. Maybe the site has a contact form that must be stored in a database, or it should run the odd database query and present the results to the visitor. I don’t think I would use Rails here, that would be overdoing it; but you could do the scripting in Ruby. (Of course, Flash might be considered for these kinds of sites).
  • Applications that do not come with clearly outlined specifications and requirements, clients that are not yet completely sure what they want, but they do want something fast: these situations call for prototyping, rapid development, the ability to change direction easily; these are projects where Rails would have a clear advantage.
  • I would hesitate to choose Rails if the project requires a large number of developers, simply because there don’t seem to be many experienced Ruby developers around yet. But this might be a local (Dutch) issue.
  • There would have to be no need for using heavyweight J2EE(-like) features like messaging, distributed transactions, connecting to ERP systems etcetera. I know, there’s a Ruby library available for everything; but if you’re going to need things like these, you’re probably (working for) a large enterprise doing an Important Project where Things Should Never Go Wrong. Let them pay for BEA, IBM or Oracle support (or Microsoft, sorry) to help out when things do go wrong, usually somewhere deep inside the application server.

It might again be a local thing, but I think a company that has chosen Java as their development platform, have done so not too long ago, and will not be particularly happy to switch to something like Ruby. Not even if the project costs them less. For them, Java is a project requirement. Also, they can afford to use Java and they’ve invested in it; I mean, Java is difficult and expensive to host, and Java development isn’t cheap either.
Clients who could be interested in Rails might not even be using Java right now — PHP might be a better guess. Those clients could well benefit from a framework that delivers faster, has a better architecture and is easier to maintain. Compared to PHP, I think Rails is one enormous sweet spot.

2006-01-13. No responses.

Running WordPress 2.0

It just took me less than half an hour to upgrade to WordPress 2.0, the latest version of the blogging software I’m using. I’m impressed with backwards compatibility. Unfortunately, the Textile plugin (which enables you to format text without HTML tags) does not seem to work properly anymore, so mosts of my previous posts are now somewhat malformed. Also I had to switch off the visual editor; my code samples came out looking pretty bad. My modified version of the Now Reading plugin (including a Favorite books section) still works, as you can see. I had hoped for a lot more options to configure and checkboxes to click on and so on, but the administration screens haven’t changed that much, apart from a visual update. Okay, back to blogging!

2006-01-10. No responses.

Closure Time for Java

Someone on our (Java) project team has so fallen for Ruby that he is now trying to force the Java code into Rubyesque patterns. He has found an ally for this in the Commons Collections Closure interface. What he seems to want to do in Java is the equivalent of:

sum = 0
list.each { |item| sum += item.amount; }

The Commons Collections Closure class looks like it will help out here, but it won’t. The following code will not compile, because sum must be declared final; and if you do that, you may no longer modify it inside the closure:

CollectionUtils.forAllDo(items, new Closure() {
    public void execute(Object o) {
        Item item = (Item) o;
        sum += item.amount;
    }
});

But then, Closure was defined with a restriction to begin with. If you add the ability to receive parameters beforehand, like this:

public abstract class MyClosure {
    public Object[] params;
    public MyClosure(Object... params) {
        this.params = params;
    }
    public abstract void execute(Object o);
}

then you can send the ‘outside’ variable, sum, to the closure constructor; so it can be used inside the closure:

Object[] result = forAllDo(items, new MyClosure(sum) {
    public void execute(Object o) {
        Item item = (Item) o;
        params[0] = ((Double) params[0]) + item.amount;
    }
});
sum = (Double) result[0];

The new forAllDo needs to return the closure’s parameters after looping, but is rather straightforward for the rest.

Of course, it’s still a long way from Ruby’s simple syntax. Also I wonder how much patience constructs like these will require from the people that will be maintaining this code. After all, the usual way of doing this in Java is just iterating over the collection’s items. But I guess it’s good to look at your coding habits from another point of view now and then.

2006-01-09. 17 responses.

The Answers to All Your Questions

Beginning bloggers can often be recognized by their fixation on web server statistics. I don’t mind admitting that I’m no exception. It’s just as satisfying to see that people read my ramblings, as it is to see people use a computer program that I wrote. Besides, the stats can show you some very interesting information, like which posts are popular, and what other sites refer people to this blog. But what’s most intriguing, is the search words some people used that lead them here. With some search words I really wonder how they could have led here, and if the posts here ever gave people the answers they were looking for. (Then again, I guess that’s the beauty of the web: you usually find what you’re looking for, but more often you find ten other things you weren’t after but are still interesting enough to look into.)

For example, how about the person that asked his search engine of choice, literally, “did sauerkraut come from switzerland?” Why did they want to know? Was the answer ever found? Does it really matter where it comes from? Personally, I would say straight away: sauerkraut comes from the Alsace region in France. The best sauerkraut I’ve ever tasted, anyway. But sauerkraut is eaten in many places, and many varieties. In Holland it’s usually mashed with potatoes, baked lardons mixed in, and served with smoked sausage. We had braised cabbage in Slovenia, which looked a lot like sauerkraut but wasn’t sour at all. According to Wikipedia, sauerkraut originated in China. Strange, it’s never on the menu at the Chinese takeaway’s…

Sauerkraut-like cabbage on the Ljubljana market

Continue Reading »

2006-01-07. 2 responses.

On Cheese: A Story of Love and Hate

As a child, I was first introduced to French cheese by the man behind the counter in our local grocery store. He offered my mom and me a slice of Brie on a cracker. It wasn’t the best of acquaintances. I wasn’t a big fan of (Dutch) cheese to begin with, and this was just more smelly and more gooey.
Some years later in life, I got a proper introduction by the woman who is still my cheese guru. She could happily have dinner eating nothing but bread, some salad, and loads of cheese. Foul, smelly, stinking cheese — that more and more often began to taste not so bad, actually. I never saw her eat Brie. (Last time we met her she served us goat’s Brie but I don’t think that counts. After tasting it I realized that I’m still far from being a fearless cheese eater.)
The best tip she gave us recently, was to buy Coulommiers cheese. She did say to buy it at the market in the village nearby where she lives (in France); but during our last visit to France, we weren’t there on market day, so we skipped and bought some in the supermarché to take home. Bringing cheese home from France is another mixed pleasure. Every time I open the fridge, a horrible stench gusts out, best resembling the smell of fresh manure. For some reason, cheese bought here in Holland never smells that bad. Maybe that’s why it doesn’t taste as good, either.
The Coulommiers tastes like Brie with a fierce kick (it’s actually from the Brie region, so technically it is a Brie). I like it best straight from the fridge, that’s soft enough for me — but my cheese guru will disapprove. According to her, cheese should be taken out of the fridge at least an hour before eating it. I guess I still have issues with gooey things…

A picture of the Coulommiers still left in our fridge. You can almost smell it. Note the ‘au lait cru’ sign on the package; unless you’re pregnant, don’t buy cheese without it, or it will (usually) taste as bad as it smells.

2006-01-06. One response.

« Prev - Next »