67 points · by gfredtech · 9y ago · 117 comments
Perl was a great language design lab experiment. They gave people 20 ways to do any simple thing, and then Matz and Guido looked to see which ways became popular and designed great languages that allow only those ways and maybe 1-2 more that are highly frowned upon. I'm almost as glad Perl exists as I am that I never needed to learn it.
Programming in general is undecidable even if the compiling of the language isn't. Whether or not a program gets to the executable stage may be decidable in some language, but whether that program terminates and calculates the correct result isn't. (So what good is the first order decidability, at the end of the day.)
In practice, building everyday, run of the mill programs terminates in a reasonable time. The undecidability means that the time isn't guaranteed; we must be prepared to wait arbitrarily long for a compilation, and to forcibly terminate it it we feel that it seems like it won't complete. And when we do that, we have no proof that it wouldn't have completed. But, so what; if a file that should take seconds to compile takes 15 minutes (i.e. that particular case is decidable), we still regard that as a problem. Why on Earth is it taking 15 minutes? Either something is wrong, or we have to adjust our expectation for that file.
Certainly the influence on Ruby was larger.
Also, I seem to recall the Perl5 object model was influenced by Python.
I think the influence was mainly in Guido looking at Perl and realizing he wanted a language that didn't look like that.
I'm pretty sure the Guido has said that ALGOL 68 and Pascal was probably the biggest positive outside influences (together with some in-house language called ABC that he was using at the time)
van Rossum's 1993 paper at http://citeseerx.ist.psu.edu/viewdoc/download;jsessionid=51C... explicitly lists C, ABC, Modula-3, Icon, C++, and Smalltalk as influences.
The section "competitors or precursors" also includes Perl and Tcl. It does not appear these languages are influences.
So the design of Python wouldn't have been influenced by long experience with Perl.
What you can't do is tell how to parse a piece of perl without running the program.
http://www.perlmonks.org/?node_id=663393
These are an expounding upon this link. In most languages, you can at least tell what things are. This is a function. That's a variable. In perl, there are constructs whose parsing depend on what a given bit of code was defined as previously, and that definition can be predicated on code execution. This leaves you in a situation where you cannot tell if something is a division and comment or a regex without knowing whether a function takes arguments. ( see link )
The sad part is, in the general case it's impossible for the parser (or any other process overviewing it) to decide if it's actually caught in an infinite loop or not, that's why they call it undecidability.
(The hard limit is how C++ gets parsed, I think. Since parsing C++ is also undecidable thanks to weird interactions with template metaprogramming.)
https://github.com/knome/metabrainfuck/blob/master/bf.cpp
Does attempting to autocomplete such a template cause issues for IDEs? I used emacs when writing it, so I've never tested such a thing.
Honestly, the only reason python "won" was because google picked it up for internal use (and that was only because of the perl5/6 debacle since why pick perl5 since 6 would be coming out by next Christmas?)
As far as "undecidable", its a feature and one of the reasons why it still remains faster than most other dynamic scripting languages.
Python's genius was to force programmers to indent their code, making sure it had at least a modicum of structure.
The "Perl is indistinguishable from line noise" meme came about from folks equating JAPH-style Perl Golf one-liners with all of Perl. It had very little to do with the use of sigils specifically; such "line noise" is perfectly possible in Ruby and Python.
If anything specific to Perl contributed to the "Perl is line noise" meme, it's probably the fact that a bunch of special variables have names consisting of punctuation marks. Nothing stopping the programmer from doing a "use English;", though.
The article is about whether or not you can actually parse Perl without running Perl to parse itself. One of the benefits/drawbacks to Perl is that it lets you run the interpreter at compile time, thus resulting in the possibility of an infinite loop preventing compilation. Which makes some people unhappy.
Oddly enough, this reminds me of the whole strongly/weakly typed discussion, with people weighing in and asserting one position or another, without really adequately comprehending the opposing position.
The meta-discussion here repeats almost every other discussion of Perl I see on HN and elsewhere. First there is a claim of death, either in the past, or present. Then there are claims that death was by sigil, line noise, etc. Further, additional claims are that other tools have taken over its space.
The data used as evidence are StackOverflow analyses, or Tiobe scores, or, insert additional popular, and often self-selected, data sets. You have to make specific assumptions about some of the data presented to be able to accept it, such that each community has about the same rate of people searching for answers on SO, or other places. Or that the searches will have relevant terms in the in each case.
This is a stretch to put it mildly. If I google for DBIx::Simple, and this search is caught by one of these filters, will it show up in Perl or not? I can't actually answer this. I have to refer to what the collectors of the data say on their own methodology [1][2]. I am not saying that there are not secular changes throughout the industry, or that various observed gross trends are "wrong". What I am saying is be careful reading into these analyses too strongly, as they may not be measuring what you think they are measuring.
In many cases, over the last 20 years or so, I've seen folks pushing Python happily talking up why they left or abhor Perl, usually saying/quoting things they've heard. From my own experience, Perl 4 and onward, much of what they complain about was Perl 4 or before. Likely before many of them started programming. That is speculation on my part, but it does appear to fit what I've observed.
If I extend this out to operating systems, I have people tell me how horrible Linux is and how much better anything-other-than-linux is than it on a very regular basis. They like to list (what they perceive to be) the faults, quote SO and other random websites as examples, and often make pronouncements not backed up by objective fact ... in many cases contradicted by objective fact.
We as a society of technologists seem to like our tools to the point where we feel that we can and should break into tribes with tags of honor around our necks, and nasty comments about alternative tools, and users of said tools. I've personally heard many an anecdote and critique of various tools from otherwise smart technologists that were, at best, badly misinformed, and at worst ... not simply disingenuous, but dishonest.
Look, it is great you like your tools, your operating system, your language. It does not mean that you are "better" or "smarter" than someone else because you use such things. And yes, I've had professional discussions as recently as last week on exactly this issue. Which is insane.
Maybe I've spent too many years on the business side, as I look at all of these things as tools to accomplish a goal, and as engineers, our jobs are to select the right combination of tools to a) minimize effort, b) maximize the possibility of success, c) enable debugging, observability, supportability.
No single tool, OS, editor (yes, I went there) has this. Moreover, if you need to bash what someone else is using simply for self gratification, then there are deeper issues afoot than simply a technological consideration.
Finally, I've been a user of Perl, and contributor to (CPAN) for more 20 years. Rumors of its demise, are greatly exaggerated. It is not my be-all/end-all language ... I am comfortable and competent in 5-6 at any one time, and can easily work in Python, C, Julia, Node, etc. w/o major issue (though with google nearby for things I don't have on the tip of my memory).
I don't use Perl for machine learning (though I could). I don't use it for numerics (though, again, I could). I don't use node for either of these. You pick the right tool for the right job. And you need to keep an open mind throughout the process on what the right tool is.
If you feel a need to bash on others choices, it might be worth reflecting why you think this course of action actually adds any light to a discussion. From what I've seen, it only adds heat.
[1] http://blog.codeeval.com/codeevalblog/2016/2/2/most-popular-...
[2] https://stackoverflow.blog/2017/05/09/introducing-stack-over...
[edit: fixed ref spacing]
> The data used as evidence are StackOverflow analyses, or Tiobe scores, or, insert additional popular, and often self-selected, data sets. You have to make specific assumptions about some of the data presented to be able to accept it, such that each community has about the same rate of people searching for answers on SO, or other places. Or that the searches will have relevant terms in the in each case.
> This is a stretch to put it mildly. If I google for DBIx::Simple, and this search is caught by one of these filters, will it show up in Perl or not? I can't actually answer this. I have to refer to what the collectors of the data say on their own methodology [1][2]. I am not saying that there are not secular changes throughout the industry, or that various observed gross trends are "wrong". What I am saying is be careful reading into these analyses too strongly, as they may not be measuring what you think they are measuring.
No measure is perfect, but we're seeing similar trends from multiple sources and they align with my own experience as well. I don't see any value in throwing shade on the measures we have. If you have specific criticisms or reasons they might systematically favour one language or another then by all means post them; otherwise this reads like rearguard sowing doubt because you don't like the results.
> In many cases, over the last 20 years or so, I've seen folks pushing Python happily talking up why they left or abhor Perl, usually saying/quoting things they've heard. From my own experience, Perl 4 and onward, much of what they complain about was Perl 4 or before. Likely before many of them started programming. That is speculation on my part, but it does appear to fit what I've observed.
Now you're the one bashing for self gratification. Is it so hard to believe that people might genuinely have bad experiences with your preferred language?
> I am comfortable and competent in 5-6 at any one time, and can easily work in Python, C, Julia, Node, etc. w/o major issue (though with google nearby for things I don't have on the tip of my memory).
Those are pretty similar languages, or at least admit a similar style of programming; if you want a good toolbox you'd do better to learn a smaller number of more radically different languages. 5-6 languages is far too many to know particularly within a narrow range like this; I'd bet that you're not writing idiomatic code in many of them. I used to pride myself on knowing a large number of languages; now I've realised being able to do more in one language is much more useful.
It's a feature, not a problem.
http://www.oilshell.org/blog/2016/10/20.html
Parsing POSIX shell is not undecideable, but bash adds a construct that relies on dynamic parsing, much like Perl.
(I cite this Perl article and the C++ one in this thread. And there is another one about parsing GNU Make.)
FWIW, Larry Wall has mentioned many times that Perl 6 fixes this problem. So he very much views it as a language design flaw. I don't think you can argue that it's not.
I watched 3 or more videos on Perl 6 and he's mentioned it at least twice.
Perl 6 is also a mostly unpaid volunteer effort. So everybody gets to choose what they work on, and very few people are brave enough to work on that aspect of the compiler.
Also I would say that the main priority of Perl 6 is to integrate many ideas from many languages and bring them together in such a way that it seems as if all of these ideas always belonged together.
The reason why the object system sees more optimizations is because everything is, or can be seen as, an object. A big improvement there, can for example make regexes faster.
Languages can include meta-programming/macro facilities without effecting whether or not the parser can do its job; I am fairly certain that Rust's macros are an example of this. Python, as a more dynamic language, also includes metaprogramming facilities (metaclasses, decorators) but IIRC, can still be parsed without needing to simulate a Turing machine.
In Lisp you can modify the read table at run time, so you can do whatever you want. The functions the reader calls when it comes across '(', ')', ' ', and every other character are all completely customisable.
Site's not ready for 21st century.
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.
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.
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.
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.
- 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.
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. :)
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.
If you know Unix, you will already know about 80% of perl. If you know Perl well, you already know a lot of Unix concepts.
Perl is a pain to learn if you don't have a solid Unix background. However, IME, if you acknowledge the sources Perl draws from, look at how they're integrated, and spend some time learning the underlying technical culture, it actually simplifies the learning process.
Interestingly enough, it's also easier to learn a natural language if you spend some time learning the underlying culture.
Who are you?
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.
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.
If you haven't, I suggest reading through https://pragprog.com/book/swperl/modern-perl-fourth-edition
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.
I don't know much about the Python ecosystem, but my impression is that besides the 2to3 program there wasn't really much of an effort to make them work together.
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.
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.
If an app needs something, it will either get it from there, or failing that, from add-on packages.
That only matters for fitting into a small embedded system where you can perhaps get a smaller image if you just bundle the exact set of packages that are required.
Due to inter-package dependencies, that plan can easily be foiled.
In the end, it's better to have a big, "batteries included" language. For one thing, it is all released at once. No separate versioning for one hundred different packages. The regression test suite for the language can cover that functionality which would otherwise be in packages. No nonsense of releasing a new version of the language and then relying on field reports about broken packages.
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.
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)
This is largely because of the sheer volume of weird global state inspections/mutations you can do in Perl--or I guess it's more accurate to say that Perl has a conveition of it being "OK" to heavily and frequently inspect and mutate global state. You can monkey patch in many languages, and sometimes it's even encouraged (Ruby), but only in Perl is it not uncommon to see monkeypatch removal or seriously altering replacement of core functionality. I've had modules hackily unload other already modules because the loaded modules' names matched a buggy load-time regex. I've had packages clobber text handling or encoding routines in other packages at compile time, or only after calling a certain function a certain way. I've had modules change the behavior of the core signal handling APIs so that any code that talked to them . . . didn't actually handle signals. And those are just the pithy examples that fit in a single sentence.
Now granted, this isn't a criticism of Perl-the-language but more of (depending on how you choose to interpret it) library authors who don't prioritize or even consider interoperability with other tools, or of Perl-the-community's conventions regarding when it's OK to go mess around in globally-stateful guts of code you don't control. You could also just as easily say that it's a symptom of the big, multipurpose monolith I had to maintain--which is valid, but other not-designed-for-huge-projects languages don't, in my experience, have problems quite this bad when they're forced to scale.
My goal isn't to cast blame, but to point out that CPAN is incredibly bloody far from a high-quality, stable, or usable code repository for certain very common use cases.
I wasn't talking about the size of cpan because it's not relevant to my point. I was talking about Perl not being at the forefront of everyone's minds and being used as a 1st-class environment as computing entered new domains. E.g. instead of Sun or Microsoft taking an existing language like Perl and giving it a canonical IDE to let programmers write data entry GUI applications, they create Java & C# instead. When Google/Android decided on a development language for their smartphone SDK, they chose Java instead of Perl. It doesn't matter if cpan has mobile phone libraries now.
You seem to be taking my observations about Perl as some sort of veiled attack. I'm just reporting why and how Perl got to the state of being "disliked" today in programmer surveys. It's not about the "undecidability".
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.
@foo
... is more compact than C#... ArrayList foo = new ArrayList(); // C# v2
var foo = new ArrayList(); // C# v3
And Perl %foo
... is more compact than C++: auto foo = std:map<string>;