Sunday, November 19, 2006

Too Much Choice Considered Harmful

... or: Why I Ditched Java and Switched to Ruby on Rails.

This post is a case study which supports the notion that too much choice is actually a Bad Thing. I've recently read a book that explores the topic in some detail, The Paradox of Choice: Why More Is Less by Barry Schwartz.

Some background to start with. I've been developing Java-based web applications since 1997. In 2000 I started dabbling with servlets and even wrote some introductory papers for my colleagues at work.

The first major web application I developed was for a startup called SupporterZone. At the time (early 2000) developers were basically left with the task of coding to the raw Java Servlet specification. To deal with some of the basic plumbing I wrote some classes to help abstract over the basic Servlet API. More competent people than myself were doing the same and Java "web frameworks" began to emerge to help make web development less painful.

In late 2000 when I was given the task of building web-based front-ends for database administration and reporting, I began investigating some of the emerging web frameworks. An Apache Jakarta open-source project, Struts, looked promising, and was getting favourable reviews on various mailing lists.

Struts served me well for the next few web applications I worked on from 2001 to 2003: extensions to SupporterZone, a brand new online classifieds site called Adengine, and a Management Programme Reporting tool for a State Government Department. But for most of 2003 and 2004 I worked on a popular State Government web application called PropertyAssist. The application dates back to the early days of Java Servlets. It sort of uses a Model 2 architecture, but by way of a homegrown web framework. So over this period I sort of lost touch with all the new Java web frameworks that were coming onto the scene.

In early 2005 I started working for a new client. They were developing a greenfields web application to manage their customer information system. I was one of several contractors in the newly-formed team. There was obviously some discussion about the architecture of the new system, in particular which Java frameworks would be used in the 3-tier application. We needed a data persistence API, and the choice came down to Hibernate or Enterprise Java Beans (EJB), with Hibernate selected. For the service layer, Spring seemed like a logical choice since it can play nicely with everything else. However the web layer proved much more contentious. Tapestry, another Apache Jakarta open-source project, was chosen. I had a brief look at Tapestry and found it quite strange. It had a reputation for a very steep learning curve, mainly due to its attempt to replace the standard request/response approach to web apps with a component model, similar to desktop Java Apps written using Swing. I had a look at some articles comparing the various web frameworks, and while Tapestry had a devoted following, it was nowhere near as widely used as Struts. However the other contractors had a lot of experience with Java Swing (a GUI API) and they liked Tapestry. They were able to quickly demonstrate a basic sample application that used the proposed frameworks. I considered demonstrating a sample application using Struts, but decided against it because Struts would have been dismissed as too "old-school" by the other contractors. I also briefly thought about trying some of the other web frameworks: Java Server Faces (JSF), WebWork, Spring MVC, Cocoon etc. But to be frank I did not have the time to devote to the task (I was only a part-timer, with responsibilities outside of work preventing extra-curricular activities). There are just too many Java web frameworks to look at, and not enough time. Just reading about all the frameworks made my head spin. It looks like I'm not alone in my disillusionment with the situation:
In mid 2005 left that job when I got the opportunity to return to working on PropertyAssist. I enjoyed not having to think too much about what web framework to use, and could focus on just doing the work.

However the issue of choosing a web framework reared its ugly head again a few months ago when I was asked to develop a new web-based application for a private company. Time was of the essence, and I simply did not have the luxury of evaluating all the open-source Java frameworks. So I did a semi-courageous thing: I eliminated Java as the language technology for delivering the application. Another option was to use PHP, and in fact there had been an attempt to build a PHP-based application internally within the organisation. But when I looked for web frameworks in the PHP world I found the same problem: too much choice! (e.g. look at this list of PHP MVC Frameworks). Therefore PHP was ruled out too.

