> Yes well, my point is if you want to make a piece of code
> incomprehensible, I don't think there is a language that will stop you.

indeed. but i now realize the counterpart is not true because everyone
has something different in mind when it comes to readability.

last example was yesterday: i wrote this in raku:

    my %final_pairs = @*ARGFILES.words.hash

i asked for code review for the python counterpart and we got:

    import sys

    def words():
        for s in sys.argv[1:]:
            with open(s) as fh:
                for l in fh.readlines():
                    for w in l.split(): yield(w)

    w = words()
    final_pairs = { k : v for k,v in zip(w,w) }

i don't need the perl version but it would something like:

    my %final_pairs =
        grep length,
        map { split /\S+/ }
        map { chomp; $_ }
        <>;

for me, readability score is: raku, perl, python but someone gives
arguments:

    * there is no reason a list could be considered as a hash by order
      of appearance
    * there is nothing more unreadable than implicity (split on what?
      what is $_?, <> iters on what?)

i strongly disagree but this is a valid opinion. i know that many
people struggle with side effects for example so $x++ is convenience for
the one of us that are used to iteration but it's hell for lot of
newcommers.

> It's a choice of the writer to write code that's hard to understand.
> Perl is a very expressive language, and can be used to write very clean
> and maintainable code.

that's it. and some of us hate expressivity because it means: learn how
the langage behave when it's preferable to describe the same patterns
again and again ...

> I think the "there's no right way" mantra helps: it allows you the
> latitude to choose the style that makes the most sense for the problem
> being solved.

yes ... but "it could be a default way because experience shown its
convenience or ability to solve the most common problem" (which is what
perl and raku do, i guess), is something that can be loved or hated.

regards
marc

Reply via email to