Last night I was speaking at the Milton Keynes Perl Mongers technical meeting. I gave a new talk about how Moose (and, in particular, Moose traits) make Perlanet easier to maintain and enhance. The slides are available on Slideshare.
We hear a lot of people complaining that programming in Perl is too difficult, but I think that a lot of these problems stem from people making the opposite assumption – that writing Perl is easier than it actually is. Let me share a couple of examples. I’ve lightly disguised the companies in question – so if you think you recognise a place where we’ve worked together you’re probably wrong.
In the first, I’m working for a global organisation. Most of their bespoke software is written in Java, but (like pretty much every company) there are a few Perl programs running vital parts of the infrastructure. This company have also outsourced a lot of their maintenance work to another company in India. This Indian company has dozens of people who are dedicated to working on my client’s systems. But they are Java programmers and every once in while they need to do some work on a Perl program.
This company has an internal IRC network and there’s a Perl channel which I keep half an eye on whilst getting on with my work (which is maintaining a huge Perl program). A few times a day one of these Java programmers turns up on the Perl channel explaining a problem they have to solve in a Perl program and asking for help. In pretty much every case, the problem boils down to the Java programmer having major misconceptions about how Perl works. Perl programmers on the channel try their hardest to to help, but it’s often a frustrating experience. Usually the correct answer is “go away and read Learning Perl and Intermediate Perl, then you will understand how the code works”. But these programmers don’t have the time to do that. They need this task finished in an hour. Often it’s a task that could be easily achieved in an hour – but only after you’ve done the groundwork of understanding how Perl works.
The problem this company had was that Perl wasn’t seen as being as important as it actually was. People in the Indian company saw it as a “scripting language” that any of their (no doubt highly qualified) Java programmers would be able to use without any preparation or training. That’s clearly not the case.
But, I hear you say, that’s not fair. Perl and Java are really different languages. I’m glad you pointed that out as it’s a nice link to my second example.
In this example, I’m working for a dotcom company London. Like so many dotcom companies they have a Perl codebase that was thrown together five years ago in a couple of months by people who didn’t really know what they were doing. This company has the added problem that they are finding it hard to recruit people with Perl experience. So they start recruiting people with experience of languages like Python and Ruby in the belief that these languages are so similar that the programming skills are completely interchangeable.
And, of course, Perl, Ruby and Python are all a lot closer to each other than they are to languages like Java. But there are differences. Important differences that aren’t just syntactic. I can read Python and Ruby just fine. But if I got a job where I had to write a lot of either of those languages, I wouldn’t assume that I could just pick it up by osmosis, I’d get a book and read about the language. If I was going permanent at the company, I might even suggest that they send me on a training course.
Conversations with these non-Perl programmers often took a predictable course. They’d start complaining that the code was hard to read. This was hard to counter as a lot of the code was horrible. But if you pointed out some of the newer and better code, they wouldn’t see the improvement. They would insist that somehow Ruby or Python code was inherently easier to read than Perl code. I’d try to point out that Perl programmers find Perl code as easy to read as Python (or Ruby) programmers find Python (or Ruby).
So there seems to be this perception that Perl should be as easy to read as Random Programmer’s favourite language. And I don’t understand why that is. Just because I’ve been programming for almost thirty years, I don’t expect to be able to program in any language I happen to look at – well, certainly not well enough to be paid for doing it.
I’m not sure what we can do to counter this misconception. I think it probably stems from the late 90s when everyone was writing Perl. And if everyone is doing something, then it must be really easy.Of course, most people were writing really horrible Perl because Perl isn’t as easy as they thought it was.
Not sure it’s possible to sum this up in a simple marketing slogan. “Perl is Easy (but not as easy as you think)”.
Sometimes people ask me why Perl marketing is so important. This morning I came across an excellent example of the kind of thing that we’re trying to counter.
In the current issue of Linux Format, there’s an article about building a Twitter client in the bash shell. It’s written by Nick Veitch – who seems to dislike Perl a bit. In the article he wants to URL encode a string and can’t find an easy way to do it in bash. He writes:
However, the compromise I’ve found for this isn’t too bad (props to http://stakface.com/nuggets). It uses Perl and, like everything in that language, it looks like you ought to sacrifice a goat or something before you run it.
perl -p -e 's/([^A-Za-z0-9.-~])/sprintf("%%%02X", ord($1))/seg'
It’s not clear to me which part of the Perl make him want to start sacrificing goats. Is it the s/// syntax that Perl borrowed from sed? Perhaps it’s the regular expression syntax that Perl shares with pretty much any language with regex support. Or maybe it’s the sprintf function that Perl borrowed from C and that many other languages (including bash) support with a pretty similar syntax.
Of course I’m not saying that Perl doesn’t have some grungy corners in its syntax. But the three pieces of syntax used in this code fragment look to me like things that should be understood easily by just about anyone with experience of programming in the Unix environment.
And if this code is so hard to understand, why use it? I don’t know what Nick’s programming language of choice is, but couldn’t you do exactly the same thing in Python, Ruby or PHP? I can’t believe that Perl is the only language that is so powerful. And I’d be very surprised if the same code didn’t look very similar in many other languages.
So why the unnecessary little dig at Perl?
Of course, it’s clear that Perl isn’t a language that Nick is particularly familiar with (neither, indeed, is the person who he took the solution from). Anyone who knew Perl would realise that Perl’s standard distribution includes the CGI module which contains an escape function which does exactly what Nick wanted – without exposing the programmer to all of that scary syntax. I would write Nick’s code something like this:
perl -MCGI=escape -e'print escape "@ARGV"'
There are a lot of people out there with really strange ideas about Perl. People who don’t bother to find out the best ways to do things in Perl. And having widely-read Linux magazines printing snide comments about Perl does no-one any good at all.
This is why I think that Perl marketing is important. We need to reach the people outside of the echo chamber and tell them that Perl isn’t the outdated, hard-to-use language that they are being told that it is.
Update: I should have pointed out that I’ve sent an abbreviated version of this to Linux Format. Hopefully it’ll be published in the next issue. And I’m considering proposing a series of articles on Perl to them.
Those of you who have been following my work for some time might remember that many years ago I took some interest in Perl books. I don’t mean the kind of books that we all read (or, even write) with animals on the cover. I mean the kinds of terrible Perl books that at one stage seemed to take up over 90% of the space given over to Perl books in most bookshops. They had brightly coloured covers and made unlikely claims about how good you would be with Perl after an unfeasibly short period of time.
They all seemed to be written by people who didn’t actually know anything about Perl and they were full of the most atrocious Perl code that I’ve ever seen. Of course they were all not just about Perl but were about CGI programming with Perl (as that’s what everyone wanted to use Perl for ten years ago). It was easy to tell the quality of these books from the index. You just looked for mentions of “use strict”, “use warnings” or CGI.pm. Most books ignored them completely. At the time Schwern had a “litmus test” for the quality of Perl books. It was list of bullet points that you could use to easily calculate how bad a Perl book was. I seems to have dropped off the internet at some point in the last ten years.
Last weekend I was in the centre of London and I went into a couple of large book shops that I haven’t been to for some time. And it looks to me as though this problem has finally gone away. Looking at the Perl section in Foyles, for example, I saw a very few dodgy Perl books. Of course, there were far fewer Perl books of any quality than there would have been five or six years ago, but the ones that were left were pretty much all decent books.
My initial thought was that this was just another sign that Perl has lost the battle for the low-end web development market. People who want to hack up a web site no longer even consider using CGI programs written in Perl. These days those people would all use PHP. But it seemed to me that there weren’t many “Learn PHP in 24 Hours” books on the shelves either. So perhaps the low-end web development market doesn’t exist any more. Or, at least, perhaps it’s not big enough to make it profitable enough for publishers.
I’ll admit that my sample wasn’t particularly big. And Foyles isn’t exactly your average book shop. It caters for the higher end of the book-buying market. I wanted to test my hypothesis by looking at the computer books section in Borders over the road. But Borders has closed down. Another indication of the diminishing size of the book market.
I’m going to take this investigation further. I’ll check out the computer section in some lower-end book shops. But just to give myself some closure I’m going to declare my campaign against bad Perl books to be over. We won in the end. But it may be a slightly Pyrrhic victory.
Last August, when I was writing my talk Proud to Use Perl for YAPC::Europe, I wanted to get a feel for what real people were actually saying about Perl. It’s all very well claiming that people say Perl is dead, but I wanted to get some real quotations to use in the talk. I came up with the idea of using Twitter. I set up a Twitter search feed for tweets containing the word “perl” and monitored that for a couple of days. I quickly got all of the quotations that I needed.
But I found the feed fascinating, so I continued to read it. Sometimes the Perl community can be a little insular, so it was interesting to read what other people were saying about Perl. I still read the feed today.
Over the year, the feed definitely feels like it’s getting bigger. I mean, there are more mentions of Perl. I don’t have any concreate figures because I read the feed at random times of the day and sometimes don’t touch it for a couple of days. It’s tempting to think that more talk about Perl is due to things like the Ironman initiative, but we shouldn’t jump to that conclusion. Firstly, more talk about Perl could just mean more people saying that Perl is dead (I don’t think this is the case) but secondly more talk about Perl could just be indicative of more talk on Twitter in general. Certainly the number of users on Twitter is still grwoing quickly, so that could probably explain the growth in Perl talk.
But over the last week or so, I’ve gradually realised that a lot of the increase in tweets mentioning Perl is due to the increase in spam (or, at least, spam-like) tweets mentioning Perl. I see a huge number of posts from accounts like @e_host which do nothing but advertise web hosting companies. I suppose we should take it as a positive sign that they think Perl is a feature worth mentioning in these adverts. There’s also been an increase it tweets that are reposts from hire-a-freelancer sites. For example, this morning I saw dozens of copies of this “Need Perl Expert” post.
I’m seriously considering dropping the Perl Twitter feed from Google Reader. It’s just becoming such a slog to go through it. I estimate that about a third of it it currently interesting – and that signal to noise ratio is only going to fall.
I do think, however, that it would be useful and interesting (and pretty easy) to set up an application which monitors the feed and records the data. If we just counted the number of posts, that would be interesting. We could even consider pushing the text through some kind of analysis to pull broad types of information from it (“is this a positive or negative mention of Perl?”). The sooner we start, the more data we’ll have to play with.
I think I’ll set something up tomorrow.
Over the last few days I’ve seen a large number of tweets saying that the Perl module Net::Twitter is being used to post pro-government propaganda from Iran. If it’s true, this is almost certainly a reaction to the large number of people who are using Twitter to get around the Iranian government’s censorship.
It’s disappointing, of course, to see Perl being used as an instrument of propaganda and repression. But that’s one of the dangers you have to face when you release software under an open source licence. I only hope that people realise that Perl is a tool that can be used by anyone and that we don’t run the risk of being linked to Ahmadinejad’s regime just because of the programming language we use.
iransource seems to be one of the pro-Ahmadinejad bots, but it’s been quiet for a couple of days. Has anyone been tracking these bots? And is there any previous evidence of Perl being using by repressive regimes?
One of the nice things about moving away from use.perl to your own site is that you can install whatever toys you want.
I’ll eventually get round to posting code on this blog. And when I do it would be nice if it had some nice syntax highlighting. I could, of course, write my own syntax higlighter (probably based on something like PPI:HTML) but that sounds far too much like hard work, so a couple of days ago I decided to poke around to see what prior art was out there.
Initially, it looked like I was in luck. In the Movable Type plugins directory I found a link to SyntaxHighlighter for Movable Type, which is an MT wrapper around SyntaxHighlighter 2.0. The example output looked rather nice.
I downloaded it and installed it. And then I prodded at it for an hour or so. But all to no avail. It didn’t seem to work as advertised (or, indeed, at all). I fixed one obvious bug in the Perl support but it didn’t seem to help. I hope that the problem is just that Perl support hasn’t had as much testing as other languages. There’s no obvious route for support, so I’ve left a message for the author on his blog. Hopefully he’ll get back to me and we can get this ironed out.
But, all in all, it looks like I’m not going to be able to be as lazy I’d like to be.
Unless, dear readers, you know better. Do you know of a syntax highlighting plugin for Movable Type? Have you patched this one to work? Is there an alternative solution that I’m missing completely?
 Which is only to be expected as Perl is, as I’m sure you realise, a dead language
Here’s my new Perl programming blog. I have another blog where I talk about a number of different things, but I like to keep my Perl writing separate from the rest of it.. Until recently I kept a Perl journal over at use.perl, but the technology behind that site is looking pretty dated so I thought it was worth striking out on my own. So here I am at PerlHacks.com.
It might be interesting to explain how I came to own such a cool domain. It’s a story that has some useful lessons about the kinds of scams that people try to pull on the internet.
It managed to get perlhacks.org in 2005, just because no-one else had thought to buy it. But someone already had the .com and, even though they weren’t using it for anything, I suspected that they’d want a lot of money to part with it, so I didn’t even bother contacting them.
Then in September of last year I got an email from someone offering to sell me the domain. They contacted me as I owned the .org and they assumed that I’l like the .com to go with it. They wanted just under $1000 for it, so I ignored them. Over the following few weeks I got three or four more increasingly desperate emails from them. All of which I also ignored.
At the end of October I got a different mail. In this one they dropped the asking price to $99. That was closer to the price that I wanted to pay, so I investigated further. I mentioned the mail on the london.pm IRC channel and someone pointed out that the domain had, in fact, lapsed and was available for anyone to buy.
There was a brief race as three members of the channel tried to register the domain at the same time, but it was a race that I won. I got the domain for less than £10. I took great pleasure in pointing out that fact to the people who were trying to sell it to me for $99. They never replied.
The lesson is, of course, to always check whether you can buy something cheaper than the price it’s offered at.
So there I was with both perlhack.org and perlhacks.com. And now they both point to me Perl blog.
Now I just need to think of something to write about.