The only other contenders that I considered were my two favourite scripting languages de jour: Python and Ruby. Last year I had written some Python scripts to manage my web site, and I liked the language. But unfortunately I hadn't worked with any of the Python web frameworks, of which there are a few. Ruby is the other scripting language I've been following in the last few years. And I've been tracking the buzz around Rails, a web framework for the Ruby language. Now, I've been in the software development game for a while: 9 years professionally and since 1984 as a hobbyist. There's a lot of hype in the industry, and I know there is No Silver Bullet, so I approached Ruby on Rails with cautious optimism. My previous Ruby experience is only writing a handful of simple scripts, so writing a reasonably-sized web application from scratch in Ruby would be a big step up. Initial experimentation writing a basic sample application proved promising, both in ease of development and in the capabilities of the technology. So I felt confident enough to propose developing the new system using Ruby on Rails. Fortunately the client was willing to use any technology, providing I delivered. Let me say this: it was probably the most couragious decision I've ever made regarding technology selection on a professional project, and I have absolutely no regrets. In about 100 hours I built a web application managing over 30 database tables, some of which were quite complex. Remember also that I was learning both Ruby and Rails while I was working on the project. And I actually enjoyed myself. Ruby is a wonderfully-expressive language. I wouldn't say it's "the best", but I've used quite a few and it's right up there. And Rails is the Real Deal when it comes to building web front-ends for databases. The framework lets you focus on the problem being solved, allowing time to be spent on the "bells and whistles" that make the customer smile. Admittedly I was able to design the database tables from scratch (albeit modelled on the Access database tables the new system would replace). But legacy support in Rails is being constantly improved so that criticism is becoming less relevant.

So, in conclusion, if you're a jaded Java web developer and need to develop a web app real fast, consider Ruby on Rails. I'm not suggesting that it's a Silver Bullet. Nor am I saying that it is suitable for all web applications. But it does represent the state of the art for developing database-backed web applications. It might just open your eyes.

Labels: ,

Saturday, November 18, 2006

A Tale of Two Brothers

Currently there is a G20 economic summit in Melbourne, where the finance ministers and central bank governors of the 20 most developed nations. The host is Australia's Treasurer, Peter Costello.

One of the items on the agenda is addressing global poverty. The Reverend Tim Costello, Peter's brother, is Chief Executive Officer of World Vision Australia, and Campaign Co-Chairman of Make Poverty History. He's criticised the Australian Government for failing to meet it's commitment to provide 0.7% of GDP as foreign aid. According to Tim Costello, Australia ranks 19th out of the top 22 developed nations when comparing the proportion of GDP given out as foreign aid. Peter Costello prefers to focus on the the raw dollar amount of foreign aid given by the Australian Government, which is an impressive-sounding $3 billion this year.

The media of course is relishing this public debate between to high-profile brothers, for example ...

Costello brothers argue over Australia's aid record

So who would you trust, a politician or a humanitarian :) Personally, when you get down to brass tacks, the Reverend Tim Costello gets my vote.

Here is an overview of the situation, with quotes from an interview on the ABC's Lateline
Tony Jones speaks with Tim Costello
[T]he global plan called the Millennium Development Goals ... we signed up. That is where we promised 0.7 per cent and haven't kept our promise...
Back in 1970 when all the developed nations said we're going to aim to give 0.7 per cent, that's 70 cents in every $100 of GNI. We said yes. At Monterey 2002, at Rio 2000 we repeated it. In August 10th, 2005 last year in Parliament, Alexander Downer repeated and said we are committed to 0.7. The problem is all the other countries, developed countries, have set a timetable and have moved towards it. Britain is at 0.49 per cent and France 0.47 per cent. Even when we get to what Peter has promised, the doubling of aid by 2010, we will still only be at 0.38 per cent whereas the average for all of the developed countries today is 0.45 cents.

We seem to be good at signing these internatinal agreements, but not acting - just look at the Kyoto Protocol, which we've actually signed but declined to ratify.

Another disturbing quote from the interview:
$400 billion approximately has been spent by the US in the Iraq war... The world developed countries only give $100 billion a year to the total one billion people living on less than $1 a day and 30,000 children die each day.

Fortunately the Australian citizens have been happy to take up the slack left by our Government's thrift. We are second only to the Irish in private donations to foreign aid agencies.

Labels:

