I'm an author on CPAN who pushes one or two releases a month[1]. I'm actually surprised the number of uploads is still as high as it is, and a few thoughts struck me about the graph:
1) Most long time libraries have pretty much reached stability and the (still relatively high) backwards compatibility promise of perl5 means they don't have to be updated to support changes in the language, which still has releases every year.
2) The quality of uploads to CPAN is of the form of solving more complex problems or interfacing with core Unix/network/internet/lower level lib stuff stuff - you don't see so much of the leftpad type modules on CPAN.
3) It definitely feels like the number of authors has shrunk significantly, even though the graph suggests that has stayed relatively level. I suspect there's a long tail of active authors and most signups never actually upload anything
4) The biggest problem now is finding modules for newer APIs - I wrote some, including for more well known services such as GoCardless and Monzo
5) Holy crap, the graph covers almost 24 years of uploads. You will probably see the same pattern in Python, JS, Go, and so on if you come back in an equivalent number of years - the most common problems get solved first, and libraries uploaded for those.
6) The graph covers uploads to CPAN, I'd guess a far more important one would be downloads from CPAN as that will probably give you more information about the relative level of use of the language.
There's so much negativity in this thread. I think that a big part of Perl's decline is exactly because of people's attitudes. I don't actually write any Perl now, but to me it's a beautiful language, I always enjoy working in it. You can abuse it in the wrong way like every other language. If I was to suggest using it in the day job there would be uproar probably. But just because I like Perl doesn't mean I want to write everything in it, use the best tool for the job and sometimes the best tool is Perl.
Yes, thank you. Perl was an absolute earth-shaker back in it's day. Even still it's a fantastic language for string manipulation. Much of Ruby's beauty, expressability, and powerful string processing is thanks to inspiration from Perl. It's disappointing to see people crapping on such a venerable language.
Prel is great and has an important role, even today.
That being said, I'm a professional dev and we own a decent amount of perl. That codebase is by far the most difficult to work in out of anything we own. New hires have trouble with it (nobody learns perl these days). Lots of it is next to unreadable.
I agree that like any other language, perl can be written well and can be written poorly. That being said, perl makes it _really_ easy to write something poorly, in contrast to something like python which is a bit more rigid and tries to have one right way to do things.
I still use perl pretty extensively for little one liners, but at this point we are actively trying to get rid of as much perl that we own as possible. We find that rarely writing anything longer than 10 lines should be done in perl, if only from a readability and maintainability standpoint.
I love perl. It was THE game changer for many many years. But perl is falling out of fashion quick.
I'd have no problem working in the language with some very rigid guidelines and a bunch of experts.
But the reality is that nobody is hiring perl experts, perl experts are becoming more and more scarce, and most new hires have a bit of experience with py or rb. I dont dislike perl, I'd just argue it's almost always the wrong thing tool for the job these days.
In a previous life I worked at a large E commerce company. You've likely ordered from them. Pretty much everything ran on perl/perl Mason for over a decade. At that time perl was the cool new thing that everyone wanted to pick up. Now (or when I left a few years back), most of that code represented a liability if it needed to be changed.
IMO this is just the cycle of a programming language.
I remember reading Spolsky articles where he talks about VB6 like it's some shiny new amazing scripting language, akin to python 10 or so years ago. But alas, time moves on and so do most programmers.
I've gone from finding perl an absolute joy to program in circa 2005 to now (2019) where I wouldn't touch it with a barge pole. The sentiment seems pretty natural and common.
I work on a large, legacy codebase (the oldest modules date from the mid-nineties) that's slowly being rewritten from Perl into Python. A handful of developers have been involved with the project from the beginning. Looking at the long term contributors, readable or un-readable code seems to be more about the person than the language. Unsurprisingly, the person who produced the most unreadable, unmaintainable code is now doing the same in a new Python only project.
I've always tried to look at programming in a similar manner as writing research papers, your ideas are no good if no one understands how they're put to paper. Explicitly stating your intentions is better than assuming the reader knows the subject matter. If something is clever, overly-compact or your reviewer expresses confusion, rewrite it or at least spend an extra line or two in explanation.
At the language level, I miss Perl's handling of regexps and shell commands (which consist of large amounts of this codebase). Python requires a fair amount of overhead to handle both and always feels a little clunky. While I'm far more fluent in Python, I typically reach for Perl when needing to quickly handle log files, automate shell tasks, and prototype ideas. On the flip side, now that Python supports type hinting, function signatures are much more valuable, and overall I feel I can write far more robust tests in Python than Perl. Given that the direction of the project is to move from a collection of one-off scripts that just kept on growing to a tested, maintainable, modular codebase, Python is the better choice.
> Looking at the long term contributors, readable or un-readable code seems to be more about the person than the language. Unsurprisingly, the person who produced the most unreadable, unmaintainable code is now doing the same in a new Python only project.
I would totally agree.
I learned Perl after first learning Basic(and Visual Basic) then Java.
Coming from Java meant that I always tried to use clear variable names, good comments, broke my code into small and simple functions etc. I repeatedly had people say to me "Wow! I didn't know you could do that in Perl!"
A lot of Perl's bad reputation came from sysadmins and other busy folks who either weren't familiar with good syntax or were in a hurry and basically were playing Perl Golf to get things done quickly. This is probably where the line "Perl is a write only language" came from.
I will concede that Python and it's forced indenting leads to much easier to read code for beginners. That being said, trying to understand what's going on with advanced Pandas usage written by Numpy wizards is no walk in the park either.
I also totally agree that the Perl one liner is still my go to even though I do everything else in Python these days.
> Looking at the long term contributors, readable or un-readable code seems to be more about the person than the language.
The biggest problem I have with Perl is like C++, the language is so stupidly big that every single programmer knows a different subset of the language.
I used to bump into this problem when I was interviewing for VLSI jobs and somebody would always do the "Let's talk about Perl" round. I was quite fluent at Perl at the time, and there would ALWAYS be some idiom that would stump me.
I solved this by bringing my own Perl program on a printout with me--I also brought the Python version of the same program with me. Suddenly, the interviewer was in MY subset of Perl and almost always went "Oh, you're a lot better at Perl and programming than I am" instead of dinging me for not knowing weird Perl trivia.
I still use perl for handy one liners on the command line. E.g. I had a 1 GB log file where I wanted to generate a histogram of the intervals between certain log messages. I used a perl one-liner to extract the timestamp via regex (regexs are perl's bread and butter), calculate the diff between the previous timestamp (easy because of auto string => double conversion), use the diff value as a key in a hash of counters (autovivification really handy here), then print the hash at the end with sorted keys using the Data::Dumper module. Took me all of 5 minutes to write. I don't write Perl often but I am thankful that it exists.
I'm an occasional perler myself and I bet that others or myself would find that code you mention to be useful, at least for the black book of snippets. Would you mind pasting?
From a experienced linux sysadmin point of view perl5 is as good as it gets.
I've been searching for alternatives for about 10 years now, at first because my novice self was heaving headaches reading other people code and even my own. I hated perl but I hated everything else even more as I came to know them. No autovivification? Some assignments copy the data and some create references and you need to memorize the conventions of which does what? 3x to 10x lower performance? My program crashes because of white space? Fuck that! Back to perl5.
I'm sorry to say nothing can replace perl5 for me even now in 2019. I wish something would come along even if it takes years. We need alternatives and competition, perl5 will get too old at some point and 6 is... I don't even want to go there.
Autovivication seemed like a great feature to me, back in the day, when I was getting started with Perl. Working with similar data structures in languages like Python always seemed like a chore.
I had heard a few perl monks criticize it a bit, as an "end run around use strict", but I was kind of dismissive. It turns out, that's a really apt way to describe it. It basically tosses the niceties of use strict out the window, so long as its a hash. And sooo many things are hashes/hashrefs in Perl.
The first time I wasted a day tracking down a bug that turned out to be a well hidden typo in a hash key assignment, changed my mind. Well... maybe the third time.
FWIW, you can 'lock down' a hash so that reads or writes of non-existing keys will cause a fatal error. Not only does this stop autovivification on 'writes' to a hash, but it will also help catch typos in your code just reading from the hash: e.g. if you accidentally wrote
$foo = $bar{Autovivication}
instead of
$foo = $bar{Autovivification}
in your program, it will abort instead of returning an undefined value :)
I mention I am a linux sysadmin but I should have been clearer: I always use perl for <100 line scripts. Back when I started and in my peer group we made clear difference between programming and scripting. I never learned programming, I don't need to as that's not my job. I write small glue scripts and that's where perl shines and I see nothing else having any chance to replace it from what exists now.
It's not perfect, but it does it job, and usually it's simpler/faster to write code than in some other langues (usually with the cost of worse readability).
I don't think there's any way to avoid that. You could always copy, but then you'd sacrifice performance. You could always make a reference, but then other parts of the language would become really complicated.
Or you could use functional persistent data structures for your stdlib types, like Erlang’s map. (Essentially, “reference on read, amortized copy on write.”)
Not quite, references were introduced in perl 5, in perl 4 and earlier had a different method that wasn't quite multi-dimensional arrays but tried to behave that way.
$hash{1,2,3} = 10;
This actually ends up doing the following
$hash{join($;, 1, 2, 3)} = 10;
It builds up a single key from the list using the special variable $; as a separator to the elements. With perl 5 you gained the ability to make references which allow you to actually make multiple dimensions and to do it on arrays, not just hashes.
$array[1][2][3] = 10;
That also allows for more complicated data structures and much easier ways to iterate through the structures.
I've just written a utility I needed in Perl. I tend to think about some things in the long term, and this utility is something I want to be able to run 10 years from now.
[it's a concistency checker (hasher) for file archives, to find out if the bits in your copy are really the ones you put there, important for multi-GB photo archives — see https://github.com/jwr/ccheck]
I do most of my programming in Clojure, which has excellent backwards compatibility and takes a long-term perspective. I still run some unmodified Clojure code from 8 years ago. And yet for really long term stuff, I would much rather write it in Perl. It has been around for a very long time, is very mature, and can be expected to last, even if it isn't the latest fashionable trend.
Take a look at the various programming languages+environments around you: there will be very few where you can expect to be able to run your code even 2-3 years from now, much less decades later.
These are for third-party packages though, Perl might be perfect but the rest of the software world not so much... That dwindling number of submissions not only means that new libraries are not being integrated as fast as they should but also, and perhaps more importantly, existing libraries are not updated.
It's pretty sad too because I distinctly remember that one of the main selling points of Perl when I started using it in the early 2000's was that CPAN was more complete and diverse than any other scripting language out there.
we waited for them since the very beginning of the millenium, i played with both and here is the difference: DNF is very desapointed and is not the revolution i expected. Perl6 is a game changer and push the idea of "scripting" way beyond i was imagining it (and i played with a lot of langages)
The written specification wasn't being kept in sync with the implementation and has been relegated to the status of 'design document'. The language is nowadays defined and versioned through its test suite, and there have been two releases (v6.c in Dec 2015 and v6.d in Nov 2018).
This is exactly the same reason that they stopped updating Microsoft DOS -- they achieved perfection. That or it become obsolete. I guess it depends on to what degree one is nostalgic and to what degree one needs to keep their skills up to date.
No languages are casual. I wrote Perl for about 5 years and was super productive with, but haven't looked it for quite a while. Most energy these days goes into JavaScript/node and it devolves into gibberish really, really quickly. The community really dove into the punctuation-based syntax, preprocessors and meta languages head first and created a real Frankenstein. And they'll complain that Java or C# are too verbose and slow to work with.
I've been writing Pascal and Delphi for more than 25+ years and C and C++ for around 20 years and a bunch of other languages for at least a decade, yet even with the tons of additions that Free Pascal has added over the years i always find Pascal code way more readable than C or (especially) C++ code. It helps that the Free Pascal developers try to keep the syntax for new stuff "Pascal-ish".
I've been coding in Perl for 20 years, I'm a CPAN author [1] and I just published my third CPAN contribution yesterday.
I've written over half a million Perl lines of currently in use enterprise cloud software[2] and I'll keep coding in Perl because I don't like the big snake dictatorship of "There should be one — and preferably only one — obvious way to do it."
The other place where this principle is completely ignored is when it comes to Python packaging, which is a complete and utter disaster.
There are many different ways to package Python, none of them are feature complete, and the result is an absolute maintenance nightmare for those of us who have to maintain tools that have Python dependencies.
Perl got packaging right, there's one way to do it, and it just works!
> Python packaging, which is a complete and utter disaster.
This is a huge barrier to entry for the first time or casual contributor. And when you try to figure it out (or figure it out again), you have to triage all the old and new overlapping documentation.
There isn't one way to do it in Perl (EUMM, Module::Build, Module::Build::Tiny, Module::Install etc), we just tried to make sure that they all interoperated cleanly. And we have things like the Toolchain Summit to make an emphasis on that.
I stand corrected, thank you :) Clearly, you succeeded in your mission since it feels like there's one way, and most importantly, it 'just works'. Many, many thanks to you and everyone who made that happen!
I used Perl for a bit but switched to Python because I was finding it harder to work out what some code I'd written a year or so ago did than to write it again, a problem I don't have with Python.
Perl is a general purpose programming language. The Perl interpreter and language are stable, it's not going anywhere soon. Perl and its syntax have been around a lot longer than most other languages and is very similar to C, C++, JavaScript and PHP. What do you consider normal syntax?
The most obnoxious parameter passing in existence? The magic variables everywhere? Perl code is an unreadable heap of spaghetti, I’d much rather be figuring out unallocated memory bugs in C then read Perl.
But why obnoxious? Do you know how old Perl is? Have you written shell scripts before? My point is, some of choices Larry and others made wouldn't necessarily be made today, but there's a history, a lineage, a reason for all of this. I actually like the magic variables, but as I said in my other comment, you need to learn it first. X language is an unreadable heap of spaghetti if the programmer writes X language in an unreadable way.
Not to someone who doesn't know Perl. But this is the same for every language. No one should be picking up a new language and working with it if they don't know it.
EDIT: To clarify, I mean there should never be the expectation that you can start working in a language in earnest without properly learning it.
What makes that less obvious is when you work with references to arrays; the reference itself is a scalar, so it gets the scalar sigil. You can dereference it, though, by sticking an array sigil in front of it, thus telling the interpreter "hey, this is a scalar reference to an array".
1 out of 100 might be understating it, though. Or it might be overstating it. Who knows?
As another data point, I've had very few good experiences with Python. The primary exception has been with PyQt5, and chiefly by going with Qt's conventions instead of Python's (i.e. being as Qt-like and un-Pythonic as possible).
> I want to run this on a production Server with ubuntu 16.04. My Sysadmin tells me that I shall not use pip or github repository, because of ... something wrong with using anything but apt ... he says.
Sysadmin is right.
First response?
> sudo apt-get install python-pip
Now there are ways to convert modules to debs (or rpms on redhat style machines) so they can be managed cleanly across an estate, but that's not the python way.
Which one? Python 3.5.x or 3.7.x or something else? Version 3 should be version 3. Anything written in 3 ought to work on every Python 3. Not so in the Python world. And that makes it a mess to use (unless you Dockerize every script).
Perl 5.001 is really old (25 years or so), and lots has changed since then. v5.10 introduced a barrel-full of new features; other important features like the "use v5.10" syntax for supporting older scripts didn't land until much later (v5.16).
Where I work, a few of our legacy systems are still dependent on ~v5.10, which can be a real pain when trying to port code back to legacy. I agree that the Python versioning problem is perhaps more prominent, but Perl 5 doesn't really get a free pass here.
The "use VERSION" syntax is fundamentally much older. It used to strictly just assert a minimum version. It also, pre 5.6, required floating point versions ("use 5.005"). In newer versions of perl, this syntax will also invoke "use feature <stuff new in your version and all versions before>" which allows the use of incompatible new features in its lexical scope. One example is that "use 5.12;" and above will turn on "use strict" in the lexical scope. I fought long and hard for that one. Makes the language strictly better (pun intended).
It strictly does! :) I knew that "use 5.12" implied "use strict" but I didn't know the mechanism, or that it could enable other features as well. That's pretty cool!
Perl documentation online applys to versions of perl that are installed. Python stuff is all bleeding edge - you'll research why something isn't working and after 30 minutes find it's expecting python 3.7.
The whole concept of "virtualenv" gives me an impression of fragility I don't get with perl.
Wanted to use Python 3 for some processing but the Sysadmin said that only Python 2 was available for that distributions version and "didn't want to frankenstein the box"
FreeBSD ships perl5 in base, but python is an addon. I suspect other BSDs may be similar. The only thing more ubiquitous is POSIX compatible /bin/sh but that's much less featureful.
Because of the stability of perl5, I barely care what version of perl5 that ends up being. (Perl 5.10 and up is pretty much what I want, 5.8 and 5.6 are a drag if i might need unicode)
Look across a bunch of common languages - Java, Perl, Python, Javascript, PHP, and of course C/C++/C#/ObjC, braces + semicolons. Even Bash and Go have braces.
>>> from __future__ import braces
File "<stdin>", line 1
SyntaxError: not a chance
Back to the topic, while I don't think its ranking doesn't generally reflect the actual popularity, the TIOBE index [1] is a good definition of "common enough" languages. So let's see... oh! There are 5--7 programming languages out of top 20 that do not generally use both braces and semicolons! (Python [not-so-strictly-necessary semicolon only], Visual Basic .NET, SQL [semicolon only], Assembly language, MATLAB, Visual Basic and Delphi/Object Pascal [semicolon only]). I also happen to know less popular but well-known programming languages that do not use both braces and semicolons at all (ML, FORTRAN, Lua, Forth and of course all lisps). So please allow me to reword your claim: why should braces and semicolons be normal?
I used Perl for many years, and still do. My bias is now toward Python for scripting, because the young all seem to know Python. But for example to write a script to be run on Linux that will talk to SQL Server, I will use Perl, since DBD:Sybase works, and I don't feel like fussing around to find and configure a Python equivalent.
I miss Perl. I love Perl still and would reach for it for any project I could. That said, I switched to Python because going into recent interviews and doing the white board or online assessment, Perl isn't necessarily an option. At least it's not a popular option. I do miss Perl and will happily without shame admit it.
It's interesting. I started Perl in around 2005, and moved entirely to Python in 2014, exactly when it reached it's peak and started to decline. Seems I wasn't the only one.
What kind of web server would even be calling Perl CGI scripts in 1992? I thought it was all bulletin boards back then. Personally I just got my first PC and was learning to play Commander Keen in 1992 ;-)
My first exposure to Perl pattern-matching was a magic regex for parsing CGI input handed down to me by a more experienced coder. "Don't ask how this works."
I think Perl was fighting on too many fronts at the turn of the century: web, systems automation, data processing, science and a few more. Today these areas are better covered by other languages that have hefty internet buzz and corporate support behind.
Perl also has no shiny features. It's just extremely dynamic and paradigm agnostic, great at shell interactions and natural at text processing (specially with regexes), good enough at binding C/C++ libraries, has package management built-in (CPAN) and an automated testing culture. Perl basically set the baseline for a lot of today's languages.
Perl5 devs put a lot of focus on making Perl even more dynamic during the 2000s, relying on CPAN/community to fix language quirks and plug in novelties. It worked to some extent, Perl got to the point where it could be written like Haskell, Ruby... During that time it also got a powerful but optional class system (Moose) and reinvented itself as a web language (Mojolicious, Plack).
Unfortunately it all came too late, most Perl5 devs moved to something else or maintained Perl5 code frozen in legacy mode. Fewer and fewer started new projects using Perl. For instance, nowadays I tend to pick a language/ecosystem pair based on these concerns first depending on what the job requires:
- asynchronous event processing, specially network related -- I pick JavaScript/Node.
- real parallel processing and highly performant systems, I'd use Go.
- "we got a package for that" -- Python or JS at the forefront here. It depends on what package I'll need for the job, typically it's not going to be in CPAN.
- great code reuse/portability -- to me JS wins here. And still the only single language for both server and browser.
- compiled hard-packaged binaries: Go, but also Rust, Elixir, Nim, and others can fit the bill.
- code style and paradigm -- a very personal choice, I think Typescript and ES2019 are both great here. Golang and others are also great if I feel like staying away away from OO.
Perl would have a hard time competing in any of these fronts, but it still is one of the greatest for practical extraction and reporting, text or database wise and easily available or pre-installed on many servers out there new and old.
> web, systems automation, data processing, science and a few more.
doesn't this apply to python, although now there are additional competitors?
> reinvented itself as a web language (Mojolicious, Plack).
highly opinionated and potentially flame creating , but -
perl was the original web language in the CGI era, PHP pretty much dethroned it due to simplicity of server integration, rails knocked them both out of 'leading edge', then the Node/SPA era arrived.
mojolicious / plack are pretty much things to bring perl up to date w/r/t the 'rails' type
I've long thought if they had PHP-style inline HTML/Perl templates it would've given the language some legs. I'm pretty sure it exists (since I remember using it back in the day as a toy, just like JSP and other stacks), but it either came too late or didn't take off before PHP stole the throne.
I love Perl but I'm currently looking at around a decade of experience which is really hard to take into a new role. I'm working a bit on Wordpress now but PHP is basically close enough to Perl for me that it sits in a weird uncanny valley where I get things just wrong enough to cause headaches every time.
This september 2012 release was kinda huge for me. It brought venv, generator expressions (event loops) a-la nodejs at the time, sped up a lot of things as well. It was a great release and a step in the right direction. Perl6 was still a myth at the time.
I did not start using python3 until last year, but I was aware it was evolving quickly to one day become usable.
Perl is good for a competent coder who doesn't work as a developer,
occasionally has a one-off coding task, and wants to incorporate a
code excerpt from the web and immediately execute it (and then throw
the code away). Languages with whitespace as syntax often fail the
"immediately execute" requirement.
I actually used Perl last week to whip up two scripts (csv2insert and csv2update) to automate converting CSV files to MSSQL-specific SQL insert/update scripts (respectively). Microsoft's own CSV import tools suck, and it was pretty straightforward to use Text::CSV and print() a bunch of SQL lines.
I'd need to do some more polishing before putting it up on GitHub or something (namely: sanitize incoming single-quotes in CSV cells, and possibly break the steps into subroutines), but I was yet again impressed by the ability to automate a bit of text data processing with less than an hour's work.
That makes me think: is there any instance that the rate of increase of packages or similar metrics ever went below zero (presumably due to removed packages)? I'm not sure if it is generally impossible in typical package manager models though.
"rate of rate of increase" = "second derivative", I presume. Negative second derivative doesn't necessarily mean a decline, it can be just growth slowing down.
Yeah I learned Perl in 2013 or so and I almost exclusively use it as a better shell+sed for text munging, which is where it excels. In my experience Python is super bad at this compared to Perl or even shell
I assume you already knew and don't wish to change client -which is fair enough- Weechat supports Python and Ruby in addition to Perl.
I remember the time before Irssi, when even CLI clients regularly had remotely exploitable vulnerabilities in them (including the 1337 BitchX). Irssi was programmed with safety in mind. Either way, scripts increase attack surface.
I'm not using IRC clients right now (I quit after realizing more than 50 windows open isn't productive), but I really love both Irssi and Weechat's interface (including default themes) and CLI. Did have to finegrain the configs but the same's true about nearly any application these days.
Perl is a prerequisite for Autoconf as well (not for the generated configure scripts though, thankfully). It would be nice to not have that dependency.
irssi has support for perl, python, js, tcl and lua(very alpha)
https://irssi.org/modules/
None of those other modules are as featureful as the perl module and are looking for people who are interested in developing them further :)
I have a crontab that runs every five minutes: 30 lines that use one CPAN module, no bugs in years. The code has the kind of hackiness that's okay when it fits on one screen, and it fits on one screen precisely because of that hackiness.
It's very hard to know which codebases will grow to be large - every codebase starts out small, and by the time you realise it's going to be big, rewriting into another language is expensive. Better to use a language that can scale to small codebases and large, that can accommodate hackiness and cleanness alike.
Nicely put, but I notice that you avoid names and numbers.
How expensive can it be to rewrite a hundred or a thousand lines, if a perl script keeps growing? And what are these languages (you use plural so I do too) that are optimal for every case?
> How expensive can it be to rewrite a hundred or a thousand lines, if a perl script keeps growing?
A hundred lines, or a thousand lines, is not so bad. But where do you draw your line in the sand that you're going to stick to? If you don't insist right at the start on coding to your maintainability standards, why would you make that change when your script went from 30 lines to 100, or 100 to 500 (no doubt always driven by an urgent functional need)? It's always easier to add one more change to the existing codebase; the only point where you'd rewrite is when the codebase becomes literally unmaintainable because no-one understands it, and at that point migrating it is extremely expensive.
> And what are these languages (you use plural so I do too) that are optimal for every case?
I'm not saying optimal (I doubt that's possible), I'm saying pick a language that's adequate for every case. I'm partial to Scala, which was explicitly designed as a "scalable language" that would work for large and small codebases; other ML-family languages (e.g. OCaml) are similar. In my book any language with the ML featureset is more than adequate for large codebases, and any language that has a REPL/interpreter and doesn't require Java-like explicit types is adequate for scripting tasks. (Side note: I've always found it odd that Perl didn't have a first-class REPL, since IME that's one of the biggest natural advantages of scripting languages). If you want to start from the scripting end, Python, Ruby or even TCL offer a level of consistency and least-surprise that let them scale to larger codebases than Perl, though I wouldn't really want to use any of them on a truly large codebase.
Next question: Code written in which of these languages tend to avoid needing major redesign when a thirty-line script grows unanticipatedly to much, much more?
I've seen plenty of Scala codebases grow without ever needing an overall redesign, and don't see why it would be different for any other language. Of course the end state is very different from the start state, and no doubt pieces end up getting rewritten many times over. But being able to incrementally evolve the codebase while keeping it all working is much easier and cheaper than having to rewrite in one go. In my experience you only need a "redesign" when you did too much design up front in the first place; if you always keep code changes driven by concrete use cases and avoid premature generalisation, you end up with a codebase that won't impede future changes any more than it has to.
Perl more than any other language I know depends on the self-restraint of the programmer to write readable code and not be overly clever with their syntax. I’ve worked on some large Perl codebases in the past that were as readable and maintainable as, say, Python.
Yeah, I've seen perl programs so broken down into simple procedural steps that non-coders were able to go in, understand what it was doing and even make some of the changes they needed after a little trial and error, but also other programs so concise and/or confusing that I'd rather rewrite it than try to figure out how it works.
All the "big" Perl codebases I've worked with were as readable as I'd have expected any "big" codebase to be, if not better. What was your experience like?
I don't find it so. I do both Perl and Python at work: the Perl code is almost always clearer to read IMHO. I know some people find curly brackets and sigils distracting, but to me they make code less ambiguous.
I agree that they are terrible, but not all programming is large code-bases. I think Perl is good for its originally intended use as a high-level scripting language.
Perl aims to be an enabler, and is therefore not particularly opinionated ("there is more than one way to do it"). This includes making little to no effort to make it hard to write difficult-to-read code.
Personally, I don't tend to have a hard time reading code I myself wrote, even long after the fact. But I will concede that Perl code _can be_ hard to read if the author has been too clever.
"too clever constructions which feel smart at the time you come up with them"
That's the coder, not the language.
Which is more obvious what's happening.
print ''.join('%(pre)s%(num)s %(bot)s on the wall, %(nul)s %(bot)s,\n%(tak)s\n' % (lambda c,b: {'pre':['','%s %s on the wall.\n\n' % (c,b)][abs(cmp(c,'Ninety-nine'))], 'num':c, 'nul':c.lower(), 'bot':b, 'tak':['Go to the store and buy some more... Ninety-nine %s.' % b,'Take one down, pass it around,'][abs(cmp(x,0))] })((lambda x,o: [(['Twenty','Thirty','Forty','Fifty', 'Sixty','Seventy','Eighty','Ninety'][x/10-2]+'-'+o.lower()).replace('-no more',''), o][int(x<20)])(x, ['No more','One','Two', 'Three','Four','Five','Six','Seven','Eight', 'Nine','Ten','Eleven','Twelve','Thirteen','Fourteen', 'Fifteen','Sixteen','Seventeen','Eighteen','Nineteen'][[x,x%10][int(x>=20)]]),'bottle%s of beer' % ['','s'][abs(cmp(x,1))]) for x in xrange(99,-1,-1))
Or
my $firstline = 1;
my @tens = qw/Ninety Eighty Seventy Sixty Fifty Forty Thirty Twenty/;
my @teens = qw/Nineteen Eighteen Seventeen Sixteen Fifteen Fourteen Thirteen Twelve Eleven Ten/;
my @ones = qw/Nine Eight Seven Six Five Four Three Two One/;
sub go {
my $num = shift;
my $bottles = "bottles";
if ($num eq "One") {
$bottles = "bottle";
}
if ($firstline == 0) {
print "$num $bottles of beer on the wall.\n";
print "\n";
}
$firstline = 0;
print "$num $bottles of beer on the wall, ".lc($num)." $bottles of beer,\n";
print "Take one down, pass it around,\n";
if ($num eq "One") {
print "No more bottles of beer on the wall.\n";
print "\n";
}
}
foreach my $ten (@tens) {
foreach my $one (@ones) {
go("$ten-".lc($one));
}
go($ten);
}
foreach my $teen (@teens) {
go($teen);
}
foreach my $one (@ones) {
go($one);
}
print "No more bottles of beer on the wall, no more bottles of beer,\n";
print "Go to the store and buy some more... Ninety-nine bottles of beer.\n";
print "\n";
People can do clever things in either language, people can write clear code in either language.
Languages are not just platonic, ideal things, living in an abstract world. They are also people, core developers and BDFLs, guidelines, communities, cultures.
The Perl culture is overall about being practical but also being clever and leaning towards code golf.
The Python culture is overall about being explicit and readable.
As usual, YMMV, but that's the impression an awfully lot of people get, so there must be some truth to that.
The problem with any language is most people don’t spend time to actually learn it to proficiency. They don’t read the books, just google a quick solution.
Perl is great because it has nuances many languages don’t, for instance sigils which allow the language to evolve safely (adding language constructs won’t clash with vars.) and “magic variables” designed to allow shortcuts like we use in spoken language. But, just like people shouldn’t use much spoken vernacular in writing, a lot of those features are designed for quick “conversations” and one-off scripts. And it should be peer reviewed before publication.
Python is great for many things too, but it’s no C++, and it’s also no Perl.
This post reminded me that Perl doesn’t even have a concept of a method signature, even so much as showing the number of arguments. You have to look at the next few lines to hopefully see all the `... = shift;` lines to see what you’re actually supposed to send.
I mean, a lack of type annotations is normal for a scripting language, but Perl always seemed to go a bit far by not even having a standard way of showing parameter names.
I remember doing `my ($arg1, $arg2) = @_;` or something similar, but even that felt weird, and not everyone adopted that convention.
Apart from on the smallest programs. So it does have a method signature (obv it's an untyped language)
There are shortcuts (just like you could write "doSometing() unless $var;"). Perl does give you options.
Python has different options for passing methods - passing variables, passing a dict,
P.S. while looking at python method declartions, you can send variables, a key-value, multiple keyvalue, and then there's this: https://stackoverflow.com/a/16785702
Which comes out with
f = lambda **dic: ' '.join(dic.get(key, 'None') for key in 'abc')
Which is no more or less readable than the most confusing perl I've ever encountered.
"Cool Shortcuts" are a problem in any language. There are values in anonymous functions on occasion (especially in sorts), there should be a very compelling reason to do so.
That does not work. Prototypes are ignored for method calls. You are expected to not abuse prototypes for signatures as they serve a different purpose.
> it's an untyped language
That's wrong even with the most lenient/charitable interpretation. Using an unexpected type of data is a fatal error.
perl -e'$x = {}; $x->[0]; print "survived"'
Not an ARRAY reference at -e line 1.
... but it does, since perl 5.20, which was released May 27, 2014. More than five years ago.
Here's a short example:
use 5.020_000;
use warnings;
use experimental qw<signatures>;
# this works:
say add(2, 3);
# this dies: Too many arguments for subroutine 'main::add' at ...
say add(2, 3, 4);
sub add ($x, $y) {
$x + $y;
}
That's my point, it's not the language itself that changes readability (although personally I find the lack of visual blocks and statement ends in python a right pain). Perl isn't a "write-only language" unless you want it to be.
I'm not a programmer, I'll bash something out to solve a problem and move on, but in general I find reading other peoples perl far easier than reading other peoples python. Maybe that's because I have more experience with perl, because it's well suited for problem solving.
I avoid cpan and pip as much as possible as it makes code much less portable, and unless the module is available in apt (and thus trivial to deploy) it would have to be really compelling to get me to wrap into a custom deb, but that's because I'm not writing products, I'm writing utilities to help run my network.
That was the point they were making, that you can write horribly ugly code in Python if you really put a lot of effort into it, and that you can kinda sorta write readable Perl if you put a lot of effort into it.
1) Most long time libraries have pretty much reached stability and the (still relatively high) backwards compatibility promise of perl5 means they don't have to be updated to support changes in the language, which still has releases every year.
2) The quality of uploads to CPAN is of the form of solving more complex problems or interfacing with core Unix/network/internet/lower level lib stuff stuff - you don't see so much of the leftpad type modules on CPAN.
3) It definitely feels like the number of authors has shrunk significantly, even though the graph suggests that has stayed relatively level. I suspect there's a long tail of active authors and most signups never actually upload anything
4) The biggest problem now is finding modules for newer APIs - I wrote some, including for more well known services such as GoCardless and Monzo
5) Holy crap, the graph covers almost 24 years of uploads. You will probably see the same pattern in Python, JS, Go, and so on if you come back in an equivalent number of years - the most common problems get solved first, and libraries uploaded for those.
6) The graph covers uploads to CPAN, I'd guess a far more important one would be downloads from CPAN as that will probably give you more information about the relative level of use of the language.
[1] https://metacpan.org/author/LEEJO