Perl is dead. Cool story, bro

Perl is dead. Cool story, bro

Perl is a high-level, interpreted, general-purpose programming language developed by Mr Larry Wall. It was written by Mr Larry for himself and his office mates to glue things together while he was working at NASA's Jet Propulsion Labs. The first public release of Perl, version 1.000, was on 18 December 1987. The latest version 5.36 was released on 28th May 2022, after almost 35 years.

It has also given birth to a separate language called Raku in 2019. It was originally intended to be version 6 of Perl, because the attempt to rewrite Perl version 5 resulted in something that wasn't Perl any more. Perl is still under active development. Perl officially refers to Raku as part of the family.

Although Perl is not an acronym, the original man page published in the source code of Perl 1.000 refers to it as 'Practical Extraction and Report Language'. Perl is optimised for many systems management tasks. The language is intended to be practical, easy to use, efficient and complete. The original idea was to automate and script text processing and report generation. Perl has undergone drastic changes and revisions and is now as feature rich as you can imagine.

It is an easy to use and easy to learn programming language. This is why it is widely used by system administrators around the world for small tasks.

The power of Perl is such that it is really the tool for one-liner programs, so short and concise that complex programs can be addressed with minimal coding. This is mostly a good thing, except that it results in code that may look like gibberish to you. This is usually because some internal code written for a specific task that wasn't intended for public release ends up in the public domain, or offered to the new developers who didn't write the code. This particular thing has also been shown to be one of the negatives of Perl. Is it? I mean, technically you can write code that isn't easy to understand in any programming language out there, including Apple's Swift or Python.

Unintelligible can be a lot of things. In my experience, Ruby is much more unintelligible, even though it often looks more like English, because libraries redefine operations and add magic that makes it hard to see what is code and what is data.

Perl is easy to learn and write, and not a bad choice as a first programming language. Apart from community support, you also get CPAN. CPAN is the Comprehensive Perl Archive Network, a large collection of Perl software and documentation.

Perl is dead or irrelevant today. Is it?

So far, things look good for Perl. So what happened? Why is most of the Internet saying that Perl is dead or has no future?

We contacted a number of programmers who used Perl extensively in the 1990s, especially those for whom the code is still available and in use. But according to them, sysadmins (especially those new to the profession) are extremely unlikely to write anything new in Perl.

One such developer said, "I can only speak for the US and especially large companies, but the switch to Python happened pretty much in the 2010s."

If you go through the different editions of the Linux/Unix System Administrator Handbook, it goes from "there's Python, but you need to know Perl" (2002) to "don't write anything in Perl, use Python" (2017).

At the large sysadmin conference LISA, they stopped teaching Perl in 2012.

What I can tell you is that I have not seen a job advertisement for sysadmins requiring Perl in years, except in some rare cases where some maintenance of legacy code was required, and even then it listed Python as preferred.

So what has happened to Perl? Is it because of Perl version 6 and how it was delayed for years?

From a developer's point of view, it wasn't that much of a factor, to be honest. Perl is really interesting in that it is, in a sense, the logical conclusion of the evolution of sed/grep/awk and shell programming.

Python, on the other hand, was designed as a programming language for building larger systems. It has a reasonable object system (although Ruby fans may disagree) and lots of tools and modules.

Python became very popular as a general-purpose programming language, and sysadmins also adopted it.

Another programmer added, "My personal opinion is that Ruby had a real chance to be the successor to Perl, but because it was not really known outside Japan for so long, it just lost its chance. Puppet and Chef are written in Ruby, but otherwise sysadmins don't really interact with it.

Perl also lost some of its appeal when people moved on from CGI scripts for web servers. Perl was really instrumental in that.

I am not a big Python fan, but if you are writing something that needs to be maintained by more than one person and/or is larger than a few hundred lines, Python is simply the better language.

Funnily enough, just last night I wrote some Perl for the first time in decades for a timesheet reporting tool, said a Perl enthusiast.

I don't think anything really "happened" to Perl. It just kind of plateaued and better things came along. There was also a bit of a professional shift (probably related to the DevOps movement), where more people trained as software engineers started doing sysadmin work.

I looked through a standard Linux installation this morning and there are still a bunch of Perl programs around. I can hardly imagine anyone deciding to start a new project in Perl, though.

In the US, Python is the most commonly taught language in introductory college programming classes. This is largely because non-CS students are using it. Python is the most widely used language in data science, for example.

I think it all depends on what your goal is. If you want to get a job, do Python. If you want to learn to write scripts for yourself and experiment with it, it doesn't really matter. Pick the language for which you think you can easily find help if you get stuck.

Is 2023 the end or a new beginning for Perl?

I think there are some interesting things happening in Perl. There is room for improvement and development is actively underway to do this.

