CommuterJoy » Logbook

« logbook home

Posted by mattc at May 15, 08 12:48 PM ... Comments (0)

I think I might learn how to do things in Python, sysadmin tasks, mini web apps and the like.

I've come to know a healthy amount about Perl in the past few years, mainly due to it being the only language officially supported at work, but it has some things I've not really got on with.

It's error handling is a bit rubbish if you are used to the try/catch/throw style of some other languages. Errors in Perl are mostly handled by adding conditionals around (or on the end of) a bunch of statements.

# if there's a problem opening 'foo.txt' then exit with the error
open( file, 'foo.txt'  ) or die $!;

The OO stuff in Perl feels a bit contrived and it's easy to cheat or pick up bad habits. Some of Perl's basic functions remain resolute in their non-OOness...

# adding an item to an array, passing the array as an argument to the push functin
my @foo = ("a", "b", "c");
push(@foo, "d");

The feeling of tacked-on OO also manifests itself in calling a classes methods. You have to remember to pluck the object out from an implied argument before operating on it. Normally you'd expect to be able to use a 'this'-like reference without having to manage this sort of low-level stuff yourself.

# if foo was a method of some class, $class would hold a reference to the calling object.
sub foo{
 my $class = @_;
}

Perhaps the main reason I don't want to keep using Perl is that it hasn't seemed to introduce much of interest to the language over the 4 or 5 years since I've known it. Most other languages I know have had pretty significant upgrades and improvements in that time (XSLT, JavaScript ...). In that time Perl has had a few minor version number patches but I can't see anything to motivate a casual user like myself to upgrade so I just stick with whatever is on the box I'm using.

Maybe Python won't do these things any better, but I won't know until I try.

Updated

I forgot one other thing. Because I don't write Perl every day I find it a real struggle to remember the specifics of the often dense and syntax. For example to get the length of an array you need to remember the $# convention, which you eventually remember after the first few times, but something like '[array].length' would be more obvious. There's lots of little ticks like this $_ (implied variable), $! (error message), @_ (arguments to an subroutine) that you don't use so often as a casual developer and have to scout around to trigger your memory...

# assign the length of array 'foo' to $a
my $a = $#foo;

Comments (0)

Post Your Comments

random bookmark
link summary month October 2009 (1)
September 2009 (14)
August 2009 (16)
July 2009 (21)
June 2009 (24)
May 2009 (16)
April 2009 (2)
March 2009 (22)
February 2009 (11)
January 2009 (11)
December 2008 (9)
November 2008 (16)
October 2008 (18)
September 2008 (11)
August 2008 (12)
July 2008 (20)
June 2008 (15)
May 2008 (27)
April 2008 (9)
March 2008 (10)
February 2008 (8)
January 2008 (8)
December 2007 (12)
November 2007 (10)
October 2007 (10)
September 2007 (6)
August 2007 (13)
July 2007 (8)
June 2007 (10)
May 2007 (12)
April 2007 (5)
March 2007 (12)
February 2007 (13)
January 2007 (22)
December 2006 (21)
November 2006 (28)
August 2006 (1)
category code (15)
food (4)
notes (4)
photo (18)
project (2)
quote (12)
sketch (13)
soup (10)
travel (2)