Beefy Boxes and Bandwidth Generously Provided by pair Networks
There's more than one way to do things

Comment on

( #3333=superdoc: print w/replies, xml ) Need Help??

Perl is not an OO language; it's a multi-paradigm language giving you the flexibility to mix OO code with other styles of programming.

Whatsmore, Perl's OO system allows you far more power and flexibility for OO code than Java or Java-inspired OO systems (PHP's is Java-inspired). And projects like Moose allow you to take advantage of that power without tearing your hair out!

Java's version of OO is very limited. It's single-inheritance, class-based OO. Many Java developers seem to believe that's the only true form of OO. Some will acknowledge that multiple inheritance is occasionally useful, but that it can also introduce problems (e.g. diamond inheritance). Few are aware that other entirely non-class-based forms of OO are also possible, such as aspect-oriented, role-oriented and prototype-based OO.

Here's an example in Perl (with Moose) using both classes and roles to take a plain old instance of the Person class and install a new method for that object only (not the entire Person class).

use v5.14; package Person 1.0 { use Moose; has name => (is => 'ro'); }; my $alice = Person->new(name => 'Alice'); my $bob = Person->new(name => 'Bob'); # Teach Bob to sing! Moose::Util::ensure_all_roles( $bob, Moose::Meta::Role->create_anon_role( methods => { sing => sub { say "lalala" } }, ) ); foreach my $person ($alice, $bob) { say $person->name, " can you please sing?"; if ($person->can('sing')) { $person->sing; } else { say $person->name, " cannot sing!"; } }

So even if Perl isn't an "OO language", it provides an arguably better and more complete OO programming environment than Java.

Also, while other languages may "have" regular expressions, these are generally just "match" and "replace" type functions which can be passed a regular expression and a string. In Perl, they're an integral part of the language...

use v5.10; my $count = 0; my $var = "foo <> foo <> foo"; $var =~ s ( fo{2} ) { ++$count; }gex; say $var;

Whatsmore, regular expressions in Perl are far more powerful. (More powerful even than those languages that provide the "Perl-compatible" regexp engine - this regexp library was compatible with a very old version of Perl; Perl's improved since then.)

Lastly, I'd say you undervalued CPAN. It's not just a repository of libraries; there's the whole infrastructure that goes with it:

  • CPAN Testers which provides a testing service for everything on CPAN on a variety of different platforms. They'll even test your code for free if you open-source it and upload it to CPAN.

  • The CPAN admins, whose existence ensures that should a module ever be orphaned by its developer, if there's a willing volunteer to take it over, they'll be given permission to do so.

  • The various CPAN websites (e.g. which make all the documentation on CPAN browsable and searchable, and link to reviews, issue trackers, etc.

  • The various CPAN installation tools that handle dependency resolution in a manner that rivals apt-get, etc.

perl -E'sub Monkey::do{say$_,for@_,do{($monkey=[caller(0)]->[3])=~s{::}{ }and$monkey}}"Monkey say"->Monkey::do'

In reply to Re: Argument for Perl ( again and again ) by tobyink
in thread Argument for Perl ( again and again ) by heatblazer

Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post; it's "PerlMonks-approved HTML":

  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.
  • Log In?

    What's my password?
    Create A New User
    and all is quiet...

    How do I use this? | Other CB clients
    Other Users?
    Others scrutinizing the Monastery: (6)
    As of 2018-05-23 22:56 GMT
    Find Nodes?
      Voting Booth?