Saturday, December 31, 2005

Happy New Year

A big Happy New Year to all. As the new year approaches all of us can look forward to new opportunities and experiences remembering that life is what you make of it. We never know what may be right around the corner.

Wishing everyone the very best in the coming year.

Thursday, December 08, 2005

Using the right tool for the job

Having developed software for quite a few years now, we won't discuss how long since I don't want to date myself :-), it is very easy to stick with a language you use frequently. When a problem arises, you immediately think, "how would I solve that in C++ or Java?". This seems perfectly reasonable given you know the language well and should be able to put something together pretty quick.

Just the other day I found myself in such a situation, I needed to pull apart a binary file to ensure it was being generated correctly. The code that produced the file was in java, however it was a small part of a much bigger system and thus was not easily reused for my purposes. Sitting in my chair I'm thinking how I can quickly put something together that will output the contents of the file and maybe do a little validation in the process. Using C or C++ would not be to bad but require the setup of a VC++ project, generate a main(), write some file code, etc, etc, etc. Nothing hard here, just tedious. Java was no better, I would have to create many of the same things required by C++.

It was about this point that a thought came to me, why not use Ruby? A little Ruby script could pull the file apart easily enough and there would be no need for a main and the file code would be really simple. Only problem, although I've used Ruby for a few things I'm still learning alot about the language so it would no doubt be quite a bit slower to write an app in Ruby than it would be with Java or C++ right? Well, Ruby it is, after all, this adds a little variety into my development life!

So first things first, how to read binary data from a file using Ruby? A quick web search outlined how to use the File class and the associated read method to access binary file data. After that things just flew. Quite literally, 5 minutes after I started a complete Ruby program was on the screen in front of me that would produce a nicely formatted output to the standard console outlining the contents of the binary file. Could I have written the same thing in C++, sure, would it have been completely done in 5 minutes, doubtful.

This is productivity at its best. The little program is easy to read, can be extended in no time and proves to be a valuable debugging tool. Pretty good for 5 minutes time! This just goes to show, using the right tool / language for the job can really pay off even if you don't know it as well as another tool.