February 09, 2005

Alan Kay Interview

I haven't posted here in ages, but I just read an interview on the ACM website with Alan Kay that seemed too good to pass up posting.

I think it's interesting to see his perspective looking back at computing and see how he thinks that while things have changed, they haven't necessarily gotten better.

I still find it ironic when I realize that languages I'm only hearing about now, like ML have roots that go all the way back to the 60's or 70's. I also think it's interesting how we keep reinventing languages, but without keeping the benefits of the prior work.

Posted by rob at 10:14 AM | Comments (2)

October 18, 2004

The Pain of Object-Oriented Perl

I like Perl. I've used it since sometime in the late 80's. I don't use it everyday, but I use it when I want to munge some text in one way or another.

I recently wanted to generate some RSS feeds for a few websites that didn't provide their own feeds. That meant HTML parsing and RSS (XML generation) which sounded like a job for Perl. I actually considered Ruby and Python, but in both cases I found it difficult to do searches for modules that would do friendly HTML parsing and RSS generation.

So into the land of Perl I went armed with my O'Reilly books.

Having learned Perl in the Old Days before it was objectified, I still have a hard time when I try and use OO-Perl. This project was no different. In fact, I got extremely frustrated.

I had created a class using the Class::Struct package. This is a fairly neat little package that creates setters and getters for you. All you do is define the names of your ivars and their types (scalar, array, class, etc...)

The first bit of ugliness I ran into was when I wanted to create access my ivars. I had an ivar named 'classes' which was an array. An obvious first guess at how to do this would be:

$self->classes

but that would be wrong. Instead you need:
$self->{'classes'}

And, if that's not bad enough, if you actually want to use that expression somewhere in an array context, you need to explicitly state the context by doing this:
push(@{$self->{'classes'}, $foo);

Ugh. The pain. The pain.

I actually got used to (but not happily) the funky ivar access syntax, but I was constantly bitten by my failure to specify the array context syntax.

I did manage to get my projects finished. But, I'm just not happy about doing OO programming in Perl. It still feels clunky and leaves me too many places to do the wrong thing.

Posted by rob at 10:43 PM | Comments (0)