Live data from Hacker News

Not Your Grandfather’s Perl

stackoverflow.blog

31–40 of 257 posts

Re: Not Your Grandfather’s Perl

#31
Maybe I’m missing the point of this piece, but it’s probably because I’m still reeling from the author’s idea that adding “say()” which is “print()” with a newline added, is somehow an improvement to the language.

Re: Not Your Grandfather’s Perl

#32

With function signatures and state variables added in 5.010, I consider Perl feature-complete and have not really missed anything from it for as long as I've been writing Perl. 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. Solo project with ~23K…

While it's not my favorite language. I have to admit that function signatures go a long way towards making perl feel somewhat normal to work with. I have to imagine they are pretty big boons for IDEs.

Re: Not Your Grandfather’s Perl

#33
post #19
post #3

Even on modern hardware with vectorization, the speed of perl is hard to match for stream processing. I write and deploy brand new perl code in 2022 to replace some clunky python and javascript - for real! AMA!

When you refer to modern hardware with vectorization, are you saying perl beats software that makes use of vector instructions? If so wow! Afaik perl is a plain old interpreted language with no JIT, what makes it so fast? I had an idea of perl as in the same performance category as Python, Ruby and friends.

Perl likely spends a lot more time in C than a lot of other bytecode-compiled languages like Python.

  while() {
   print $_;
  }
isn't doing much of its work at the top level.

Re: Not Your Grandfather’s Perl

#34

With function signatures and state variables added in 5.010, I consider Perl feature-complete and have not really missed anything from it for as long as I've been writing Perl. 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. Solo project with ~23K…

> 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

Re: Not Your Grandfather’s Perl

#35

With function signatures and state variables added in 5.010, I consider Perl feature-complete and have not really missed anything from it for as long as I've been writing Perl. 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. Solo project with ~23K…

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).

Re: Not Your Grandfather’s Perl

#36
post #19
post #3

Even on modern hardware with vectorization, the speed of perl is hard to match for stream processing. I write and deploy brand new perl code in 2022 to replace some clunky python and javascript - for real! AMA!

When you refer to modern hardware with vectorization, are you saying perl beats software that makes use of vector instructions? If so wow! Afaik perl is a plain old interpreted language with no JIT, what makes it so fast? I had an idea of perl as in the same performance category as Python, Ruby and friends.

My assumption (and I could be wrong) is that whenever you do something that's ultimately CPU intense, perl dives into C code. The sort of stuff you do with perl tends to be a lot of string manipulation and it turns out perl is pretty hyper optimized for that sort of workload.

Other languages could do the same, but often they have a few more layers before they start running that C code.

I'd be curious to know if the perl grammar also somehow lends itself to being fairly optimizable for it's interpreter.

Re: Not Your Grandfather’s Perl

#37
post #31

Maybe I’m missing the point of this piece, but it’s probably because I’m still reeling from the author’s idea that adding “say()” which is “print()” with a newline added, is somehow an improvement to the language.

The point is not about `say` itself (which has been there since Perl 5.10, released on 2007/12/18), it's only an example of how much Perl uses modularity (via `use`) to enable new features while ensuring a) code dependent on a new feature alerts on Perl versions without the feature and b) backward compatibility of new Perl versions with old Perl code.

Compare:

    # Perl
    use feature 'say'
vs:

    # Python
    from __future__ import print_function
Which at first blush follow the same principle, except that Python decides that `from __future__` is a vision into upcoming doom, that is a future version of Python for which code that preexists becomes incompatible unless it is ported to the new version.

IOW py2 code doesn't run on py3, barking at you in obscure ways if you try, and py3 code doesn't run on py2, barking at you in obscure ways if you try. (or worse, partially runs and either explodes in mid flight or silently corrupts data).

Whereas Perl code written targeting vX runs on Perl vY as long as Y >= X, and if Y

    $ perl5.18 sig.pl
    Feature "signatures" is not supported by Perl 5.18.4 at sig.pl line 1.
    BEGIN failed--compilation aborted at sig.pl line 1.
(yes yes I am aware that with enough effort and trickery you could write code that works on both py2 and py3. I did that a long time ago; it's a pain, and doesn't solve the problem of preexisting code)

And not just that, Perl alters its parser behaviour live (and scoped to the module!) so remove `'signatures'` from `use` and you get:

    $ perl5.30 sig.pl
    Malformed prototype for main::my_subroutine: $foo, $bar, $baz = 'fury' at sig.pl line 7.
But leave it in and there's no parse error. No magic preprocessed comments or fake code trickery like JS (which has a commitment to backwards compatibility as well) has to do[0]:

To invoke strict mode for an entire script, put the exact statement `"use strict";` (or `'use strict';`) before any other statements.

(They had to make it a string in void context instead of a comment because comments are removed by JS obfuscators, but it's essentially a magic comment/preprocessor directive)

[0]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Refe...

Re: Not Your Grandfather’s Perl

#38
post #23
post #14

Earlier quoted context omitted.

I'm working in Windows (employer's choice) and need to process some huge data files on the desktop. Perl (Strawberry Perl for Windows) is much faster than native Powershell (or CMD) scripts. A few Perl one-liners and I have 2 GB processed in a couple of minutes. Big fan of Perl here.

> A few Perl one-liners and I have 2 GB processed in a couple of minutes. This matches my experience: my task is IO bound, processing tens of GB in a matter of minutes. > I'm working in Windows (employer's choice) Work prefers MacOS, Windows is my personal choice :) Windows 10 and 11 are a pleasure to use: between the Windows Terminal and tools like AutoHotKey, there's no Linux equivalent, even for a commandline geek…

Full disclosure: Work has been Windows centric, but I recently moved to a new group with some Mac users. I'll have that choice, next time I swap hardware, but probably will stay with Windows because

* Would miss too many amazingly useful utilities like arsclip.

* Easier to patch into my home network, which is NTFS-based.

* Employer is now wedded to Microsoft and Azure, so having Powershell and native access to NTFS AD on my native desktop is proving more useful.

* I actually like the Windows interface, even with the Control Panel and other system utilities caught in a weird split between Windows XP and WIndows 10 UIs.

* Some things, like certificate management and hosting a personal database, I do in Ubuntu or Debian as a VirtualBox guest under Windows.

* Wife uses Windows on her laptop. She doesn't know it, but it's actually running as a VM on Debian, very stable, and can easily take her Windows to a new machine.

* [I keep coming back to add items to this list] Remote Desktop Services have improved vastly, and I can manage remote servers or 12 year old client machines at a remote site with equal ease. (XP/7-era machines got a second life when I converted Windows OS disk to SSD). Also find screen sharing via 3rd party VNC (TightVNC) useful.

* The keystrokes have become second-nature. Try as I might, I can never get fully comfortable on a Mac OS desktop. Now get off my lawn.

Re: Not Your Grandfather’s Perl

#40

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

That looks more like write-only naming... but the syntax itself isn't bad at all.

Here's the main module: https://github.com/schwern/AAAAAAA/blob/aaaaaa/aaa/AAAAAAAAA...

Post reply on HN