Some week ago I was doing a peer review of one of my team-mates. We came across one of the objectives that he had since our last review (more than one year and a half ago): P. should have deepen his knowledge and practice of the ruby language. The idea here was partially inspired by PragProg’s concept of “learn a new language every year”. Another source of inspiration came from the hacker’s culture as described by Paul Graham articles.
P. wholeheartly agreed with the objective and slowly started devoting some spare time to study ruby, mainly by means of reading the PragProg’s so called PickAxe book, at that time at his first edition, freely available on the web and automatically installed with ruby. The problem is that everyday job is to develop in java, there is really a little space for ruby in everyday activities.
Infact, P. clearly missed his objective, as he recognized himself as well. I wouldn’t blame him, I know and I have seen that he tried. Apparently there was really no time, nor any significant occasion.
But is this really true?
In this period I’ve found myself dealing with process and code metrics in search of the Productivity Myth. I’ll write more about it, that’s not important now. The point is that I had to check out several modules from a CVS repository, isolate certain files, invoke metrics calculation on those files, manipulate the result and add it to a file. Well, that sound simple, doesn’t it? How would you do it? Where would you start?
If you are an ol’ time *nix hacker you would probably write a shell script, combining already existing tools with pipes and redirections. That is nice, really nice, but maybe you are on a Windows desktop, and you don’t know yet if this got to run on your desktop, on a linux server, or whatever. And maybe you are NOT such a good hacker!
I can tell you what I have done: I started slamming together some code in ruby, mainly small isolated one-liners, jumping from a shell prompt to irb, where you can interactively experiment with code. After a while I began writing the code in a .rb file, trying and correcting, one little step at a time. I haven’t developed in TDD-style this time, because I don’t think it’s really worth for a 70 lines script of procedural code.
I learned a lot of course, because I’m not either a fulltime ruby expert, but … who cares!?! I did it and I enjoyed it, so what?
Ok, ok, I know what you are objecting: “Hey, you are dishonest, we were talking about somebody who is developing all the time in java due to external constraints that he cannot control!”
Interesting objection, but are you really sure? What about those dozen of ant scripts that I see in every project, ranging from building, to moving, to deploying, to generate sources and mappings … yes, tell me about them, tell me about hours and hours spent trying to understand why that ant script, including another one, based on a custom task, never really work as expected; but if they work, try to change them after some months! I could have decided to develop ala TDD or cover some areas with test afterwards, but what about those deploy procedures in ant, so important and so fragile at the same time, with no verification at all associated to each of them?
By the way, this is just an example, there can be a lot more. What about those tens or hundreds of bookmarks that you have collected and you would like to post on del.icio.us? What about that Excel worksheet that you feed every month with your loan payments, integrating with interest rate predictions and projected into the future? etc. etc.
The message here is that you are not really spending 100% of your time writing java code, even if that’s what you are supposed to do based on your business ticket. So, don’t be lazy, and start saving time with ruby.