top | item 15738867

(no title)

grabcocque | 8 years ago

You know there was that recent Stackoverflow analysis that concluded that Perl was the most disliked programming language?

It got me to thinking about how Perl managed to become quite so profoundly disliked, and I remembered these papers and thought that maybe things like this are the reason.

discuss

order

GuB-42|8 years ago

Perl is designed to make life easier for the guy who writes the code, not the one who reads it.

The motto "there is more than one way to do it" is telling. It allows beginners to write code the way they are most familiar with and give experts a large toolbox to be most efficient in many situations. The trouble is that while the writer only needs to know a subset of the language, the reader has to know everything in order to read other people code.

This philosophy make it very suitable for quick hacks, and that's its primary use. The problem is that quick hacks have a tendency to stay, and some poor guy need to maintain that mess. And when your experience with the language is to maintain the unmaintainable, hate is totally justified.

Note that is is possible to write clean Perl, but it requires effort, and unless you are writing Perl modules, there are probably better languages for that.

Compiler undecidablity is not a problem. Sure, it is not intellectually satisfying, and it may be troublesome for some application where formal proofs are required, but for a language like Perl that is all about practicality, no one really care.

falsedan|8 years ago

> Perl is designed to make life easier for the guy who writes the code

Whenever I write perl, I feel like the binary is actively fighting me, not helping me…

perl is designed to make simple things easy, and hard things possible. Readability is up the the programmer, and writability is up to the editor.

dozzie|8 years ago

> The motto "there is more than one way to do it" is telling.

The more telling is you omitting the other half of the motto. TIMTOWTDIBSCINABTE

mhd|8 years ago

People don't really care about how hard it is to parse a language, and complex grammers might actually be due to making it easier for humans. One of the bigger differences is IDE support, but more regular languages that compete with Perl had about the same issue here...

Perl derives its dislike from about the same source as BASIC (and arguably PHP): Early errors/preconceptions and plenty of non-programmers writing code (home computer users, sysadmins). Perl4 was used for some pretty hacky jobs, replacing sed/awk/shell combinations (which were horribly fragmented across the unices of that time). Modular Perl5 code had little to do with that, but by then the damage was done. Early CGI scripts didn't exactly help, either.

Modern Perl is a step further than that, but when Moose and the like became popular, people already moved away to PHP or Ruby, both being part of the same family.

dmytrish|8 years ago

Perl has a lot of crappy language design decisions (which make it "fun" and a tire fire waiting to happen in any large-ish codebase):

- interpretation of a variable (is it a list, a number, a string, a hash?) depends on the context in which it's used, and the context depends on, um, its context;

- pervasive global state (`$_` and friends);

- you can mess with compile-time operations, patch the language on the fly, e.g. during module imports;

- autovivification: a single read by key from a hash is enough to actually create this key; variables are a number and a string at once, but the number will not be computed until you need this variable in number context. Reading a non-existing key in a hash as a hash actually creates a new subhash.

- ties: you can override access to any variable by your methods;

- the built-in data structures are special, there is no sane way to emulate and extend them (but, as usual, for sure there are insane ways);

- the built-in `sort` takes a code block (not a closure with parameters), that has magic variables `$a` and `$b` appearing out of thin air. It looks like a closure, but it's not.

- features are often added in a convoluted way. E.g. there was a (now deprecated) feature that allowed `push` and `shift` to take a reference to a hash instead of a hash directly. How was it implemented internally? Basically by backpatching the error condition when the existing `push`/`shift` choked on a reference.

- the language design principle is "Do What I Mean" (where the "I" part varies). It's ironic that a language built "for human communication" by a linguist (what could possibly go wrong?) is harder to read and to reason about that programming languages built around logic.

On the other hand, if your business brings enough income to pay good developers with strong discipline, you can still have a big codebase in Perl and sustain it for years: it's better to have a terrible language and good engineers than bad engineers and a good language.

hoytech|8 years ago

Most of these design decisions are very useful and pragmatic, and not everyone regards them as "crappy".

Additionally, there are several misleading statements in your post. I expect you are aware of the following but just for the record:

> - pervasive global state (`$_` and friends);

Perl uses dynamic scoping (https://en.wikipedia.org/wiki/Scope_(computer_science)#Dynam...) when setting $_ and friends. For example:

    $ perl -E '$_ = "A"; say; say for ("B", "C"); say;'
    A
    B
    C
    A
For me, dynamic scoping (and, relatedly, RAII) is sorely missed in languages that don't have it. (Although I do agree about $a/$b in sort -- that's a language wart, but not too bad in practice)

