News for hackers. Stuff that matters.
Re:Why Perl? by worik on Thursday April 20, 2023 @06:14PM (#35647211)
> Sadly Perl has fallen on hard times. I think the Perl 6 debacle is mostly at fault.

I agree hard times. Hubris is at fault.

Perl did too much and reached for the stars. Its happy place was a sane job control language. A niche Python is filling.

I have used both, Perl extensively, Python when I must. Perl is much better, but being better is not enough.

Perl did "everything". Python was "object orientated". People wanted the shiny "object orientated" and, sadly wisely, did not want a language that could do anything and everything.

I blame Larry Wall, the genius, both for Perl's success, and Perl's failure. If only I could fail so brilliantly!

Re:Why Perl? by kstrauser on Thursday April 20, 2023 @06:37PM (#35647457)
Python ruined Perl for me. As soon as I convinced my self that pass-by-object-reference really was that simple, and I didn't have to deal with pass-by-sigil-maybe, I never looked back.

Write a Python function that writes an object's string representation to a file:

  def write(obj): open('/tmp/foo', 'w').write(str(obj))
Call it on an integer:

  write(123)
and it works. OK. But what if I want to call it on a list of strings?

  write(["spam", "eggs"])
That was too easy. I know - let's see if we can write a dict of tuples to sets of ints!

  write({(1,2):{3,4,5},('spam','eggs'):{6,7,8}})
That freaking worked? And I didn't have to change the function to accept a hashref? You just pass an object... and it passes the object?

At first, I thought I had to be missing something, like maybe it was impossible to do trickier things because they made the simple things so easy, but no. It just turned out that some of Perl's design decisions increased my cognitive load way more than strictly necessary. That's clearly not true for everyone, but it sure was for me. The first day I wrote Python was the last day I wrote Perl.

Re:Why Perl? by lanx on Sunday April 23, 2023 @01:59PM (#35678722)
Data::Dumper is included in core Perl ...

    use v5.12.0;
    use warnings;
    use autodie;
    use Data::Dumper;
    
    sub logit {
        open state $log, ">>", 'c:/tmp/foo'; # open *once* for *append*
        print $log Dumper(@_)
    }
    
    
    logit(123);
    
    logit(["spam", "eggs"]);
    

    logit({"(1,2)"=> [3,4,5],"('spam','eggs')"=> [6,7,8]});


    # logging multiple objects at once ...
    logit(
          123,
          ["spam", "eggs"],
          {"(1,2)"=> [3,4,5],"('spam','eggs')"=> [6,7,8]},
         );

NB: Perl has neither tuples nor sets, but there are workarounds
Re:Why Perl? by dale_glass on Thursday April 20, 2023 @06:32PM (#35647418)
> I agree hard times. Hubris is at fault.

I don't think it was so much hubris as bad communication.

Perl 6 was understood to be that: Perl 6, a definite successor to Perl 5. But besides being very, very late it turned out not to truly be Perl 6, but a new, incompatible, Perl-ish language.

I think the decision to rename it to Raku was a good one, but came too late. By then the world had already moved on.

Done early enough I think it'd have fixed things. It'd have created the clarity needed to understand that Perl 5 wasn't going away, and that it was pointless to wait for a successor.

Re:Why Perl? by BjoernKW on Friday April 21, 2023 @06:00AM (#35651688)
I suppose, the parent comment was referring the Three Virtues of a great programmer: https://thethreevirtues.com/

Bad communication isn't one of those (although, given the prevalence of bad communication in the industry, one might assume it is ...).

Re:Why Perl? by PaulDavisThe1st on Thursday April 20, 2023 @06:17PM (#35647260)
> Its happy place was a sane job control language

maybe that was your happy place for Perl, but it certainly wasn't mine or that of lot of Perl users I've known over the years.

  #!/bin/perlish
  while (<>) {
    /* regex match */
    /* do some stuff, with variables or the file system or whatever */
  }
Awk theoretically is a close match for this basic structure, but Perl is closer, most of the time.
Re:Why Perl? by worik on Thursday April 20, 2023 @06:33PM (#35647429)
Yes.

I mispoke. "A happy place" I shold have said

I never learnt awk or sed bedcause I knew Perl.

That loop, often in a command line invocation `perl -e 'while(<>){chomp;......}'`

My point is its happy place was not application programming, gui systems. AS I commented elsewhere here processing every Apache hook.

Pythin suffers the same problem. It too is brilliant at the little jobs, yet there are many GUI junk piles written in it, just as happened with Perl back in the day

Re:Why Perl? by wazoox on Friday April 21, 2023 @07:18AM (#35652167)
Perl offer auto looping : perl -n or perl -p. Typically one-liners are `perl -n -e 's/foo/bar/g'` or similar.
Re:Why Perl? by antisthenes on Thursday April 20, 2023 @06:21PM (#35647320)
> Perl did too much and reached for the stars. Its happy place was a sane job control language. A niche Python is filling.

> I have used both, Perl extensively, Python when I must. Perl is much better, but being better is not enough.

> Perl did "everything". Python was "object orientated". People wanted the shiny "object orientated" and, sadly wisely, did not want a language that could do anything and everything.

I don't know what kind of Python you've tried using, but it seems you got some defective ancient 2.x version. Python is exactly the kind of language that should be replacing Perl, simply because it's the best glue language out there right now, with modules that are actively being maintained and developed.

And, as a cherry on top, actually has human-readable syntax.

Re:Why Perl? by worik on Thursday April 20, 2023 @06:35PM (#35647435)
> Python is exactly the kind of language that should be replacing Perl, simply because it's the best glue language

When tabs and spaces have different syntactic meaning, I am suffering quite a bit of revulsion.

I have to do it, but I want to control my own white space for my own purposes.

It comes down to taste, I guess. I am not wrong, but neither am I correct