News for hackers. Stuff that matters.
Re:We were wizards – a foreword to Learning Perl by hnlmorg on Sunday March 17, 2024 @04:35AM (#39732880)
> Perl was rightly bashed because it was the poster child of cowboy coding, which flies in the face of good engineering practices: Understandability, predictability, reproducibility, measurability, safety.

That’s the meme, but it’s simply not true.

I’m going to use Python as a basis of comparison because that’s the language which, from my perspective at least, seemed to replace Perl.

> understandability

A lot has been said about sigils but ultimately a language is only as familiar as a developers exposure to it. Python appeared easier to understand for the newbie because it favoured words over expressions but now that Python has matured it’s become just as incomprehensible too.

> predictability

I’ll be the first to admin that there are a couple of really massive footguns in Perl which are remnants of its evolution as a shell tool. But there’s other aspects to the language which are really clever. For example the way Perl does type comparison is much more predictable then Python.

On the whole, I think those languages are about equal.

> reproducibility

CPAN was also light years ahead anything also available at the time. And still is in many regards. For example, Python environments is a mess. Perl is one of the most portable languages out there. Want to change the state of the runtime? Just add a line to the top of your source. Simple.

Python and JavaScript are a completely pain in the arse in comparison.

PHP is another example of a language that gets this right. Few people on here (myself included) will have much love for 2010’s PHP but it just goes to show that a lot of the languages “real programmers” praise do actually suck at a lot of the basic principles.

> measurability

Not really sure what this is intended to refer to. Maybe APMs? Either way, a lot of diagnostics like that came into vogue after Perl’s decline so this isn’t really the fault of the language but more just 3rd party tool writers putting their focus elsewhere.

That all said, don’t be fooled into thinking such tooling doesn’t exist for Perl.

> safety

Perl basically invented unit tests amongst the scripting languages. It also has stricter run modes to differentiate between one time scripts and important business code.

Saying Perl lacks safety demonstrates a lack of experience with the language.

——-

I’ve written production Perl, PHP, JavaScript, TypeScript, Python, C++, Go, Bash, Visual Basic and even Pascal. De-mangled other people’s spaghetti code in all of those languages too. Probably a few languages I’ve forgotten about too. Perl is one of those languages people love to hate but is, in my opinion, one of the most misunderstood.

[edit] I should have added a comment about Perl’s backwards compatibility. Few other languages even come close to the longevity of Perl 5. And that commitment extends down throughout Perl’s ecosystem. With JavaScript I’m constantly scared the next npm update will break the project.

Re:We were wizards – a foreword to Learning Perl by singingfish on Sunday March 17, 2024 @05:14AM (#39733028)
Back compat is an important thing. A few years ago we took a 250kline from perl 5.8.9 to perl 5.16 in one hit. Out of the entire application under 50 lines of application code needed to be changed (excepting the big bump in cpan module versions). Currently I'm slowly finalising the move from 5.16 to whatever debian stable is currently shipping 5.34 maybe? The biggest pain point is some type safety in the elastic search cpan module. Other than that I've had to slightly refactor some hacky but effective cache invalidation startup code due to a weird `perl -e` bug I found but can't characterise sufficiently precisely to report. The only reason that the perl latest upgrade wasn't done incrementally was because of a super weird unicode bug between perl and the oracle client library which is now out of scope for us.

But I agree perl can have bad management problems because of different people's capabilities, and different people's approach to showing their individuality.

Re:We were wizards – a foreword to Learning Perl by lloeki on Sunday March 17, 2024 @05:13AM (#39733023)
> safety

You forgot safe mode and tainting, which while imperfect and has some sharp edges, is a first class construct that when correctly wielded outright prevents classes of attacks like shell or SQL injections or XSS.

Some have been reinventing it in a piggybacked way, and so, partially/poorly (comparatively), e.g Rails's safe/unsafe strings in ActionView.

Re:We were wizards – a foreword to Learning Perl by alfiedotwtf on Sunday March 17, 2024 @05:06AM (#39732988)
>> safety > >Perl basically invented unit tests amongst the scripting languages. It also has stricter run modes to differentiate between one time scripts and important business code.

Don't forget Tainted Mode! It's 2024 and I still have never seen it adopted in any other language. It's essentially SELinux-lite for variables :)

IMHO Perl lost to Python because of 3 reasons: 1) Google at the time chose Python and it was the new cool startup everyone wanted to work at, 2) Pandas and Numpy weren't matched in the market (I'd even argue this is still true in 2024), and 3) Perl 6 was way too ambitious and scared people off (even though Perl 5 was never going to go away overnight (and still hasn't))

Re:We were wizards – a foreword to Learning Perl by HybridCurve on Sunday March 17, 2024 @05:52PM (#39738380)
Some of the arguments about Perl and bad engineering practice are not entirely without merit. Neglecting 'use strict;' or 'use warnings;' in your script typically makes this more apparent. The language itself however does not attempt to constrain developers in the same way modern languages do, instead the burden of responsible engineering is placed on the developer. The result is people that deal with badly engineered Perl typically become sour to the language itself.

I reserved my criticisms of Perl for things like signal handling and it's implementation OOP(to name a few), but overall it's a good language.