> - autovivification: a single read by key from a hash is enough to actually create this key;

Not true:

    $ perl -MData::Dumper -e 'my $h = {}; $h->{a}; print Dumper($h)'
    $VAR1 = {};
You need to read it as a hash or array reference for it to autovivify:

    $ perl -MData::Dumper -e 'my $h = {}; $h->{a}->{b}; print Dumper($h)'
    $VAR1 = {
              'a' => {}
            };
Autovivification is another feature that I miss in languages that lack it.

Your points about the perl5 implementation are definitely accurate, although I suspect a lot of language implementations have their own dirty laundry as well. :)

carlmr|8 years ago

>It's ironic that a language built "for human communication" by a linguist (what could possibly go wrong?) is harder to read and to reason about that programming languages built around logic.

It's not like having a fascination with weird language quirks makes you have good taste in languages. Especially because weird quirks are the end of usability.

psergeant|8 years ago

Perl is disliked because it has a very shallow learning curve to do badly, and a high learning curve to do well. Therefore, lots of people see a lot of bad code, but also people don’t understand a lot of good code.

Ultimatt|8 years ago

Its the main reason any language is hated. JavaScript now is less hated because the tooling got there and people were educated at university to program in it well. PHP and Ruby are on the list of disliked on the SO analysis. Which is basically nonsense for modern versions of both languages. I really wish these stats would state "Perl 5" too, as Perl 6 is really modern in semantics and syntax and is nice to code in.

ionforce|8 years ago

This is one of the most well-reason and true responses I've ever read about Perl.

Who are you?

lazyloop|8 years ago

Perl being a dead and disliked language has become a meme. But the community is still very much alive and a lot of cool stuff is being built with Modern Perl. http://mojolicious.org

pjc50|8 years ago

Perl used to have fans with meetups and so on. I've not heard of these for a long time.

IMO three things killed Perl, leaving it as an unpopular legacy husk:

- loss of ecosystem. The high points for Perl were CGI.pm and its use as a "super awk" by sysadmins. The first was obliterated by other ecosystems, better and worse: PHP, Rails, Node, Go, and so on. The second was obliterated by "servers are cattle not pets": people have moved from meticulous hand-administration to the use of containers, Ansible, etc - or away from systems administration altogether to AWS or "serverless".

- Perl 6 transition. Second-system effect at its highest. The long wait for this to be completed absolutely destroyed incremental improvement because everyone was waiting for a big bang that came very late. Python managed to avoid this level of community damage but has still split into two languages, Python 2 and Python 3.

- the "two Perls" of style; one was the Wall-influenced style that looked a bit like English. The other was sigil-heavy and incomprehensible. Eventually people decided that it was easier to put up with syntactic whitespace than remember all the $? and $| and so on, so a lot of the Perl audience moved to Python.

dozzie|8 years ago

> IMO three things killed Perl, leaving it as an unpopular legacy husk [...]

I don't really think it was any of these. There's much simpler mechanics at play here: Perl's competition (Python and Ruby) has about the same expressiveness, but is much easier to learn, so for a long time very few people have chosen Perl to learn. There was simply not enough young blood to replace old timers that were retiring, dying, or migrating to other languages.

cestith|8 years ago

Perl5 is the second system. That's why it seems so bloated. The releases of Perl5 since Perl6 work started actually became larger and more frequent. There's lots of work between, say, 5.8.8 and 5.28.8 including making lots things to do with regexes iterative that used to be recursive. Old features now finally have explicit deprecation schedules. Lots of features in the core and popular libraries are back-ported from Perl6.

If you haven't, I suggest reading through https://pragprog.com/book/swperl/modern-perl-fourth-edition

oblio|8 years ago

> Python managed to avoid this level of community damage but has still split into two languages, Python 2 and Python 3.

The fracture is very slowly healing. Outside of some huge corporate hold outs with a lot of Python 2 code (Google & co.), Python 3 will win out.

Perl 6 vs Perl 5, on the other hand, I don't even know if you can call it a fracture. A new start would be more fitting.

cutler|8 years ago

A big contributor to the demise of Perl, IMHO, was the failure of Catalyst and mod_perl to compete with PHP and Rails. mod_perl security was too risky for most ISPs and Catalyst, with it's clunky subroutine attributes style of routing and hefty CPAN dependencies, was a pain to get up and running. Mojolicious was a big improvement but too late to stop the PHP and Rails defections.

rurban|8 years ago

It's more caused by the toxic climate amongst it's maintainers, paired with technical and management incompetence.

