Sunday, August 21, 2005

Why I Like Perl

Perl is a fairly recent addition to my knowledge. I needed a program that would generate a random string given a regular expression. I found only one solution that was good enough for me. It was a module for Perl. Since I actually needed the code, I opened a book nearby (which happened to be Learning Perl by Randall Schwartz and Tom Phoenix). I skimmed through it and through the man pages of the module and in about 1 hour I wrote the thing that I needed. So I thought it was quite OK as a programming language.

I already knew Python fairly well, and I had nothing better to learn (actually I had, but I didn't like that other option very much). So I said... what the heck? At any rate, since a lot of people are using it, it should be at least doing something right. Of course, if a language is not used by a lot of people, that doesn't mean it is a bad language, but that is a different story.

So I finished reading Learning Perl (properly this time and doing the exercises) and I started reading Programming Perl by Larry Wall.

The book was too much. I am not able to remember even half of it. However, I liked Perl because it was fun. Unlike Python, I was able to code anyway I liked it. Writing Perl code is almost similar to cartooning. Or doing something similar. At any rate, small projects were very easy to get done. It was also pretty cool because it looked like a spoken language (Of course, I am forgetting the $,@,% here ;)). I was usually able to write a statement any way you like. Another thing that I liked was those default variables. I liked them because they make the code shorter.

However, I really didn't like the way the code was looking when it got big. As the code grows, it seems harder to mantain.

So where am I now? Well, somewhere in the middle. Lately I have been using Python a lot more again. However, I still use Perl as a glue language (which was designed to be in the first place). The irony here is that even though Perl is bigger than Python, I really think that it is better suited for smaller projects than Python.

On a larger scale, I think however that even Python breaks, and you probably are forced to use a stronger language (C++ for example). I haven't got to work in projects of such magnitude yet. After talking to andrei (he posted here in response to one of my previous posts), I generally think that languages like C++ and Java are a lot more used than they should be.

At any rate, if anyone out there cares to learn Perl, you might as well give it a try. Some things are done easier using it. Also, as Musashi once said, "do not have just one school". As a result, I do not care a lot about the philosophy (TIMTOWTDI or the Pythonic way)... I just take a problem, and solve it (and in the meantime I try the easiest way to do it).

Keep your mind flexible. And if you are used to Python, Perl might just make it flexible enough.

Let's limbo :D

0 Comments:

Post a Comment

<< Home