Why would you use Perl in 2024?

The rise and fall of the popularity of programming languages is fun to watch.

### Quick disclaimer: I’m not a programmer. I’ve never held a programming job. I have been interested in programming as a hobby for several decades, and have written shell scripts as a part of my job in a previous life.

I still remember when C++ was the hot thing*, then Java (for far too long, haha), then perhaps Ruby, Python, and various and sundry JavaScript abominations. Now Rust seems to have most people’s attention and admiration. (I have no opinions of particular substance on that language. I can, however, provide many opinions of lesser substance upon request 😄)

I don’t think Perl was ever the hot language, but it gained a lot of popularity in the 90s as a great glue language and cgi language for websites. It was gradually overshadowed by PHP and other languages in the mid-naughties.

So, why should someone still use it?

Looking at my ~/bin/ directory, I have:

One of the Perl scripts wasn’t written by me (the venerable scrmable.pl[a] by jwz), two of them are trivial (and I don’t recall ever using them), and one of them is a 25-line hack to add thousands separators to file sizes in the output of ls -l.

[a]

Hmm, my Perl advocacy career isn’t looking particularly brilliant.

Nevertheless, I did write a fair bit of Perl as my second-tier language (after ksh) when I worked in I.T.

The advantages it offered over regular shell scripting were:

I still consider myself a Perl noob after all these years, and in truth, I don’t think I’ve written more than a dozen Perl scripts in the last decade. Still, it’s a language I remember fondly for its power and elegance.

I can already hear programmers complaining and kvetching about Perl. Please understand, I’m coming at this as a scripter, not a programmer. What I do is best described (in homage to that great 70s/80s dramedy, M.A.S.H.) as “meatball programming.” I wouldn’t know a functional language if it bit me in the… Noctua fan. I haven’t even ever properly learned OOP!

I think people using another serious languages like Ruby, Rust, Python, or Nim have their reasons to stay away from Perl, and I won’t tackle arguments I’m not equipped to take on. Besides, we all have very different use cases, preferences, and styles.

But for the fellow scripter, someone who likes banging out bespoke shell scripts here and there, Perl has a lot to offer, and as I recall, the learning curve is not bad for someone coming from shell (a cursory familiarity with C syntax helps). I learned from the well-respected Camel book 20 years ago, and that’s not a bad way to go, although there may be easier and more interactive ways nowadays.

If you are looking for some inspiration, inxi[a] (the system information utility) is an extremely powerful program implemented as a single 33k SLOC executable.

[a]

Looking at all of the public executables on OpenBSD system I’m writing this on (looking within /bin/, /sbin/, /usr/bin/, and /usr/sbin/), I see:

Looking at the same directories on my Raspbian server, I see:

(Dear Lord, always minmaxxing, Linux!! 🤦‍♂️)

So, Perl isn’t going anywhere, is very available, fast, and definitely worth learning as a second programming/scripting language!