Why would you use Perl in 2024?

Sun 17 November 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 clearly remember circa 1993-4 overhearing someone at a restaurant making a joke about "C, C++, and C+++" (Or was it "C, C+, and C++?")

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:

  • a sed script
  • three python scripts
  • eight korn shell scripts
  • a dozen Bourne shell scripts
  • 157 bash scripts
  • and just four Perl scripts

One of the Perl scripts wasn't written by me (the venerable scrmable.pl 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.

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:

  • Incredible speed (even faster than Python, the last time I checked)
  • Powerful and sane syntax
  • Native and powerful regex (bash has since added this, although only extended regex)
  • Universal: Most UNIXes come with a Perl interpreter pre-installed, or quite readily accessible

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 (the system information utility) is an extremely powerful program implemented as a single 33k SLOC executable.

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:

  • 9 Korn shell scripts
  • 22 Bourne shell scripts
  • 34 Perl scripts
  • 598 ELF executables

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

  • 2 Korn shell scripts
  • 744 Bourne shell scripts
  • 2 Java source files (?!?)
  • 30 Ruby scripts
  • 102 bash scripts
  • 242 Python scripts
  • 510 Perl scripts
  • 4490 ELF executables

(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!

Category: Tech Tagged: BSD Computing FOSS (Free and Open Source Software) Hobbies Language Linux Non-religious post Productivity UNIX WritingMonth


Which Linux Distro *shouldn't* I pick, and why?

Wed 30 October 2024

I enjoyed The Linux Cast's recent video tackling the perennially-debated question of "the best Linux" distro, and I wanted to present my own somewhat tongue-in-cheek version of a recommended Linux Distro List, but more like a dis-recommendation list.

So here are some distros I (kinda sorta) do not recommend …

Category: Tech Tagged: Computing FOSS (Free and Open Source Software) Linux Non-religious post Productivity UNIX

Read More
Page 1 of 2

Next »