One comment from a programmer was interesting, he told us that the script he wrote last night, for example, was more or less in the same style as he would have written it in the 1990s. As soon as he turned on the more modern Perl switches, it didn't even run.

Good thing is there has been some talk about fixing optional behaviour and renaming Perl 5 to Perl 7 to make the defaults more modern, but there is no concrete plan yet. Regardless, it will just be a major version update with more fanfare.

There is one thing about Perl that I really miss in Python. In Perl you can easily do a little one-liner on the command line. This is mainly because Perl was meant to replace AWK for some applications. You can't do that in Python. It's either a script in a file or an interactive Python session.

In AWK, you can easily extract fields from a line like this:
command | awk '/foo/{print $2}/bar/{print $3}'

In Perl you can do the exact same thing like this:
perl -ane 'print $F[1] if(/foo/); print $F[2] if(/bar/);'

You would have to open standard input, loop through it line by line, split the fields, then do the matching and then output. That's maybe ten lines in Python, and because whitespace is syntactically significant, you can't really do that on the command line.

Python has a -c which lets you do short one-liners, but it just wasn't designed with that as a requirement. Python is quite good for medium to large teams working together on a system. It is also fast enough that very large production systems (not just prototypes) are written in Python.

It's like this: If you need to do a quick automated edit of a file, use sed. If you need to filter strings or do a simple report, use AWK. Shell scripts are good for maybe 100 or 200 lines. Perl was specifically designed to do all these things in one language.

Perl actually used to have something like this. It used to come with a2p and s2p to translate your AWK and sed scripts into Perl. This was dropped in 5.22 though.

Python covers most of that, but then goes up to larger systems, which will be difficult to do in Perl, simply because of the language design.

So if Python is already good for large systems, is a more solid programming language, and people with more of a CS background are coming into the sysadmin field (because of DevOps), you end up with more automation written in Python than Perl.

The funny thing is that I'd be willing to bet money that a) there are still some absolutely mission-critical systems that use Perl, and b) those won't go away for another decade or two.

If you ask me to name them. Sorry, I can't. Mainly because they tend to be deep inside large IT organisations.

Exactly why it is so difficult for companies to find people who can maintain COBOL code, for example. There is also a lot of Fortran out there for scientific applications. Yes, there is.

Sooner or later, code written in one programming language will be replaced by another.

COBOL is often written in Java, Fortran is often written in Python. Often, but not always, and not always replaced, just new modules written in the newer languages.

It's not really driven by the features of the language, but more by who companies can hire.

MicroFocus has been making a lot of money for decades with tools for legacy COBOL applications. A programming language that first appeared 64 years ago. Many countries were not even independent at the time.

In some cases it's code translation, in others it's emulation of older systems or rehosting.

That's why I'm always wary of calling a technology "dead".

I don't think Perl is dead. It's been stable for years, and the number of new tools written in it is slowly declining. But as long as there's Perl code in production, it's not dead.

Is Perl fairly structured and easy to maintain?

You can write Perl code that way, yes. But I have also seen code that was very much not, and that is because Perl allows it. Python is quite idiosyncratic in that way, and you tend to run into it less.

The cost of replacing any code in the industry isn't cheap. Estimating the cost of software engineering projects has been a field of academic study for decades, and nobody really knows the answer. "It depends" is pretty much what everyone will tell you.

If you think you don't have to learn new things all the time in IT, you're in the wrong industry.

Perl as a first language

Someone who wants to use it as a starter language should start with the Modern Perl book.

As many experienced Perl programmers will tell you, it is very different from the messy Perl they learned.

It really doesn't matter, there are a zillion options and over-choosing can make it very frustrating to choose anything. But in the time it takes to worry about making the right choice, you could try just about anything. Switching languages is called Tuesday. This means that most programmers will never stick to one language for long. Try everything for a week and see what progress you make.

Also, the language isn't as important as the implementation.

For example, Java as a language isn't any better at cross-platform development than, say, C++. The difference is that the Java compiler compiles to byte code in the JVM. These are features of its implementation, not of the language itself.

Verdict

Perl is not going anywhere. It won't be extinct or dead. Apart from being used to maintain legacy web systems, there is plenty of new work for it, including scripting and day-to-day system administration. Also, there is a decent demand for Perl developers today, there is a listing of Perl jobs that you can get at Perl.org. According to the site, employers include tech giants, hosting providers, universities, banks, etc.

It is included by default in GNU/Linux and MacOS, making it as good a choice as any for scripting to unleash the power of Perl.

Before you start worrying about its death, remember that someone somewhere is already writing a new project in Perl, it could be a new HTML template engine, or a one-off word processing script, or anything else powerful and efficient that the Perl language is known for. Perl lives on.

Read more