Live data from Hacker News

Half My Life with Perl

perladvent.org

131–139 of 139 posts

Re: Half My Life with Perl

#131
post #124

Earlier quoted context omitted.

OO is the part of Perl that I grok the least. What about it makes it "far advanced" compared to, say, Java or C++ versions of OO?

https://metacpan.org/pod/Moose Moose is definitely what I go for when I have to use OO with Perl, this more than a decade old and stable for production use cases. Its based on Class::MOP, which is in turn based on Meta Object Protocol, the same concepts on which CLOS(Common Lisp Object System) is based on. Its always nice to have CLOS goodness in Perl. For eg- https://metacpan.org/dist/Moose/view/lib/Moose/Manual/Met…

The key idea in CLOS is multi method dispatch, which Moose does not provide.

Moose out of the box has its own set of problems, leading to other workarounds, e.g.

Moo (a similar but much less bloated solution)

MooseX::Extended - Moose with more sensible/correct defaults

https://metacpan.org/dist/MooseX-Extended/view/lib/MooseX/Ex...

Re: Half My Life with Perl

#132
post #129
post #122

Earlier quoted context omitted.

>>Remove regexes from perl, what’s left? qw, qr, references, multiline regexes, a far advanced OO ecosystem, Data::Dumper, map, grep, pack/unpack, DBM, ``, top class unicode handling, given/when, functional programming etc etc. In fact I've barely scratched the surface. You must grok Perl more.

given/when are deprecated and will be removed in a future release. References are a PITA - cumbersome to use, and they make code less readable. Perl doesn't have first class functions (you can pass or return functions via references, but that's cumbersome and less readable compared to languages with better FP support).

>>given/when are deprecated and will be removed in a future release.

given/when won't be removed, too much back wards compatibility issues.

>>References are a PITA - cumbersome to use, and they make code less readable.

Depends what you mean readable though. In python you can't tell whats a variable and whats a list, and whats a dictionary by looking. One can claim whole language is unreadable since variables are needed at every step.

>>but that's cumbersome and less readable compared to languages with better FP support

Sure let them add all the other practical goodness of Perl, then we can use them.

Re: Half My Life with Perl

#135
post #132
post #129

Earlier quoted context omitted.

given/when are deprecated and will be removed in a future release. References are a PITA - cumbersome to use, and they make code less readable. Perl doesn't have first class functions (you can pass or return functions via references, but that's cumbersome and less readable compared to languages with better FP support).

>>given/when are deprecated and will be removed in a future release. given/when won't be removed, too much back wards compatibility issues. >>References are a PITA - cumbersome to use, and they make code less readable. Depends what you mean readable though. In python you can't tell whats a variable and whats a list, and whats a dictionary by looking. One can claim whole language is unreadable since variables are need…

Consider

    % perl -v | head -2

    This is perl 5, version 40, subversion 0 (v5.40.0) built for x86_64-linux
    % 
    % perl -E 'use feature "switch"; my ($x, $y); given ($x) { $y = 1 when /^abc/ }'
    given is deprecated at -e line 1.
    when is deprecated at -e line 1.
This is also mentioned in the docs:

  Smartmatch is now seen as a failed experiment and was marked as deprecated in Perl 5.37.10. 
  This includes the when and given keywords, as well as the smartmatch operator ~~. 
  The feature will be removed entirely in the Perl 5.42.0 production release.
https://perldoc.perl.org/perldeprecation#Smartmatch

>> In python you can't tell whats a variable and whats a list, and whats a dictionary by looking.

In Perl, sigils are used to distinguish between scalars/lists/hashes. Sigils and references are not the same thing.

https://www.perl.com/article/on-sigils

https://perldoc.perl.org/perlreftut

Re: Half My Life with Perl

#136
post #12

Earlier quoted context omitted.

>>In the real world, the ability of a lone genius to cobble together a script in an hour is actually not that much of an edge Any macro/multiplier is that way. You don't miss it, until some one shows you how to do it. In the last six months alone the scenarios where I had to call upon Perl to help slam dunk a thing insanely laborious are dozens in number. Its just that if you don't know this, or don't know it exists,…

