Tag Archives: perl

Why Corporates Hate Perl

This is a reprint of an old blog post.

A few years ago I was writing blog posts (semi-)regularly for O’Reilly. This is the one that probably got the most feedback. I’m reprinting it now because a) it’s pretty hard to find on the O’Reilly site and b) it’s relevant to a couple of conversations that I’ve had over the last few days.

Last week I was in Copenhagen for YAPC::Europe. One of the announcements at the conference was the location of next year’s conference which will be in Lisbon. The theme of next year’s conference will be “Corporate Perl”. And that (along with a couple of conversations last night) got me thinking about a talk that I’ll submit to next year’s conference which might well be entitled “Why Corporates Hate Perl”.

It’s not true, of course. There are a still large number of large companies who love Perl. I could probably work through to my retirement enhancing and extending systems that are written in Perl at many of the big banks in the City of London. There are, however, also many companies who are moving away from Perl for a number of reasons. Here’s one of the reasons that will be included in my talk.

I was talking to people from one such company last night. The Powers That Be at this company have announced that Perl is no longer their language of choice for web systems and that over time (probably a lot of time) systems will be rewritten in a combination of Java and PHP. Management have started to refer to Perl-based systems as “legacy” and to generally disparage it. This attitude has seeped through to non-technical business users who have started to worry if developers mention a system that is written in Perl. Business users, of course, don’t want nasty old, broken Perl code. They want the shiny new technologies.

And so, in a matter of months, the technical managers at this company have created a business environment where Perl is seen as the cause of most of the problems with the current systems. It’s an impressive piece of social engineering.

It’s also, of course, completely unfair. I don’t deny at all that this company (like many others) has a large amount of badly written and hard to maintain Perl code. But I maintain that this isn’t directly due to the code being written in Perl. It’s because the Perl code has developed piecemeal over the last ten or so years in an environment where there was no design authority which encouraged developers to think beyond getting their immediate task done. Many of these systems date back to this company’s first steps onto the internet and were made by separate departments who had no interaction with each other. It’s not really a surprise that the systems don’t interact well and a lot of the code is hard to maintain.

There are, on the other hand, a number of newer systems which are also written in Perl which follow current best practices in Perl development and are far easier to to maintain and enhance – as easy, I would contend, as anything written in the new approved languages.

It’s certainly true that this company has a large number of systems that need to be rewritten over the next few years. But throwing away all of the company’s accumulated Perl expertise and moving to new languages seems to be a step too far. Management are blaming Perl for the problems when really they should be blaming the management and design procedures that were in place (or, more likely, weren’t in place) when the code was originally written.

Many organisations are in the same situation, with large amounts of unwieldy Perl code. Ten or twelve years ago everyone was writing web systems in Perl and we were all making mistakes. We all have to deal with those mistakes but we’ve  hopefully, learned from them and can rewrite our systems to take account of everything that we’ve learned in the last ten years.

It’s too late for the company I’ve been talking about in this article. The anti-Perl social engineering has probably insinuated itself too deeply into the culture. It’s unlikely that Perl’s reputation can be rescued.

But if you have similar problems in your own company, then please try to ensure that blame is apportioned correctly and that you don’t use Perl as a scapegoat.

A couple of updates to the post. I did propose the talk to the next YAPC, but the proposal wasn’t accepted. And the company I talk about in the article is still employing a lot of Perl programmers – four years after this post was written.


A Cautionary Tale

I can never remember exactly how Time::Piece works. But that’s ok because I have documentation.

$ perldoc Time::Piece
No documentation found for "Time::Piece".


$perl -v
This is perl 5, version 14, subversion 2 (v5.14.2) built for x86_64-linux-thread-multi

$ corelist Time::Piece
Time::Piece was first released with perl v5.9.5

$ perl -MTime::Piece -E'say $Time::Piece::VERSION'
Can't locate Time/Piece.pm in @INC (@INC contains: /usr/local/lib64/perl5 /usr/local/share/perl5 /usr/lib64/perl5/vendor_perl /usr/share/perl5/vendor_perl /usr/lib64/perl5 /usr/share/perl5 .).
BEGIN failed--compilation aborted.

So Time::Piece has been in the Perl core since 5.9.5. I’m running Perl 5.14.2 but I don’t have Time::Piece installed.

After ten minutes or so of head-scratching it came to me.

$ sudo yum install perl-core
Loaded plugins: langpacks, local, presto, refresh-packagekit
[ stuff snipped ]
---> Package perl-Time-Piece.x86_64 0:1.20.1-212.fc17 will be installed
[ more stuff snipped]

I’m running Fedora. The Fedora packagers have decided that they don’t need to install the whole standard Perl distribution as part of their standard installation. I don’t have a problem with that. I do have a problem with their naming conventions.

The minimal Perl installation that they include by default is in an RPM called “perl”. The full RPM that includes everything that a Perl developer would expect to see is called “perl-core”. Surely it’s obvious that those names are the wrong way round?

Isn’t there some way that the Perl 5 Porters can object to  this renaming of Perl?

