Send As SMS

Wednesday, February 15, 2006

A Ruby (on Rails) Shines Brighter Than a Perl

I'll get this out of the way up front: I'm a long-time Perl-head (and sorry for the lame pun in the title). It was what I learned web programming on, and its rapid development and absolute mastery of text-processing kept me loyal to it as my programming language of choice until, oh, about last week.

Enter, Ruby on Rails: offering all the flexibility and ease of Perl without any of the hassle. Now granted, I'm still in the honeymoon period with this new language, but I have to say I really like what I'm seeing.

One of the biggest problems with Perl was that despite my best efforts to keep the code clean and readable, I'd inevitably return to a piece of code months down the road and be baffled as to what on earth was going on. Perl's readability was horrible. Ruby code is so clean and simple – it almost reads like English.

Programming is also involved in my day job, and for a long time I was coding C++ on a daily basis. You get used to having a solid object oriented language, and try as it might, Perl's objects are horribly hacked.

In the end, I found myself really using Perl as a glorified regular expression parser, so when I discovered that not only did Ruby support full regular expressions but was also truly object oriented ala Smalltalk I had to investigate.

Now, of course, you can point to PHP having object orientation and cleaner syntax than Perl as well, but it just never really clicked for me. Maybe it was debugging in a browser, or writing all that code in my HTML editor, but it just didn't do it for me.

With Ruby on Rails, you get a scripting language with clean syntax, low overhead, and a huge bang-for-your-buck factor when writing code. Using Rails, you can generate web database applications that are functional in mere minutes. It's a surreal experience seeing a completely functional web app running off literally a few lines of code.

Tedious configuration, templating and SQL queries vanish. Suddenly, you can focus on making something cool rather than fighting with syntax. The intuitiveness of Ruby is phenomenal, and I think you're going to see more and more people adopt it in the coming years.

I'm sure that as I use it more I'll begin to uncover its flaws and pitfalls, but for now, I'm basking in the glow of having found a new gem for web programming. So long Perl, it was fun while it lasted.

---

Tags: |||

4 Comments:

Perl has a perfectly good object system. What some people get confused about is how this object system was "thrown in" after Perl was constructed.
This is a characteristic of a flexible language. You find the same characteristic in any of any Lisp's object system (CLOS, Meroon, were "thrown in" too).
Whenever people complain about Perl's capabilites for OOP I *know* they don't grok Perl. This includes "celebrities" like Eric Raymond and Bruce Eckel. And, truth be told, most Perl programmers remain at a superficial level (not entirely their fault, due to the profusion of books that do the same).
Here's a good reference: Object Oriented Perl, by Damien Conway (a C++ expert too, by the way). It hasn't received half the attention it deserved.
True enough. And there are quite a few object based libraries available in CPAN as well - I guess it could be somewhat of a 'culture' thing. Most people don't look to Perl to satisfy their need for well designed software - they use it because it works fast.
All this would be very true is Ruby On Rails had an ORM that could actually handle complex abstract queries, or understoof what a foreign key was and respected it. Until that happens I'll stick with Catalyst and DBIx::Class
Pete: Welcome aboard. Wonderful stuff, ain't it?

Anonymous 3: ActiveRecord, combined with the ez_where plugin, can do some amazing things.

W.R.T. AR's foreign key support, I really don't ge it. I add two lines of configuration. Foreign keys... done. I guess I'm of the opinion that the business logic goes in the data model. There are drawbacks to this, but I don't work with integration databases, and for a reason. I like my business logic right out in the open, not tucked away under thousands of triggers and stored procedures. It'd be nice to have it automatically detect these relationships, but considering I work with MySQL, I wouldn't see those benefits, even with InnoDB.

ActiveRecord's real failing (and something they're working on as we speak) is its lack of support for multiple primary keys. But, you'd have to actually use it know that.

Add a comment

free stats