You are missing my point. For transparency, you are talking to someone who writes Racket in emacs on my Linux desktop, has used Rust macros to clean up awful code in widely used open source packages, and regularly generates code for all manner of purposes in lots of different languages. I know the slam dunk feeling of generating exactly the code that will topple a problem -- and I also know it's not actually that big…

I personally believe there are 2 types of Perl - development which you’re talking about here, and sysadmin/devops.

For the first category you’re right - these days there’s not much difference between Perl vs Java vs Rust because abstractions are the same.

But where OP’s smugness comes from I totally agree when applied to the second category - there’s an ocean of a difference between using tools like Perl, awk, sed, jq, and bash to transform Unix command inputs and outputs that it really is a massive superpower. Try doing a day’s work of a Unix admin using these tips compared to writing Java to do it. Oceans I say!

But I don’t think their being a basement dweller genius as you put it is because of Perl - it’s the smugness for the same reason why BOFH Unix sysadmin got their reputation - their tools are literal superpowers compared to GUI tools etc and they can’t believe everyone doesn’t use them!

Re: Half My Life with Perl

#137

Earlier quoted context omitted.

Inline::C did a good job of reducing the barrier to entry for C code.

True but I don't remember it being nearly as convenient to distribute those modules as it still required the whole build environment on the target and you still had to deal with perls exceptionally efficient but ancient and cumbersome object and type system. XS wasn't _that_ bad once you got the hang of it; anyways, but I do remember ruby 1.6 coming out and being blown away by how improved the experience of creating…

Inline:: was a world of a difference! I was so intimidated at the time with XS but Inline:: was almost magical.

Also, same as you though - happy to see Randal’s name pop up here :)

Re: Half My Life with Perl

#138

Any good reasons not to build web apps and API backends with Perl these days?

I do. I've worked with other languages over the years but I always come back to Perl. There's a few good options for web apps/APIs. Web frameworks: https://www.dancer.pm https://mojolicious.org http://catalyst.perl.org https://metacpan.org/pod/Kelp https://metacpan.org/pod/Net::API::REST Middleware: https://plackperl.org https://github.com/miyagawa/Starman Some other useful stuff... OO Frameworks: https://zydeco.toby…

Excellent comment, can’t wait to give this a look and start playing around.

Re: Half My Life with Perl

#139

Earlier quoted context omitted.

You are missing my point. For transparency, you are talking to someone who writes Racket in emacs on my Linux desktop, has used Rust macros to clean up awful code in widely used open source packages, and regularly generates code for all manner of purposes in lots of different languages. I know the slam dunk feeling of generating exactly the code that will topple a problem -- and I also know it's not actually that big…

I personally believe there are 2 types of Perl - development which you’re talking about here, and sysadmin/devops. For the first category you’re right - these days there’s not much difference between Perl vs Java vs Rust because abstractions are the same. But where OP’s smugness comes from I totally agree when applied to the second category - there’s an ocean of a difference between using tools like Perl, awk, sed, j…

I use nearly of these tools with the exception of Perl. I go to great lengths to make sure I have access to them because it's so critical for quality of life. I love them and I understand why people love them.

Here's the reason: these languages/tools are tactically very powerful. Tactics are immediate and decisive. Tactics are effectively tricks in the sense that if you can "spot the trick", you can -- with a tiny amount of work -- reduce a formidable problem to virtually nothing. Having a vast toolkit that facilitates such tricks is incredibly powerful and makes you appear to have superpowers to colleagues who aren't familiar with them.

But tactics are definitionally short-term. You deploy them in the weeds, or at least from the forest, (hopefully) never from the skies. Tactics aren't concerned with the long term, nor how things fit together structurally. They are not concerned with maintainability or architecture.

This is why it isn't actually that important that you can cobble together a 15 line Perl script in an hour to do something that would take any of your colleagues a week. Years from now, when you are gone and someone runs into a similar but slightly different problem, someone will find your Perl script, not understand it, and rewrite it all in Java anyway. Or assume it's too hard and give up. Maybe they will adapt your Perl script, but more likely it'll be seen as a curiosity

It sucks, because there is beauty in that approach of solving problems. As I said in another comment, I wish there were more diversity in tooling and languages. But at the same time, it's important to consider that people are fundamental. All of this is in service to that. And I personally would rather build software that people use over the long term.

Post reply on HN