Beefy Boxes and Bandwidth Generously Provided by pair Networks
good chemistry is complicated,
and a little bit messy -LW
 
PerlMonks  

Re^2: What if Perl had an OO standard library?

by awncorp (Acolyte)
on Aug 24, 2022 at 03:51 UTC ( [id://11146352]=note: print w/replies, xml ) Need Help??


in reply to Re: What if Perl had an OO standard library?
in thread What if Perl had an OO standard library?

I'm very tempted to agree with you "wholesale" given that I've been doing Perl since the mid-late 90s and through many many many bouts of trial and error have learned how to write well-reasoned succinct very Perlish code. However, I recognize that I'm only able to do so because of the amount of time I put into learning the language, and all of my failures along the way.

People (other than us) needing to use Perl, who may not have the time or interest in learning "the ways of the force", who may be coming from other (typically OO) languages, would be much more comfortable in Perl if they could find corollaries to the idioms they already know.

Some examples:

In JavaScript:

['a', 'b', 'c'].forEach(item => console.log(item.toUpperCase()));

In Ruby:

['a', 'b', 'c'].each(|item| puts item.upcase);

In Perl:

print uc("$_"), "\n" for ('a', 'b', 'c');

In Venus:

Venus::Array->new(['a', 'b', 'c'])->call('map', 'say', 'uppercase');

In Venus:

Venus::Array->new(['a', 'b', 'c'])->map(sub{ print uc $_, "\n" })

Replies are listed 'Best First'.
Re^3: What if Perl had an OO standard library?
by hippo (Archbishop) on Aug 24, 2022 at 08:30 UTC

    Your examples here just reinforce my general opinion that full-OO languages where everything is an object are just overly verbose when it comes to simple operations. By eschewing this and having intrinsic non-object types we (in Perl and in other languages which do the same) can write much cleaner and therefore maintainable code.

    The contrast is slightly hidden by an overly verbose Perl entry. I think in most cases I would be using

    say uc for 'a', 'b', 'c';

    or perhaps with qw/a b c/ instead.


    🦛

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://11146352]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others cooling their heels in the Monastery: (2)
As of 2025-07-16 02:09 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found

    Notices?
    erzuuliAnonymous Monks are no longer allowed to use Super Search, due to an excessive use of this resource by robots.