Yeah, What He Said. Hang On ...

Former Australian Media Mogul Rupert Murdoch, "Addressing an exclusive black-tie Australian American Association dinner in Sydney, Mr Murdoch urged Australians to resist and reject the hostile anti-American sentiment that has gripped much of Europe." (Murdoch urges Aust, US to maintain strong relations)

We, along with the rest of planet Earth, have had to endure George W. Bush's nightmare of a presidency for six long and painful years (and unless he does an honourable thing we have two more years to endure). So excuse us if we feel a bit bitter to Dubya and his band of global havoc-wreakers. I think Uncle Rupert is over-generalising by labelling anti-Bushism in Europe as anti-Americanism. I'm pretty sure that the feeling in the streets of Europe (and Australia) is not the same type of anti-American feeling harboured by terrorists. If it were, then we'd all be in real trouble.

Uncle Rupert does concede:
"But wars end. Administrations come and go. The Australian people must not allow their perfectly legitimate doubts about one policy or one American administration to cloud their long-term judgment."

Since he also concedes that the Iraq War remains "unpopular" in Australia, is he inferring that we are right to consider the War an unmitigated disaster? If so, I bet John W. Howard was squirming in his seat at that exclusive black-tie dinner.

While on the subject of anti-Bushism, there seems to be a lot of it inside the United States as well ...

Misplaced loyalty to a diminished leader
In the US, anti-Bushism is now downright patriotic. Speaker-designate Nancy Pelosi has denounced the President as shallow, deceitful, dangerous and incompetent (sound familiar?). Many widely respected conservatives were actively barracking for the Democrats last week. These included veteran pundit George F. Will, who reckons the Republicans got off relatively lightly "for the party that has presided over what is arguably the worst foreign-policy disaster in US history".
[Matt Price, The Australian]

PS How ironic that George W. Bush finally goes to Vietnam, albeit to attend APEC as the "Leader of the Free World", just as his Iraq War looks set to eclipse the Vietnam War as the US's biggest foreign policy disaster ever.

Labels:

Friday, November 10, 2006

Fortress Suburbia

At 8:45am every weekday morning the draw bridge opens and the gleaming metal carriage rides out of the fortress.

No, this is not the scene from a medieval story, but rather everyday suburbia. It's not really a draw bridge, just a massive electronically-operated garage door that is raised to reveal a thirsty behemoth of a car. Some children are being taken to school. But in fact the scene is repeated several times a day. The thought of simply walking out the front door to go to the shops or elsewhere has become an alien concept in this day and age of convenience.

Perhaps it's more than that. In the suburbs we seem to want to close ourselves off from the big, bad outside world. So if we do need to venture from the absolute safety of our homes we need to surround ourselves by a tonne of metal and glass. Not content with having our whole house airconditioned to the perfect temperature, we also have to take that perfect climate with us. No matter what the consequences are for our global climate.

Labels:

Friday, November 03, 2006

Wake Up Australian Car Makers!

Almost everyone and their dog now accepts that global warming is happening. Unfortunately governments can't always be relied upon to do the right thing. Witness how the Australian and United States governments still refuse to ratify the Kyoto Protocol. Look at the participation map for the outcasts in red.

Australian citizens may decide to take the future in their own hands. This could be disastrous for the local car industry, because the three locally-manufactured vehicles have pathetic carbon dioxide emission numbers:
  • Holden Commodore (VE) ..... 260 g/km
  • Ford Falcon (BF) ................. 244 g/km
  • Mitsubishi 380 (DB) ............ 259 g/km
Source: http://www.greenvehicleguide.gov.au/

A random look at typical overseas-produced vehicles highlights how bad the Australian-made cars look in comparison:
  • Fiat Punto ............ 145 g/km
  • Honda Civic ......... 164 g/km
  • Peugeot 307 ........ 188 g/km
  • Toyota Camry ..... 210 g/km
Admittedly these are all 4 cylinder models, while the Australian-built cars are all 6 cylinder models. But perhaps the local manufacturers need to wake up and smell the coffee before it's too late.

Labels: ,