But unfortunately, some Perl devs in recent years keep thinking that what they need to do is break stuff to "modernize". They keep eyeing goals like turning `strict` on by default, and eliminating lesser-used features, which will surely break untold numbers of 20-year-old scripts.
I think there is some low-level anxiety among some of their developers that interest in their language has basically evaporated and they keep reaching for a silver bullet that doesn't exist. I think they are crazy ("perl 7... now 10% more like python!") but it's open-source so in the worst case I'm sure someone will keep a traditional perl from bit-rotting.
edit: I had made a short blog post about playing with perl 1: https://rwtodd.org/2020/Jun/building-perl-1
Not unless you declare a version. Old style perl will continue to work as before.
If you declare something like:
use v5.40;
... then, and only then, you'll get strict/warnings/whatever turned on.Your 20 year old script can continue to run just fine.
Some--not all--of the people working on perl really want so-called "cruft" to disappear. I'm not a fan of that attitude for such an old language with such a rich history of backwards-compatibility, and I definitely don't think it's going to accomplish some kind of perl renaissance. I think it would be better to double down on what makes perl unique. When I watch Signes giving a talk like https://www.youtube.com/watch?v=FlGpiS39NMY where he shakes his head at variables like `$;` or `$,` (29:20 in the video) ... it looks like the leaders of perl hate how strange it is. That worries people like me, who love perl _because_ of its quirkiness, not in spite of it. Surely people who want something more consistent have moved to Ruby long ago.
Personally, so long as all that stuff's behind a feature bundle I'm all in favour of it.
A little nitpick: it's not about "multidimensional hashes", but rather "multidimensional array emulation". Steer clear of it, if you can.
I personally don't mind using variables like $; or whatever. Some prefer to "use English" and use longer variables name for the same effect. More power to them.
I just wrap the call with the proper "## no critic (...)" and off I go.
I have a feeling you're reading Richardo Signes wrong, by the way-- he likes to play up what a negative kind-of-guy he is, and makes critical remarks about the state-of-perl in public that some people take a little too seriously. Perl-haters gotta hate, and they really loved to link to his talk with the title about how perl is an "Ongoing Disaster" or some such.
Feature bundles don't bother me, but if I read between the lines (possibly too much), comments they make seem like they are still looking for an opening to remove some of these features entirely. I hope I'm wrong.
(I remember the Ongoing Disaster talk, I personally thought it was fun)
https://gist.github.com/Grinnz/be5db6b1d54b22d8e21c975d68d7a...
There was some talk about that a few years back, but those ideas have largely been abandoned. They've also adopted the "steering committee" approach, and they have something like a formal RFC proceedure to talk over new proposals-- in general the project is in very good shape. And backwards compatibility is still the rule, unlike a lot of other projects out there.
Isn't it the whole point of Raku (previously Perl 6)?
The main reason to learn Raku at present is simply that it's profoundly different from most other things out there-- there's no particular "killer app" that's emerged for it, but it's unusual enough that this might happen yet (no one expected Perl would be critical for "Web 1.0" and the Human Genome Project...).
Some Raku features:
(1) it's numeric types include true rational numbers, so there's less chance of being tripped up by floating point approximations (e.g. 2/3 is really 2/3, and if you multiply by 3 later you get precisely 2). It also does big integers by default: you're less likely to have overflow problems.
(2) Raku's regular expressions have been redesigned from scratch, and it ships with expanded capabilities to compose them into larger structures called "grammars": Raku is a uniquely powerful tool for writing special-purpose parsers, ala domain-specific languages. (Note: this is how Raku parses itself-- it's not implemented in the usual lex and yacc style.)
(3) Extremly convenient features for handling CAP (concurrency, asynchrony, parallelism), possibly the easiest to use of any language.
As for Perl (meaning the original, Perl 5), it's vastly superior to traditional bash scripting because all the components were brought into one process where they could be made more consistent and talk to each other easily.
How Perl compares to Python is a little difficult for me to answer: I prefer Perl, but I could be biased on this one, and there's no question Python has quite a bit of momentum at present in a number of areas.
I am surprised you didn't mention Perl 11 which is try to mash Perl 5 and 6/Raku together. Is that still happening? Or do I have it wrong?
"How Perl compares to Python": The first thing I tell Perl programmers who are starting to learn Python: There are Perl-style references in Python. (If you are not familiar with Perl: These are a roughly pointers, and can be 'undefined' / null.) In short: You cannot create a reference to a scalar in Python. Perl hackers then scratch their head and ask, "Well then, how do I build XYZ data structure without...?" The easy workaround is a single element tuple or list. "Aha!" Otherwise, Perl programmers can adapt very quickly to Python.
Both of these approaches have their advantages. I have a saying I overuse: "Python helps you think more like the computer does, Perl helps the computer think more like you do". The consequence of this is that python is good at helping people think about tasks that the computer is good at in - like statistical problems. On the other hand perl is good at helping to contain the mess and chaos of the real world in a way that makes it more tractable for the computer - which is why it remains popular in the recruitment industry backends and other less tidy business areas.
Perl's very raw unvarnished object model is in fact based on python's, so it is very similar, but it's also built for flexibility. This means object models like Moo[1] which are really nice flexible and done right make it really easy to write extendable applications. Implementing python's object model in perl (i.e pretty much the exact specification) is easy. However you can't implement perl's object model in python except by messing with the guts of the python interpreter.
I haven't done any commercial python - I only have a passing aquaintance really from messing with sympy and the like. But boy perl has been good to me. I earn a good living in an interesting job and I can maintain interests out of work as well. And I haven't had to look hard for work for years. Of course currently I'm neck deep in recursive SQL queries.
[1] https://metacpan.org/pod/Moo - My favourite job to date was building a back end to spin up network devices, that got one gentle refactor after the initial implementation and was then subsequently extended to three or four completely different network device architectures extremely quickly. Mostly by virtue of making almost every object property read only and memoised on demand (extensions to existing methods would are likewise inlined on complilation - all done with object composition rather than inheritance too for an added layer of sanity)
I use Perl over Python because of the culture/tradition of not introducing breaking changes into the language/runtime, which has also saved me countless hours. I'm also a fan of arbitrary whitespace for formatting.
Perl is ubiquitous in the *nix world. Combined with its stability and my avoidance of third-party libraries, I can run my scripts basically anywhere without struggling with dependencies, version mismatches, etc.
* not grinding a theoretical axe against the user
* language changeable at run-time to some degree, so stealing new ideas from other languages and keeping up with advancements in PLT can be and is done by end users, not only the maintainers
Example: Convert Windows newlines to UNIX newlines: $ ... | perl -p -e 's/\r\n/\n/g' | ...
My brain is too full to remember how to do similar regexy transformations using sed, but I know it can be done.
It depends on what you are trying to do.
Perl excels at processing text particularly if you are familiar with regular expressions.
Perl mainstreamed regular expressions and most programming languages that support regular expressions support some subset of Perl regular expressions.
Perl is faster than both Bash and Python and scales up a bit better than Python as a project starts to grow because 'use strict' and 'use warnings' will catch many errors. Python has a better 'batteries included' standard library, so it tends to be better at prototyping than Perl unless you are pulling in libraries in which case it depends on what you are trying to do.
Perl can be more terse than Python, particularly if you are using built-in variables. However, this impacts legibility which is part of the reason why Perl is the target of 'executable line noise' jokes.
I think people tend to associate it only with a certain era of web dev, but it has remained a good scripting language with a large, consistent, well-documented standard library for a long time now.
Not worth switching off perl since you're very used to that, but iirc ruby was initially conceived as a successor to perl and for me at least it has landed in that role.
I think it's the sysadmin culture. If your scripts are used by thousands of different servers hosting custom web apps and strange databases you'll run into every possible bug fast.
The compatibility really does stretch back all the way to '94.
I'm curious, though, do you have any Perl programs you've worked on recently that are public? I'd love to take a look at how people are writing Perl these days...
template default perl
Which features do you see as esoteric?
I typically write code which I can (and do) copy and paste into PHP almost without changes. (I use PHP as both webserver glue and for duplicating functionality so that I can have two copies of the same code to validate against each other.)
I've also started adding some Python to my project and developed a very similar style in Python, using commented curly braces to reduce the code's brittleness.
I used a machine with a 9-year-old distro on it for a few months, and all my scripts ran without issue, and I have high confidence that they will continue to run for years down the road without my having to adjust them for breaking changes in the language runtime, which is more than I can say for most other stacks I've used.
Furthermore, ALL the code examples I can google up will work without me having to check if they're for the right version of Perl, because it has near-perfect backwards compatibility going back all the way to 5.000 from 1994.
About the only other thing with a comparable level of stability has been HTML/JS/CSS, which gets a lot of new features all the time, but, for the most part, if I use only minimal features, remains usable for years without modification.