Live data from Hacker News

Not Your Grandfather’s Perl

stackoverflow.blog

101–110 of 257 posts

Re: Not Your Grandfather’s Perl

#101
post #75

I've used Perl off and on throughout my career, even working at one job that was pretty much exclusively Perl. I've also used Java and C/C++. I've done a lot of work with embedded systems where C was the order of the day. But back to Perl. I always thought one of the best things about Perl was CPAN. I could nearly always find a module that would accomplish a specific task I needed and then I was just left to write th…

CPAN was definitely the envy of other languages for many years but I feel most have caught up by now.

Re: Not Your Grandfather’s Perl

#102

Earlier quoted context omitted.

> What I do appreciate that's missing from many other languages and systems is the extreme committment to backwards compatibility. The knowledge that the next minor release won't break existing scripts is underrated, IMO. I don't write much Perl these days and haven't for some time, but it's still what I might reach for if I were tasked with writing something suitable for a scripting language that had to run with ~0…

Perl needs backwards compatibility given the `write once, read never` nature of the syntax. Imagine trying to upgrade this to some new syntax... https://github.com/schwern/AAAAAAA

See also Acme::Bleach:

https://metacpan.org/pod/Acme::Bleach>

Re: Not Your Grandfather’s Perl

#105
post #16
post #13

"Bare bones" seems to be a good thing for Perl. I use Strawberry Perl on Windows and it is orders of magnitude faster than Powershell for processing large files of text strings using regular expressions. I hope the addition of a "new object-oriented programming framework" won't take away the "bare-bones" speed of the current release.

Perl's bindings for Win32 and OLE are amazing.

Really? This is interesting! I had completely written off Perl for Windows due to its heritage. But we still use COM objects in our scripts here and while I like PowerShell conceptually, I really never got to have fun with it as a scripting language. It just has so many quirks like “implicit returns” etc. and is just so verbose it’s bordering on hard to read at times.

Re: Not Your Grandfather’s Perl

#106
post #104

Perl receives such an unnecessary amount of hate

Those who've had to maintain someone else's perl tend to find that the hate is, if not strictly necessary, very much warranted.

apparently also some of those that have to edit their own code they have not touched for a year.

Re: Not Your Grandfather’s Perl

#107
post #35

Earlier quoted context omitted.

I’ve had very limited contact with Perl, but for scripting purposes it does seem like the best option, so I intend to sit down to it and learn it better. It looks like a great next step after sed and awk (perl -pe). I love the ability to write terse scripts, reasonable speed for a scripting language and, as you said, backwards-compatibility (such a stark contrast compared to Python).

I would argue that ruby as almost all the strengths of perl and conciseness with more coherency if you want a perl-like fluidity and terseness. I personally like python for anything that becomes more than a 100 lines of bash.

For that, there is Next Generation Shell. Also works like a charm even before 100 lines. For example when structured data is needed. Some other advantages over bash are error handling, automatic command line arguments parsing (similar to Raku, btw), standard library with functions like warn(), log(), debug(), retry(), etc that you have likely implemented hundreds of times in your bash scripts.

Disclosure: I'm the author.

Re: Not Your Grandfather’s Perl

#108

Earlier quoted context omitted.

Signatures were added in 5.020, and [edited:] were considered experimental until 5.036.

are Perl function signatures the PHP/Python equivalent of type hints?

This may shock you, but: historically, Perl functions did not have declared arguments. Like, at all. The function just got arguments implicitly passed to it as an array (@_), and parsing that into individual variables was up to the function -- so most functions would start like this:

    sub myFunction {
        my ($self, $arg1, $arg2) = @_;
        ...
    }
Or, in older code, you might even see this:

    sub myFunction {
        my $self = shift; # implicitly get the first value from @_
        my $arg1 = shift;
        my $arg2 = shift;
        ...
    }
Notably, this didn't even check the number of arguments you passed. If you passed too many or too few arguments to a function which worked this way, the extra arguments would silently be ignored, or missing arguments would silently show up as undef.

Function signatures turn this into something that'll look much more familiar to users of other languages:

    sub myFunction ($self, $arg1, $arg2) {
        ...
    }
which includes checks to make sure that all the expected arguments (and no more) were passed.

Re: Not Your Grandfather’s Perl

#109
I skimmed the article looking for a mention of a REPL or a new debugger. Perl is a great language but it lacks these tools. Sometimes I just want to try a couple of lines of Perl code in a REPL, but I cannot. Instead, I need to create a file. Also, when debugging with `perl -d`, I cannot use the Up arrow key to get the previous command. Not a big deal but the coding experience will be significantly improved with those tools.

Re: Not Your Grandfather’s Perl

#110
post #104

Perl receives such an unnecessary amount of hate

Those who've had to maintain someone else's perl tend to find that the hate is, if not strictly necessary, very much warranted.

I see this for every language, every project - and across domains.

Every new Dev says the previous code is shite. Odd that the plumber and electrician do it too.

It's as if nobody can produce good work except for $ME at $NOW

Post reply on HN