Is Ruby the new Perl?
I don’t know Ruby very well, and I have only looked at Ruby briefly a couple of times, and this of course is not sufficient to make an objective and qualified judgment of Ruby. However, what would the Internet be without unqualified ramblings?
Today, while doing my daily coffee and Google Reader routine, I saw a post on PRC that someone had written a MUD in 15 lines of Ruby. Then of course the first comment is “Freakin’ amazing. I love Ruby!”.
Pardon my Perl
Perl is a programming language with a PR problem. It has a lot of features, and in the hands of the right person it is possible to produce quite elegant code. In the hands of the wrong person though, you will quickly get the worst code known to mankind. To be fair, horrible code can be produced in any language, but some languages facilitate the possibilities of writing horrible code more than others. Perl, I’m pointing at you.
When I first looked at Ruby a while back, it immediately struck me as being a cross between Perl and Python. It still does, but recently it has begun to feel more like Perl than Python. Especially considering there seems to be a mad rush towards Ruby, and it’s tempting to draw parallels to the mad rush towards Perl in the late 90s that probably lead to Perls big PR problem.
For new readers, Perl was (and perhaps still is) the language of choice for the newbie that wanted guestbooks and mailers on their website, leading to people without the right skills creating horrible code and lots of security problems. It’s extremely easy to get started with Perl and get things done, and this turned out to become a problem, believe it or not.
This is when defensivists of Ruby (and Perl) start blaming developers for bad code, and defend their favourite language. That’s ok, language wars can’t be won, so I’m not expecting the developers of Ruby and Perl to simply stop what they’re doing and start using Java or Python or Ada or whatever.
Developers are very protective of their ideas and choices in programming languages, especially when they’re young. As they grow older, they become more cynical, and this can either make them even more protective and defensive, or make them realize that the search for the perfect language is a neverending quest. Perhaps it’s unavoidable - shouldn’t we always be searching for something better?
Ruby vs. Java
There seems to be quite a lot of attention to Ruby from the Java camp, Sun has even hired some of the developers of JRuby to work on it full time. Java 6 has support for scripting languages, and it’s possible to package Ruby on Rails applications as WAR files and deploy them in J2EE application servers.
It’s no wonder Ruby is popular with Java-people… They have to work with Java after all, and it’s not the greatest thing since sliced bread, although it is a language in development and I’m sure it will change even more than it has the latest years. This is where Java Haters will proclaim that Java is horrible and doomed. I will do no such thing, Java has its uses.
So, if Java developers are running to Ruby, it’s just because they’ve suddenly discovered that it’s possible to work in a language that is less verbose and easier to use. Well, I have news for you, it’s been possible all along!
The Unwinnable War
There are some things that are necessary for developers to succeed. First, they have to be smart. Second, there are some external factors that have to be right, such as the work environment, project management, planning and so on. If these things are not in place, the result might not be very good.
In my years of experience, I have come to believe that the programming language is one of these external factors. At least it is for me. It shapes the way we think and design solutions, and the community around a language also affects this. That is why Java developers are so much into abstraction and object factories, and Perl developers into code magic. Notice how I’m generalizing immensely here, apologies to everyone who doesn’t feel at home in these generalizations.
You can Get Stuff Done in any language, but if you choose a language that is more structured and easier to read, I believe you are on your way to producing good and maintainable code. Yes, yes, I can hear you screaming from the back row, it’s no silver bullet and unmaintainable code can be written in any language, and you’re right.
But choosing a good programming language puts you on the right track.
When I look at Ruby, some alarms always go off in the back of my head, and it feels like Ruby isn’t a language that will put you on the right track. Hacks like a 15-line MUD shouldn’t be applauded, and shouldn’t be why developers love Ruby. Yes, it is nice that you can get a lot done in few lines of code, and it is wonderful compared to Java.
Is Ruby the new Perl?
Is Ruby the new Perl? Only time will tell. Will I be developing in Ruby? Probably, it has a lot of momentum, so somewhere down the road there is probably some Ruby code waiting for me to be written or maintained. I don’t mind, I’m flexible and open minded. Perhaps I’ll even turn out to love Ruby.
But you can bet I’ll be searching for something better.
“But you can bet I’ll be searching for something better.”
But.. didn’t you just turn 30? ;)