Hacker News new | ask | show | jobs
by snorkel 1514 days ago
Perl rose to popularity because early web development was all about text processing (reading web forms and outputting HTML) and Perl made that easier (regex deluxe) than other choices on unix at the time. It became the lingua franca of web developers. Perl 5 made heavy use of symbols so it was visually noisy, and then Perl 6 came along and added even more magic meanings to other symbols, and that was a tipping point of perl’s decline. Readability of code is paramount. Code is for machines to execute and for humans to understand. Perl code became both modernist abstract art, and Baroque in its intricacies.
6 comments

> Readability of code is paramount.

For almost all languages, Perl included, this onus is mainly on the programmer. You can churn out gritty spaghetti in almost any language. Perl code doesn't have to look like what Perl programmers put out in the 90s. It's an old misconception that people refuse to let go of.

> You can churn out gritty spaghetti in almost any language.

I hate this argument because it doesn't allow for any variation in the intrinsic readability of languages, or the style those languages encourage. Yes, you can write shitty code in any languages, but some languages encourage it, while other languages discourage it. I would say that Perl encourages unreadableness more than any of its peer languages, and the corpus of actual code out there is much more likely to be terse, unreadable noise than what you're likely to find in most python or ruby projects.

> "I hate this argument because it doesn't allow for any variation in the intrinsic readability of languages, or the style those languages encourage"

I don't understand what you mean by this. How ever does that argument mute Perl's dynamic expressiveness - which lends equally to unreadable syntax as much as clean syntax - or the commonly encouraged patterns in Python?

> "and the corpus of actual code out there is much more likely to be terse, unreadable noise than what you're likely to find in most python or ruby projects"

Because Perl saw in its infancy back in the 90s much higher use than Python and Ruby did. It's the same with PHP, which looked like shit in the 90s even if it didn't need to. Incidentally, PHP, too, suffers from stubbornly outdated criticism.

I think you're too hung-up on the languages themselves, and forgetting that programmers, and software development and engineering as a process and as an art, evolved a lot the past 20 years - much has happened also with how people write C today compared to the 80s and 90s.

I'm there with you. Taken to the extreme, this is why we don't use assembler for everything. I mean, it's Turing complete, right? And you can write readable assembler, true? And yet, we don't, largely because it's much easier to express large systems in other languages that are easier to write, read, and reason about.

OK, so Perl isn't assembler. Still, it's a lot easier to write unreadable code in Perl than it is in some of its contemporary languages. You don't have to, sure. You could write clean, pretty Perl code. I know, because I've seen it. But in my experience, that definitely wasn't the common case.

True you can write readable Perl code, but developers tend to adopt the predominant style of the community of each language, and the community was showcasing more brevity and cleverness than clarity
>You can churn out gritty spaghetti in almost any language

But some languages make this much easier than others

That should not be misconstrued as Perl making it hard to write clean code. It does not. It swings both ways.
As someone who spent many years loving Perl, I counter that literally every programming language is obtuse and overloaded with meaningless symbols.

And I'd also credit Perl's rise to Lincoln Stein who wrote CGI.pm which was at the time the absolute state of the art for managing web applications with Apache and mod_cgi.

yes and, one of Perl's design goals was literally "report generation" .. which it turns out, might be in HTML format
It can't do reports. It's a rubbish lister.

It's also clearly not an anagram of REPL. I wonder if anyone ever figured out how to write REPL with a keyboard. I'd like to learn it some day.

(REPL was written in a crazy character set and relied on custom printed punch cards. I think it was the perl of its day.)

CGI.pm is a port of Perl 4 cgi-lib.pl. Credit: http://cgi-lib.berkeley.edu/#credit
I first encountered Perl as Perl 4, which certainly had the @ and $ sigils. I had been using Perl 5 for a while before using it in any web development. I think that Perl 6 contributed to Perl's decline much more by the long delay and certainly than by anything it had when it appeared.

Edit: and Perl 4 had the % sigil.

If I understand right you are saying that the # of symbols Perl employs makes it hard to understand or read, correct?

TL;DR; I would say that you assertion is context sensitive. - For a junior Perl programmer or an outside expert those symbols are stumbling blocks. - For an intermediate Perl programmer and up, those symbols are tools that make the code more readable and expressive.

I got two ways of looking at that. First, I would look at Perl in the context of language. It is a more context sensitive language than some of it's close competitors. When you understand those \ $ % @ & sigils you gain the ability to know at a glance the context in which data is being used. Understanding @_, $_, allows you to write shorter code without sacrificing meaning. Part of the Perl philosophy is TIMTOWTDI. Most of those special variables also have an English equivalent. Instead of using $) which I never remember I can use $EGID, or if I think that's not explicit enough then I can use $EFFECTIVE_GROUP_ID to really spell it out.

The second way is that Perl has a steeper learning curve than it's close competitors. I see this like comparing Vim to Notepad++ and Emacs, or Haskell to well most other functional programming languages. Just because it took longer to learn, that doesn't mean it's better or worse at creating good code. It does mean that armchair pundits are less likely to be correct in their hot takes. They lack experience and understanding.

While ultimately everything is a matter of taste, the kind of people that hate sigils also tend to hate parentheses in Lisp. Both syntax elements are there for a reason.

I believe sigils make string interpolations easy to support in a language. Consider JS that had to introduce an adhoc „${}“ expression to support those eventually.

An excellent heuristic proposed e.g. in the book "Modern Perl" (2015) [1] is to think of $_ as the pronoun it in human language, and @_ as the pronouns they/them.

Edit: a previous HN comment thread on how sigils are derived from practical linguistics: https://news.ycombinator.com/item?id=26659322

1: https://pragprog.com/titles/swperl/modern-perl-fourth-editio...

> Just because it took longer to learn, that doesn't mean it's better or worse at creating good code. It does mean that armchair pundits are less likely to be correct in their hot takes. They lack experience and understanding

Ah yes the same snobbery and inability to take criticism that's been the standard since the 90s. And people wonder why Perl is dying (so is Emacs, Vim only survived because a significant part of the community decided to break away, refactor create a community that's more engaing and less snobbish). You forget what Perl was made for. Basically a replacement for awk/sed and so on and writing quick scripts that can be used elsewhere. If a newbie want to invest significant time and effort learning a new language why the hell they will spend it on Perl rather than a real language like C/C++ and in more modern times Rust, Go or Swift that actually creates performant code?

What? Perl it's far more than a regex machine looking like line noise. If you think that about Perl, you'll get mad with AWK.

To me Perl it's a better tool for anything better than shell scripting without needing to get dirty with C or Go.

I feel like PHP was the first big blow to Perl's king-of-the-web status. Python and especially Ruby+Rails knocked Perl off many people's radars for good.