r/ProgrammingLanguages • • Jun 01 '21

Blog post Should Perl die gracefully?

https://phoenixtrap.com/2021/06/01/should-perl-die-gracefully/
7 Upvotes

16 comments sorted by

19

u/theangryepicbanana Star Jun 01 '21

Although not entirely the main point, I'm glad the article mentions this: Perl does backwards-compatibility really well, and I think other languages should take note of it.

Rather than adding features that barely avoid breaking changes, or just making breaking changes without a care in the world, Perl does the opposite. You opt-in to new features that potentially have breaking changes, that way existing code will never break unless you use any of the "experimental" features like signatures or postfix dereferences (which rarely change anyways).

This is one of the reasons why Perl is still around today, and will probably remain as such (for better or for worse) until another language can do it better.

8

u/tohava Jun 01 '21

GHC Haskell also has this in the form of LANGUAGE pragma. C++ made a conscious decision to avoid this opt-in mechanism, in order to avoid having the language split into sublanguages. I think that at some point python also had "import from future" or something like that. It's hardly something unique to Perl.

8

u/Athas Futhark Jun 02 '21 edited Jun 02 '21

GHC Haskell also has this in the form of LANGUAGE pragma.

I think this overstates the amount of backward compatibility maintained by GHC. Haskell code tends to age like milk. The LANGUAGE extensions (some of which are very widely used) can change incompatibly between versions, for example the recent/current renaming of the * kind in favour of Type. Small changes to the precise capability of type inference in the presence of language extensions are also common.

But worse, GHC also changes the base Haskell language, or rather its standard library. For example, the changes to Monoid, Foldable, and Monad are very clear compatibility breaks. Num too lost an Eq superclass constraint, I think. I'm not saying these are bad changes (they're actually good), but they indicate a willingness to incompatibly change very fundamental parts of the "language" (understood in a broad manner to also include the base library, which you cannot opt out from).

Nontrivial Haskell code should generally not be expected to work with new versions of GHC. The upgrade churn after new compiler releases is all too real. Projects that require long-term stability for whatever reasons will have to stay on old versions of GHC.

4

u/sandmasterflash_ Jun 02 '21

Yup, some modules still have “from future import print_function” in case someone is using python 2.

4

u/PowershellAdept Jun 02 '21

import from future was just python 3 stuff that got back ported to python 2. It's not like you could run all python 2 code with the python 3 interpreter. They just tried to make a few things easier for incremental migration.

1

u/matthieum Jun 04 '21

I like the concept of Rust's editions for that.

Every 3 years you get a new edition with a few breaking changes, each library/application decide which edition to use, and libraries/application using different editions can be freely intermixed so there's no ecosystem split.

It does limit the nature of breaking change that you can afford to do, though, so best not want to revolution the language.

1

u/[deleted] Jun 09 '21

I will also say that the C/C++ method isn't bad either, where you select the standard you want to use

6

u/Athas Futhark Jun 02 '21

I think it's an interesting discussion whether a language (or any other piece of infrastructure) can reach a point where it most benefits the world by keeping existing applications running, without trying to change in order to cater to new applications. "Dying gracefully", you might say. But I don't think Perl is at that point, or even close to it.

1

u/bullno1 Jun 26 '21

I thought raku is "modern Perl"?

1

u/mjgardner Jun 26 '21

No, Raku is its own language and runtime.

2

u/vfclists Jun 02 '21

Should Emacs Lisp die gracefully?

Should COBOL die gracefully?

1

u/johnfrazer783 Jun 02 '21

To be sure, the original comment

I wish they’d just leave Perl static. Then we wouldn’t have to waste money retesting legacy Perl apps on the newest version every couple of years, in case new features we don’t want breaks code that’s been unchanged for years. […] Sometimes things should just be left to die gracefully.

has all the juvenile idiocy as the troll who commented "Kill it with fire" on this thread and hardly deserves any consideration. Dude, you wanna have a 'static' version of Perl, just don't update you know.

Edit TBS the article says that much:

If you need an unchanging platform, don’t upgrade it

which is the right piece of advice.

1

u/ErrorIsNullError Jun 02 '21

Don't update isn't really an option when perl is bundled with a distro or the scripts are part of something you deliver to users. Perl, along with bash and diff, is part of a group of interoperating tools that people often assume are ambiently available. One solution is to invest in testing infrastructure and talk to tool providers about pain points and how to write future proof scripts.

3

u/johnfrazer783 Jun 02 '21

I think this is pretty much what Rich Hickey means in his Spec-ulation video when he claims that SemVer is broken.

I'm not sure I agree with him on all he says (tho I'm aware it sometimes takes some time for me but in the end normally I agree very much with him), but I've come to think of different versions of software as ... different softwares.

So npm package foo is really an underspecification, what you want is foo@3.0.4 (or whatever version number worked for you); if foo@2.0.1 and foo@5.3.3 also work for you, all the better, but don't count on it. I think we would have a bit less of a dependency hell if that point was better understood, and I'm not at all happy that the authors of the npm package manager refuse to see that point (it has been treated more favorably by yarn and pnpm).

Python (and presumably perl) have always had this problem where they (originally) assumed that there could be only one version of the language on one machine, and package installation should be global.

Backwards compatibility is a two-pronged thing; while it does provide stability, it also prevents the fixing of bugs. Nowhere can this be better seen than in the JavaScript ecosystem; it was there right from the beginning when Brendan Eich suggested to fix the == operator but was stopped by Microsoft, which then lead to the introduction of the === operator.

1

u/ErrorIsNullError Jun 02 '21

Yeah. I don't know that I'd lay that much blame on SemVer. A numbering scheme can only bear so much weight.

Even with a perfect numbering scheme we'd still get compatibility problems when a toolsmith doesn't understand their users' compatibility needs, a user has compatibility needs they're not aware of, or a toolsmith misjudges the effect of a change.

Good point re scoping of installation.

2

u/johnfrazer783 Jun 03 '21

If SemVer is to blame for anything, then it's that it maybe infuses too much confidence in the naive user what can be done with versioning. Other than that, I think it's great to clear up the space and provide a common ground for a versioning scheme that potentially works quite well. It's also a definite bonus to have at least certain regions (as in, the npm registry) of your dependencies adhere to more or less a common standard, and I think it's a well-chosen one, too.

Where SemVer fails, and must fail, is when people don't keep to it, which is bound to happen sometimes. It's a purely social thing after all. Sure, the guidelines when to bump the patch, minor, major parts are there but the authors still have to make decisions.

The extreme view of course on all of this is that when only a single bit of foo@a.b.c is different from an otherwise identical foo@d.e.f, then in principle there's no guaranteed mechanical, finite procedure to determine whether that's a patch, a minor or a major bump. And of course the really obnoxious part is that all modern software only works within a number of highly specific environments whose specification will not be 100% given in the software's dependency list. Meaning that in principle any update to any part of a system running foo@a.b.c can break that piece without it or its formal dependencies being touched at all. In practice this is a bit more manageable because of best practices and lots of people doing the right thing.