I know I should be installing my own Perl with perlbrew. But I generally find that the system Perl works for everything that I need. There’s just this one thing that is guaranteed to trip me up every time I work on a new Fedora installation.

This is a public service blog post. Perhaps someone will come across it and be saved a couple of hours of confusion.

CGI.pm vs Templates

I’ve just been involved in a discussion on LinkedIn that I thought deserved a wider audience (I have no idea how well that link works if you’re not a member or or logged in to LinkedIn).

A couple of days ago, someone asked for advice on the best way to include HTML in a Perl program. They got a lot of good advice (basically – don’t do that, use a templating system instead). And then this morning, someone came in and said:

use CGI module, u don’t need to write a single HTML tag..just use CGI Methods…

I did a bit of a double take at that point. I thought we’d all stopped using CGI.pm’s HTML generation methods back in the last millennium. I replied saying that, but this chap was adamant that CGI.pm worked for him. He asked me to explain why I was so against his approach.

This was my reply:

I never said that it didn’t work. I just think that it’s a really limited way to build things and you’d be better off taking a more flexible approach right from the start.

My main objection is the separation of concerns. The logic of your application is separate to the display layer. It’s quite possible that the display of the application will need to change in the future. And that all becomes easier if the HTML is stored separately from code.

This leads to other problems too:

As I hinted at above, CGI.pm only has pretty basic support for HTML. It’s really hard to create a great-looking web application using CGI.pm. In fact, I wouldn’t be surprised if CGI.pm was largely responsible for the terrible web sites that the Perl community has been building for itself for most of the last twenty years.

Your project might well have HTML experts who know how to create good looking web pages. Expecting them to do it by editing Perl code is a bad idea. Front end developers need to know HTML, CSS and Javascript. Why force them to understand Perl as well?

Even if you’re the only developer on a project (as I often am for my personal projects) there are advantages to separating your work into “front-end task” and “back-end tasks”. I find it really helps me switch my mindset to the appropriate skills if I switch from editing a Perl source file to editing an HTML template.

It makes your Perl code more complicated than it needs to be. Seriously, try moving the HTML out of the code and into a template. See how much simpler your code becomes.

It’s unlikely that your CGI-generated pages will make up all of the web site. There will almost certainly be static pages too. If you use a tool like the Template Toolkit then you can generate static pages from the same set of templates that your CGI programs use. That way it’s easier to maintain a consistent look and feel across all of the pages on the site.

I’m not saying “don’t use CGI.pm” (well, I am a bit – but that’s a different story). The CGI bits of CGI.pm (for example the bits that give you access to the incoming parameters or let you set the outgoing headers) are great. It’s just the HTML generation stuff that I strongly recommend that you don’t use.

I’ve just remembered an article that I wrote in 2001 that might also help. The first half is about cookies, but the second half demonstrates using Templates instead of the HTML generation methods. I hope it shows how much simpler it makes things

See http://mag-sol.com/articles/cgi3.html

Does that help at all?

I think that pretty much sums up my objections. Did I miss anything obvious? Or am I completely wrong and many of you are still using the HTML generation methods in CGI.pm to do this?

The Perl community on LinkedIn is a fascinating place. I should really write a blog post about it.

What is Modern Perl?

I wrote an article for Josette called “What is Modern Perl?” In it, I talk about the different things that people might mean when they talk about Modern Perl and why it’s well worth buying a copy of the new edition of the camel book.

After a gap of twelve years, a new edition of Programming Perl (affectionately known as “the Camel book” to its many fans) was published earlier this year. That came as quite a surprise to many people who had given up on seeing a new edition.  What has changed in the new edition? Does the book now cover Modern Perl? The answer depends on what you mean by the term “Modern Perl”.

Of course it’s not a complete coincidence that the subject ties in nicely with my forthcoming Modern Perl for Non-Perl Programmers course.

Update: There’s a discussion of the article on Hacker News. It seems to be taking a predictable path.

Modern Perl for Non-Perl Programmers (Redux)

Six weeks ago I announced that I’d be running a free one-day course called “Modern Perl for Non-Perl Programmers” in August. Places on that course were fully booked in less than a day.

So I’ve decided to run to course again, two months later. It will still be at Google Campus, and the date is Saturday 6th October.

The original course was free, but I can’t afford to do that on a regular basis. I hope you’ll agree that £30 is still a bargain for a day of training.

As last time, most readers of this blog probably aren’t in the target audience for this course[1], but you might know people who would be interested in the course. Please pass on the link.

You can buy a ticket using at perlschool2.eventbrite.co.uk.

Eventbrite - Perl School: Modern Perl for Non-Perl Programmers

[1] Programmers of other languages who want to learn Perl.

Perl Teach-In 2012

Back in 2007 the London Perl Mongers ran a free one-day Perl training course at the BBC’s offices in White City. That was five years ago, so for a couple of months I’ve been thinking that it was probably about time that we did another one.

And then suddenly this afternoon a few loose ends came together and all of a sudden it’s been organised.

The course will be on Saturday 4th August at Google Campus in London. It will run from 9am to 5pm. As last time, it will be completely free to attendees.

