Sunday, February 05, 2006

I can't do Ruby (a.k.a. strict typing)

I took another stab at getting into Ruby this weekend, as it has long been on my list of things to learn. I have attempted this in the past, but something always drives me away. I guess one of the things that draws me to the language is all of the hype about Ruby on Rails, but I just can't seem to do it. This time what drove me away was the lack of strict typing, for reasons I will try to explain.

Let me first explain the world I come from. I have been writing code professionally for 10+ years, and coding for fun for almost 10 years before that. During my professional career I had worked almost exclusively with Perl for 5 years, and now I work with Java. Coming from the Perl world, and being a strong advocate of the language, you would think that I would easily latch on to Ruby. The problem I think is that I have been tainted by Java.

With Java I need to declare the specific type of value that a variable can hold, and over time I have started to see this as a feature as opposed to a nuisance. When I was writing Perl, the last thing I wanted to do was to waste keystrokes telling the interpreter what type of values a variable would hold. With Perl I wanted the interpreter to do what it was told. Now that I have worked with Java for nearly five years I see things a little differently. The Java compiler is my friend, as it 1) makes me document my code by declaring variable types, and 2) stops me from potentially adding a difficult to trace bug.

With Perl, I can perform near miracles with a couple lines of code. Even now, when I am asked how some list of files can be altered in some specific manner I will quickly whip up a Perl script. Perl is my programming companion, and I could not imagine working without it. I suspect that if I ever did learn Ruby, it would fill this same need.

For large projects though, I would never user Perl, or even Ruby I would expect. The difficulty is that when I pull out my favorite IDE, it can't perform adequate autocompletion or refactoring with these languages. I remember the joy I felt when I started using the Eclipse refactoring tools for Java. With these tools I was able to effortlessly move methods up to parent classes, rename methods, encapsulate variables, and perform other refactorings with ease. I can now dive into an old nest of poorly written Java code, and quickly clean it up so that I can add needed enhancements. It is also failry easy to use an unfamiliar library when the IDE's autocompletion tool can display properties and methods of any variable.

Maintenance typically consumes 40 to 80 percent (average, 60 percent) of software costs. Therefore, it is probably the most important life cycle phase of software. - Robert Glass, Facts and Fallicies of Software Engineering

The bottom line is that I love languages like Ruby, Perl, and Python... but they hurt me more than they help me when I am maintaining a large project with thousands of lines of code. The word maintenance is the important point here, as maintenance is the majority of the software cost over it's life. So for me, my choice is to spend the extra time with a verbose language like Java when working on a large project that will hopefully have a long life.

No comments: