> Not sure about anyone else, but comparing the Python vs Perl example you
> gave above, I would still say Python is the nicer-looking language.

i was just saying that there is no need for yield in perl. now i can
show you tons of examples to demonstrate perl code is not only
more "unixish" but easier to:

* write
* read
* modularize (__init__.py always made me smile)

when you have to manipulate text files or large datastructures, python
is far behind perl. i won't try to convince you but to illustrate what
is said before.  see this code:

use v5.20;

while (<>) {
    chomp;
    # trim and print lines only when not empty
    say s/
        ^ \s+    # triml
        | \s+ $  # trimr
    //rx if /\S/;
}

this is *hell* for a unix newbie:

* regexps is a concept that windows programmers (so python ones too)
  try to avoid (pretending it's hard to understand and read)
* ARGV ... what is a "filter" anyway? i don't want to read about
  the unix litterature to write my code.

to be fair: if you just write a web application or a datascience script
were datasources are from binary formats or databases and libraries are
available, you just don't need those tools and run away is probably
the good strategy (python *is* indeed easier to learn when you have
simple things to code). if you believe in text streams and simple formats
in a unix land (which i do), or if you need to solve complex problems,
learn those concepts and be familiar with them is worth it.

another "line noise" bullshit comes from sigils and i have to admit
i though sigils made my script looks "not professional" when i was
younger (having a php background). But when you understand the way
sigils works, it appears that it is very informative and useful:

* they always give clues about the structures you're working with
* they permit some very useful shortcuts

as example: hash slices is something i always miss in python.

    use v5.20;
    my %user;
    my @names = qw( uid gecos home shell );
    my @cols  = qw( 0   3     5    6     );

    @user{@names} = map
        { chomp; (split /:/)[@cols] }
        `getent passwd mc`;

    printf '%s is the default shell for %s'
    , @user{qw( uid shell )};

sure, python is evolving in the good direction (see PEPs 448, 449, 572 ...)
but so many things are missing to be confortable comparing to perl
(sometimes little ones but so convenient). some examples that comes to
my mind:

the quoting system

    # qw( for a list of barewords )
    my %user = qw(
        login  mc
        shell  /bin/zsh
    );
    print $user{login};

    # q() and qq() to replace '' and "" when it's complicated
    my $comment = qq{
        with qq() you can choose your delimiter like in sed
        so you can't get it wrong or unreadable
        even if you have """""" in mind
    }

yada to spot an unimplemented section
(https://perldoc.perl.org/perlsyn.html#The-Ellipsis-Statement)),
the //g modifier with the \G anchor (so you can iterate in a string with regexp 
matching), ...

so many other ones. and python people don't get those are
very useful features. when i asked for fair help, the
anwsers were often flooded in tons of messages like:

* you don't need this
* you shouldn't program with this
* perl is dead

So even the community is anoying and i don't want
this logo++ to be unfairly compared to perl anymore
but as i said: i don't want to reboot a 2 decades sterile
feed:

* since 3.4 python became bearable (so much saner than php or js)
  and a good tool for teaching OO.
* both python and perl are langages from the last millenium with
  lot of issues that are fixed in raku. so that's the spot i switched to.

cheers
marc

Reply via email to