Last time the course was aimed at intermediate Perl programmers and introduced them to advanced Perl techniques. This time I’m aiming at the opposite of the spectrum. The course is called “Modern Perl for Non-Perl Programmers”. It’s aimed at people who are comfortable programming in languages other than Perl and who are interested in getting up to speed in Perl as quickly as possible.

Obviously most of the readers of this blog won’t be in the target audience for the course, but I’m betting that you all know at least one person who might be interested in the course. So it would be great if you could send the link to the registration page to anyone who you think would find the course useful.

The link is: perltraining.eventbrite.co.uk

Eventbrite - Modern Perl for Non-Perl Programmers

Update: All of the places on this course were booked in about 20 hours. In 2007, a similarly sized free course was all booked up in about two days. I guess it’s true that Perl is dying :-)

Free Training Competition in Linux Format

I’ve mentioned before that I’m running some public training courses in London next month. But how do you fancy coming along to those courses for free?

Those lovely people at O’Reilly have put an advert for the courses in the new issue of Linux Format which hits the shops about now. That’s issue 154 and the advert is on page 54. The advert contains details of a competition where two people can win free places on the two courses – one person on each course.

There are also four runner-up prizes which are copies of the new edition of the Camel book.

All you need to do is… well to find that out you’ll need to buy the magazine. Ok, so entry isn’t 100% free – you’ll need to pay £6.49 for the magazine.

Perl Tutorial

Google Reader just showed me Mithaldu’s blog post about the falling level of Google searches for the term “perl tutorial“. The fall is, of course, more than a little worrying and we should do what we can to get more people searching for Perl. But I wondered what results Google is currently returning for this search. It’s not a pretty sight.

  • The first two results are for Nik Silver’s Perl tutorial from about twenty years ago. I know Nik and I know that he would be horrified to think that people were trying to learn Perl from this site. Nik has been responsible and left a clear notice at the top of the page stating how out of date it is and I understand him wanting to leave the page there for historical interest. But I still see questions on places like Stack Overflow from people who are obviously using this tutorial.
  • The next link is to a site at perltutorial.org. That sounds encouraging, but it’s a rather pedestrian affair teaching dated and simplistic Perl and written by someone whose first language clearly isn’t English.
  • The next result is to tiztag.com. It’s about as good as you’d expect from a site that insists on calling the language “PERL”.
  • Next, we finally get to something worth using. It’s a link to the free online version of Simon Cozens’ book Beginning Perl. That’s good – but it’s still a little dated.
  • Next we get to Robert’s Perl Tutorial. Which proudly boasts it was last updated on 20th April 1999. That’ll be up to date then.
  • The next result is BradleyKuhn’s book Picking Up Perl. This was an attempt to produce an open source Perl tutorial book. It was a worthwhile project, but it was last updated in 2002.
  • The next result is one that finally links to perl.com. It’s an article by Doug Sheppard called Beginner’s Introduction to Perl. I bet it was great when it was first published in October 2000.
  • Towards the bottom of the list there are two links to Gabor’s recent (current?) Perl tutorial series. These are probably the only links on the list that we should be sharing with people wanting to learn Perl.
  • Finally, there’s the NCSA Perl Tutorial. At least this page has realised that it is out of date and has closed down. Unfortunately the alternative sites that it suggests are of variable quality.

So there it is. The first page of results is of rather variable quality. There’s some great stuff there, some good but dated stuff and some dreadful stuff. But I’m sure there are better Perl tutorials out there. It would be great if the first link returned by Google was to learn.perl.org. But what other sites should be on the list? What good Perl tutorial resources do you know of?

Have I just given all those dreadful sites a healthy boost of Googlejuice by linking to them?

Perl Search Engine

Often on sites like StackOverflow you’ll see questions that people could have answered for themselves if they had just searched the right web sites (usually perldoc or CPAN). But instead, they just went straight for Google and ended up with some dodgy, out of date information that just left them confused.

In order to get round that, I’ve created a Google Custom Search Engine which searches known Perl web sites. You can try it out here.

If you want to use this search engine on your site, the code is below.

<div id="cse" style="width: 100%;">Loading</div>
 <script src="//www.google.co.uk/jsapi" type="text/javascript"></script>
 <script type="text/javascript">
 google.load('search', '1', {language : 'en'});
 google.setOnLoadCallback(function() {
 var customSearchControl = new google.search.CustomSearchControl('008350714774536055976:a2zesuxuecs');
 }, true);
 <link rel="stylesheet" href="//www.google.com/cse/style/look/default.css" type="text/css" />

YAPC::Europe Preview

Earlier this year I met Josette Garcia at OpenTech and she told me about her new blog Josetteorama. She asked me if I’d like to contribute a few articles about Perl to the site. I agreed and then promptly forgot about it for a couple of months.

But I remembered my promise a week or so ago and realised that this would be a great opportunity to promote YAPC::Europe outside of the Perl community.

So I wrote an article called YAPC::Europe Preview. And she published it today. Hope you find it interesting.