Perl, Ruby, why hast thou forsaken me?
by codemonkey on Nov.13, 2009, under Dave's Rants
I remember when I first learned perl. I was lucky enough to be traveling internationally with a big-wig (VP of Engineering) of my company, so I got to hang out in the First Class airline club at the airport. He was going somewhere else, but, once I was in, I was in. I didn’t want to leave and risk not being able to get back in, so, I pulled out Larry Wall’s Perl Programming book. (The first edition O’Rielly’s Nutshell book)
I was instantly in love. I don’t know if it was the very geeky jokes, or just how simple the language, but, from that day on, I was a perl head. I did many things with perl that many people would use a compiled language for. If I couldn’t do it in a shell script, I did it in a perl script. If my shell script needed awk or sed, it was time for perl. It was probably the biggest, most useful tool on my toolbelt.
But, that was about 12 years ago. And, since then, perl hasn’t changed much. All of the OO stuff that was added just confused me. It made perl harder to use, not easier. I am a huge fan of OO (when it is called for), and, perl just wasn’t making the grade.
About two years ago, I picked up a book on Ruby. Ruby was (is?) the best implementation of a clean OO language that I’ve ever seen. I love the itterators. I love the fact that even a literal is an object. 5.method works just fine, using a method of the literal 5. Plus, the syntax was very far from normal c-style languages. It would have easily replaced perl, except that — being so far from C syntax, I never hit that grok stage. Also, there are a lot of libraries for ruby out there, but nothing like CPAN.
Then came along python. Obviously, not in the literal time-oriented sense. I had played with python before, and one thing annoyed the @*#&*% out of me. Python was sensitive to white space. I have not met a whitespace sensitive language since COBOL. It immediately pulled python out of my toolbelt, and I labeled it as a useless language. I mean, if it couldn’t handle white space, how could I trust it to do what I wanted. But, meanwhile, all of my colleagues were ranting off an on about how nice python was.
Then, I needed a new script. I needed to parse out .cab, .zip, and .tgz files, and pull information out of files contained within. I was replacing a shell script, and, I was hoping to do something in ruby that would natively walk around the tgz file. I came up empty. I decided to give python a try, and, it had libraries for everything but cab. (And, a quick cab2zip or cab2tgz script is trivial to call before we work with cabs). The python libraries for zip and tar files were easy to use, and, I’ve noticed that my normal indenting is up to python’s standards, so, my code just works as I intend, even if I “forget” the braces. Pretty cool.
Python’s OO implementation isn’t bad. It’s not just one big ugly hash like perl’s, but, it’s not nearly as nice as Ruby’s. But, the world will go where the world will go, and, python has the libraries (the .zip and .tgz thing is installed in the core — you dont’ even need to download anything), the support, and, is plenty fast for what I’m doing. It looks like perl is now dead to me, and, unless the world decides to all jump in ruby’s camp, ruby is dead too . . .
Oh well, guess I just need to hop onto the bandwagon!
“Long Live Python!”
July 17th, 2010 on 7:03 pm
I know this is an old post but have you taken a look at Moose in Perl? It does a lot to clean up the inconsistent mess that can be Perl’s default OO system. Additionally it brings things that don’t exist in either Ruby or Python (yet) to the table. Things like a system of TypeConstraints, a MetaObject protocol (though Python has some metaprogramming stuff, I’m biased by thinking that Moose’s is better), and an implementation of Smalltalk style Traits called Roles.
If your working under the impression of 10-12 year old Perl OO you really need to see the new stuff.