“Before you speak, listen. Before you write, think. Before you spend, earn. Before you invest, investigate. Before you criticize, wait. Before you pray, forgive. Before you quit, try. Before you retire, save. Before you die, give.”

Sunday, December 5, 2010

Ruby on Rails or the beauty of instant feedback

I was trying to write a GWT application that would help track the weight , calories and training for a person and make it run in the Google App Engine. Unfortunately I was always blocked by some configuration issues which made me delay it (being tired after work does not help).
So Saturday I thought maybe I should give this Ruby On Rails a try since I am into ruby a lot lately.
Using Netbeans I started with the sample "Depot application" and started to understand RoR a week ago.
After watching this video of DHH presenting Ruby on Rails and the concept of scaffolding I was able to get started in no time .
Today (less than 24 h since I started) I have a working weight tracking application which needs some improvements .. but it is working.
Being able to avoid the compile/deploy/test cycle and replacing it with just "test" was a huge benefit for me.
Instant feedback is really enlightening and reminds me of the reasons I actually loved PHP years ago. As a beginner programmer I wrote "working" PHP code that was horrible with no MVC separation .. or layering. It was a shame but it worked.
Right now when looking at Rails I see somehow what PHP should have been like ages ago .. the benefits of PHP and the engineering I used to see only in J2EE frameworks. And best of all I did not have to write one SQL line .. this is fantastic for me :).

Yes I know a Jedi JEE programmer must be able to just figure out things such that a single deploy will be enough for all fixes. Well it usually ain't the case and I find myself waiting for the machine to deploy only to find other things to fix .. which I thought were fixed and the human brain can only keep track of 7 things at a time .. add to this the typical open plan office space , personal concerns or other thoughts and you get minimal productivity ..
I realize running the projects inside Netbeans and/or Eclipse allows sometimes the automatic redeployment but even that takes time.
We have MVC , Active Record pattern for ORM , automatically generated unit-tests, integration-tests, functional tests , the famous convention over configuration rule , clean layers (except the service layer that for now I do not miss).
As I read in Bruce Eckel's "Thinking in Python" (for a while I wanted to choose between Ruby and Python) it's not the static type checking or compiling that brings so many benefits it's the use of unit-tests.
Hence I strongly believe well written Ruby on Rails applications can be equal or equivalent to J2EE applications for the same purpose it the test driven development technique is used. Moreover I wrote way too much Java to know that not using unit tests and a technology like EJB2.0 can lead to almost 0 productivity (unit tests seem to help as you do not have to start the container just for a small function you just wrote).
Yes the same can be said about PHP .. you can write horrible code in any language , but Ruby is the new high level language of the day and I tend to go with the flow.
Of course being an Java developer /architect wanna be I realize my 10 years experience in Java are going down the drain with this Ruby on Rails stuff but if I can get things done while having fun .. why not ?
Of course if I have to develop something that has to be distributed and integrate with other tools I will still go for Java but some smart guy invented JRuby meaning I could be running Ruby in a JEE container in order to do a slow migration.
Of course making a JEE application go through the build deploy cycle without issues would be nice , I just can't see how.
This link shows how much time we are loosing with deployment and 2.5 weeks a year looks like a lot considering just the salary of the average developer.