Live data from Hacker News

Perl, the first postmodern computer language (1999)

wall.org

221–225 of 225 posts

Re: Perl, the first postmodern computer language (1999)

#221
post #217

Earlier quoted context omitted.

Python never succeeded in scripting. Shell still dominates scripting today. Perl is rooted in scripting.

Where do you think Python has failed as a scripting language? I'm not very familiar with Perl, but overall I can't think of any obvious advantages aside from some of the syntactic sugar around invoking shell commands and string matching. I can see stability as a knock against Python, but outside of 2 vs 3 the only breaking changes I've really had to deal with were relatively short term issues with third party libs.

Perl started with scripting, so many design philosophy are centered around scripting. Python, I think, is started with the goal of building applications. My first impression when I learned Python (around 2000) was the OOP nature of Python. Building classes and objects were least in my mind when scripting.

A few examples:

Perl (flexible/optional function call interface)

    print "hello world\n";
Python (the insistence of function call parenthesis)

    print("hello world")
Perl (direct string substitution thanks to sigils)

    print "Hello $name\n";
Python (a few formats, keep searching for the perfect ones)

    print("Hello %s\n" % name);
Perl (a core set of shell like patterns)

    if (!-d $dir) {
        mkdir $dir;
    }
    chdir $dir;
    foreach my $f (glob("*.txt")) {
        ...
    }
Python

    import os
    import glob
    # google for usages
Perl (good lexical scopes)

    if ($do_A) {
        my $x = "A";
        work_with($x);
    } else {
        my $x = "B";
        work_with($b);
    }
Python

    if do_A:
        x = "something" # did I changed x for somewhere else?
        ...
Perl (a set of defaults balacing the succinctness and readability)

    my %opts;
    while () {
        if (/(\w+):\s*(.+)/) {
            $opts{$1} = $2;
        }
    }
Python

    import ...
    ...
        m = re.match(r'...', line, re_flags)
        if m:
             opts[m.group(1)] = m.group(2)

Perl's philosophy is "There is more than one way to do it", pick the way that makes most sense to you.

Python's philosophy is "There should be one-- and preferably only one --obvious way to do it", but obviousness is subjective to some, and for the rest, you need learn/search/train the "one" way.

Re: Perl, the first postmodern computer language (1999)

#222
post #216
post #6

Earlier quoted context omitted.

Please don't post links to pirated content.

Stop pushing your own moral values onto others.

I don't know about you, but many of us on HN make our livings with things protected by copyright, trademark, and sometimes patents. Supporting the framework that enables our livelihoods is not a moral judgment. It is a practical concern.

Also, there are legal issues over promotion of pirated content.

Also, there are ethical concerns over pirating content that is easily and cheaply available legally.

Also, I said "Please" and didn't force anything on anyone.

Also, under a strict interpretation posting directly to pirated material is likely a violation of the Terms of Use for HN. https://www.ycombinator.com/legal/#tou

Re: Perl, the first postmodern computer language (1999)

#223
post #216

Earlier quoted context omitted.

Stop pushing your own moral values onto others.

I don't know about you, but many of us on HN make our livings with things protected by copyright, trademark, and sometimes patents. Supporting the framework that enables our livelihoods is not a moral judgment. It is a practical concern. Also, there are legal issues over promotion of pirated content. Also, there are ethical concerns over pirating content that is easily and cheaply available legally. Also, I said "Ple…

I said stop pushing, not stop forcing. And I didn't post pirated material I asked you to stop moralizing.

Re: Perl, the first postmodern computer language (1999)

#224
post #217

Earlier quoted context omitted.

Where do you think Python has failed as a scripting language? I'm not very familiar with Perl, but overall I can't think of any obvious advantages aside from some of the syntactic sugar around invoking shell commands and string matching. I can see stability as a knock against Python, but outside of 2 vs 3 the only breaking changes I've really had to deal with were relatively short term issues with third party libs.

Perl started with scripting, so many design philosophy are centered around scripting. Python, I think, is started with the goal of building applications. My first impression when I learned Python (around 2000) was the OOP nature of Python. Building classes and objects were least in my mind when scripting. A few examples: Perl (flexible/optional function call interface) print "hello world\n"; Python (the insistence of…

I think this is really just a factor of what you're used to, because none of those Python examples seem like an issue to me, and the Perl examples seem much harder to parse. I personally prefer print as a function rather than a statement, and keeping most standard lib functionality in modules seems like the right choice for anything other than a DSL.

I agree scope leakage is a major stumbling block with Python for sure, but it only occurs with control-flow so rarely causes actual issues once you're aware of it. Aside from that my biggest qualms with Python are the typesystem and whitespace for scoping, but those two don't cause much trouble for typical scripting purposes.

And, for what it's worth, Python's f-strings have been the go-to string formatting approach since 2016 so your example becomes something like:

  print(f"Hello {name}")
Which is doubly nice because you can also use format specifiers and arbitrary expressions like so:

  >>> f"The current year is {datetime.now().year} and the value of pi is approximately: {22/7:.2f}"
  'The current year is 2022 and the value of pi is approximately: 3.14'

Re: Perl, the first postmodern computer language (1999)

#225
post #195

Earlier quoted context omitted.

> Bad Python looks like good python. Never used Perl, so I can't really make an honest comparison. I do use Python at work, though, and I can assure you that is FAR from being true. In fact, I think this is so untrue that I urge you to check out essentially any code written in academia (especially projects involving numeric computation and data science). If you come back and make that same statement with a straight f…

I have had colleagues (in academia) asking me to correct their unindented (or very badly indented code) in Perl. You couldn't actually do that ion Python.

https://metacpan.org/pod/Perl::Tidy is your friend. Think Black from Python land but far more powerful.
Post reply on HN