When Larry Wall was still the lead a lot of progress was made, but then it reversed course in the last 20 years. Every single competent developer left or was booted, and not a single of the many designed features for Perl6 were properly implemented in perl5. Perl5 is now purely a religion, with the heresy to express of loss of faith in the supreme leaders gets you booted, whilst uncivil name-calling and technical destruction by wannabe middle-managers took over.

The undecidedability problem is caused by the dynamic lexer. It's actually a feature to drive the static parsing rules dynamically.

ceronman|8 years ago

Perl is a very practical language. But this practicality has been achieved by building features on top of bad design. The result is a big, complex and quirky language. To make this worse, the community decided to "fix" this re designing the whole language from scratch. They created Perl 6 which has a much better design, but it's incompatible. The community now it's broken in two and the future doesn't look that good.

zbentley|8 years ago

I think the word "big" above is often overlooked when discussing Perl (5). For a scripting language, there are an incredibly huge number of core language features. Even compared to something like Ruby or a lisp-like language with a true templating/macro system. It's easily up there with c++ in terms of "number of (sometimes crazy) things you can do with the core language/distribution out of the box".

And that's not even a statement about how many ways there are to the same/similar things things; these features all are intended to facilitate different stuff. I think it is the biggest language I've ever programmed in, fighting for top spot with C++.

I think core-language-feature counts are something it's better to have in moderation. JavaScript of ~2010 was far too small a language, so it had crazy library/cargo-cult utility bloat. Lisp is somewhat similar: it's elegance in its small size and simplicity, but that results in a lot of beginners (re)writing a lot of unnecessary code. Perl and C++ have too many core-language features; everything else is somewhere in the middle.

...and all that is without even getting into some of the insane language extensions you can find in third-party libraries. There's an on-after-module-load hook someone wrote that's implemented in terms of a syntax extension to the language, that isn't quite an operator or a statement. There's a coroutine library which is written mostly inside to the fatal-killsignal core dump handler I think (or something similar). And the list goes on.

hultner|8 years ago

It's actually quite interesting, from what I've understood it's one of few well adopted programming languages that's designed by a linguist and made primarily to be easily understood and written by humans.

At the time of inception and around the peak of popularity I do believe it was a quite innovative language. But by now we have a much larger set of languages aimed for the same target group, many of which have gained larger adoption among developers of this time.

In a way I can almost see Node as "the new Perl" in the sense that it's a widely used language across platforms praised for it's large set of available libraries and ease of creating "quick n' dirty"-hacks.

jasode|8 years ago

>how Perl managed to become quite so profoundly disliked

I'm guessing the reasons are actually more conspicuous than computer science concepts of "undecidability" since most working programmers don't read academic papers to judge whether they like/disklike a programming language.

The conspicuous reasons seem to be a combination of:

1) PERL's usage of sigils.[1] One the one hand, it makes code compact and terse. On the other hand, many perceive the source code as "line noise" or "sigil hell". This is the opposite problem of other disliked languages like Objective-C where people complain it's too verbose.

2) PERL not having a constantly updated ecosystem that keeps up with new trends in computing. PERL was great for text munging (alternative to sed & awk). However, PERL wasn't extended as the driving language for dynamic web pages (Brendan Eich created Javascript instead of embedding Perl interpreter in Netscape browser), or GUI data entry forms programming (Java and C# gained popularity), or machine learning (Google developers designed Python to be 1st class in Tensorflow), etc.

tldr: PERL is perceived as "legacy" with ugly syntax

[1] https://en.wikipedia.org/wiki/Sigil_(computer_programming)

Ultimatt|8 years ago

Point 2 is kind of nonsense. The ecosystem is incredibly big and keeps up with most things. Name something then search here https://metacpan.org/ The main missing stuff is anyone marketing heavily their libraries and there being communities around them etc. Like probably no one knows what PDL is, even though it was around long before numpy+scipy etc. Before data science trended in the mind of hipster VCs and coders. The naming was to try and win over people from the IDL language, used mostly in image analysis in physics/geography. A niche crowd to be sure. Perl sort of never caught on to the modern style of advertising what its got. In the same way no one really advertises grep, awk or sed but lots of people still learn and use them.

kbp|8 years ago

> 1) PERL's usage of sigils.[1] One the one hand, it makes code compact and terse

Sigils have nothing to do with Perl's terseness; actually, they make code very slightly (one character per variable) more verbose. In Perl 5, $foo is a scalar, @foo is a list, %foo is a hash, etc. $foo[0] is the first element of the list @foo; it gets a $ because the element being accessed is a scalar. This is in contrast to most languages where variables are referred to like 'foo' and that's that.

psergeant|8 years ago

Why do you write it in all capitals?