The Value of Community, or Why I Love Perl
I’ve been asked a number of times recently why I chose to use Perl to develop SAGrader, my company’s flagship essay grading product. I’ll be the first to admit that Perl tends to permit bad (unreadable, unmaintainable, overly terse) code in more ways then, say, Java. I think that those problems are mitigated by keeping to modern best practices in Perl and adhering to a coding standard, but that’s not why I love Perl. I love Perl because of the community.
SAGrader, for example, is only implemented in about 40,000 lines of code, split between actual application code, unit and acceptance tests, and HTML templates. That’s all! But if you ruthlessly reuse code from CPAN, the hub of the Perl community, you can implement computationally intelligent essay grading, a complete website to handle thousands of students, and everything else that goes on behind the scenes to make a website like SAGrader work in very little code and time. While SAGrader may only be 40,000 lines of code, we reuse almost a million lines of Perl from CPAN.
The downside of this much code reuse is that it increases the resident size of your program in memory. Frankly, memory is cheap, and programmer time, effort, and happiness is not. Perl might not be the best tool for every job, but for this job, it’s saved us (without exaggerating) man-years of time and effort.
Using next_successor with Graph::Traversal
I recently needed to do a graph traversal using the excellent perl Graph library, but I needed to determine the order for visiting new nodes in the fringe myself. Graph::Traversal provides a next_successor attribute which takes a code ref so that you can specify this behavior yourself. Unfortunately, in version 0.80 that feature isn’t well documented, and if you try to use it, you get an “unknown attribute” error. I’ve submitted a patch to enable, document, and test the feature. Now, if you want (for example) to do a breadth-first traversal, but visit the nodes in reverse alphabetical order, you can do this:
Graph::Traversal::BFS->new(
first_root => 'a',
pre => sub { print $_[0]; }
next_successor => sub { (reverse sort keys %{$_[1]})[0]; },
)->bfs;
My first CPAN acknowledgement
It’s a small thing, but I’m listed in the acknowledgements for Test::Class, an excellent little xUnit-with-a-decisively-perl-twist module that we use at work. A star is born?


