Month: January 2008

Frozen Perl hackathon & lightning talks announced

January 11, 2008 Conferences No comments

Frozen Perl, a one-day low-cost Perl workshop in Minneapolis, MN on Saturday, February 16, has just announced its call for lightning talks. They also announced that there will be a hackathon on the 17th.

Register today, because this Saturday, January 12, is the last day to get the early bird rate for non-students of just $20, so you if you’re planning to go, now is a good time to register and pay for your admission.

Which language to inflict on clients?

January 9, 2008 Business, Opinion 2 comments


Originally uploaded by reedwade

Brenda Wallace posted a colleague’s picture of a whiteboard from their office today.
Her post says “dunno which technology to inflict on my clients next, so we had a brainstorm. looks like TCL won.”

The whiteboard reads:

Lisp is bitter
PHP is DancingBear
Python is beige
Erlang is imaginary
Ruby is a fad
Java is angry
Tcl is cute
Perl is ready for retirement

Certainly I don’t think Perl is ready for retirement, but it’s interesting to see what people think about Perl, and about all its brethren.

Strawberry Perl is all-inclusive

January 8, 2008 Perl 5, Windows 1 comment

Yesterday’s article about Strawberry Perl referred to a blog post with incorrect installation instructions. All the downloading and installing discussed is just not necessary, even for CPAN installations. According to Adam Kennedy:

The install and setup process for Strawberry Perl is to uninstall any existing Perl, run the installer, and then run “cpan” or run it from the Start menu. There is no additional installation required.

How to install and set up Strawberry Perl

January 6, 2008 Perl 5, Windows 3 comments

Note: Beware of the instructions in the link below. It has you do far more work than is necessary. See this follow-up article for details.

Here’s the first big blog post I’ve seen about Strawberry Perl: How to install and set up Strawberry Perl

I am writing this article with much joy and glee…. Active State no longer has a monopoly on the issue of Perl on the Windows platform

I haven’t read the Strawberry Perl docs, since I’m Windows-free. The blog post gives details about what tools are necessary to make the install, with links to the tools.
Now, I thought that part of Strawberry Perl was that you wouldn’t need any external tools, but maybe they’re just for building CPAN modules.

Superstition has no place in programming

January 4, 2008 Code craft 3 comments

Working on my Big Dirty PHP Project at work, I’ve found this bit of code in many places.

$categories = "";
$categories = Array();

Why is $categories set to an empty string, and then an array? It’s not necessary to pre-initialize a variable before setting it to another value. So why is the code there? It’s not just one case. It’s throughout the codebase, where I delete the first line whenever I find it.

The original programmer is (thankfully) no longer around to ask, but I’m guessing it’s superstition. Perhaps he had some problem that went away for an unrelated reason when he added the first line of the code. The problem is that he never considered why.

Here’s another coding horror to avoid in Perl. Ever seen a regular expression by someone who wasn’t entirely familiar with regexes and quoted everything whether it needed it or not?

if ( $name =~ /Marcus Holland-Moritz/ )

The hyphen in Marcus‘s name isn’t a metacharacter, but the unsure, superstitious programmer will quote it anyway. “Eh, it doesn’t hurt anything,” he may reply, but it also demonstrates his non-mastery of regexes.

If you ever find a piece of your code where you can’t understand exactly why it works, why every single statement exists, stop and rework it until you do.

LWP::Simple is beautiful code

January 3, 2008 Code craft No comments

Michael Schwern has written a column for Andy Oram’s Beautiful Code blog called LWP::Simple – Simple Goal, Simple Interface. In it, he talks about minimizing the “gulf of execution” with a two-line easy-to-understand Perl program:

use LWP::Simple;
my $page = get("");

Bravo to Schwern to getting the words “Perl” and “beautiful code” together. I can’t wait to see part two.

First what in five years?

January 2, 2008 Community, Perl Foundation 1 comment

The news about Perl 5.10 is everywhere, and it didn’t take that much emailing of news editors on my part. However, I have one regret.

I should have made it more clear in the announcement that Perl 5.10 is the first major change in the Perl language in five years. What I wrote was “Today the Perl Foundation announces the release of Perl 5.10, the first major upgrade to the wildly popular dynamic programming language in over five years.” Unfortunately, that got shortened in headlines to the incorrect
“first release of Perl in five years”, which ignores 5.8.1 through 5.8.8, and has since been spread far and wide.

I’m glad the news is getting out there, but wish it were more accurate.

Why I love say

January 1, 2008 Perl 6 2 comments

Dean Wilson reveals My
Favourite Three Features
in a recent blog post, but doesn’t
discuss my #1 feature of Perl 5.10: The say command.

Why love say so much? It’s just the same as print
with a "n" at the end, right? Yup, but that "n"
causes heartache for me in life. See, I’ve been working on removing
interpolation from my life wherever possible. For instance,
we’ve probably all seen beginners do something like:

some_func( "$str" );

where the quotes around $str are unnecessary. (Yes, I know
there could be overloaded stringification, but I’m ignoring that
possibility here.) That function call should be done as:

some_func( $str );

By the same token, I don’t use double quotes any more than necessary. Rather than creating a string as:

my $x = "Bloofga";

do it as

my $x = 'Bloofga';

It’s not about speedups. It’s about not making the code do anything more than it has to,
so that the next programmer does not have to ask
“why is this work getting done?” If the code doesn’t need the double-quoting, then don’t use the double-quoting.

I started down this road when I read this rule in Perl Best
, but ignored it. “Eh, no biggie,” I thought. Then
I started using Perl::Critic,
and it complained about everywhere I was using double quotes. As
I examined those complaints, I came around to realize that if you’re
having the computer do work, the next programmer has to wonder why.

So now we get the say command, and I get to eliminate at least 50% of my necessary string interpolation. Instead of:

print "Your results are:n";

I can now use:

say 'Your results are:';

So much cleaner. In a color-coding editor like vim, the distinction is even clearer, and as
MJD likes to point out, “It’s easier to see than to think.”

Start using say. Even if you’re not on 5.10 yet, you can use Perl6::Say for most of the places that say works in
5.10. Even better, stop using unnecessary interpolation altogether.