http://qs1969.pair.com?node_id=1161280


in reply to Bullish on Moose, how about you?

Opinions here vary somewhat widely—you can find love letters and haters comingled— but Moose is largely appreciated. I prefer Moo because I like its syntax a little better, it's quite a bit faster (for command line especially), and I have, rarely, maybe never, needed the intense levels of class control, generation, introspection and such that set Moose apart.

I encourage you to explore some side-cars like Type::Tiny.

Replies are listed 'Best First'.
Re^2: Bullish on Moose, how about you?
by Athanasius (Archbishop) on Apr 23, 2016 at 07:36 UTC
Re^2: Bullish on Moose, how about you?
by stevieb (Canon) on Apr 22, 2016 at 23:22 UTC

    I'm hoping Monks will post some tiny snips of code that shows *how* these modules save time and effort. It's one thing to go read the documentation, but another if code-compare examples are presented.

    I like the sound of things like Type::Tiny

      The main reasons I like/use Moo, etc, are to share behavior in a larger application (like a Catalyst application where the model is needed by the controllers, the tests, and the command line) and to wrap up, normalize, and auto-document, complex behaviors of conjoined simple parts that would otherwise quickly become spaghetti; make things like push and @{$object->{bunch_of_data}} semantic, less dense. This web spider stub is off the top of my head so take it as a terse draft but it shows the kinds of things I like to do–

      package MooSpider; use Moo; use MooX::HandlesVia; use Carp; our $VERSION = "42"; has "_pages" => is => "ro", handles_via => "Array", default => sub { [] }, handles => { pages => "elements", queue_page => "push", next_page => "shift", }; has "agent" => is => "lazy", isa => sub { confess "Need a flavor of WWW::Mechanize" unless eval { $_[0]->isa("WWW::Mechanize") } }, handles => [qw/ get post request links uri success response /]; sub _build_agent { require WWW::Mechanize; WWW::Mechanize->new( autocheck => 0, agent => join("/", __PACKAGE__, $VERSION) ); } sub crawl { my $self = shift; return unless my $uri = shift || $self->next_page; if ( $self->get($uri) and $self->success ) { $self->queue_page($_->url_abs) for $self->links; } else { carp "Problem fetching ", $self->uri, $/, "Moving on to next link"; $self->crawl; } $self->response; } 1; my $spider = MooSpider->new; $spider->crawl("http://example.org"); print join($/, $spider->pages), $/; $spider->crawl; print join($/, $spider->pages), $/;
Re^2: Bullish on Moose, how about you?
by nysus (Parson) on Apr 23, 2016 at 12:43 UTC

    Why use Type::Tiny? Because it works with other OO frameworks?

    $PM = "Perl Monk's";
    $MCF = "Most Clueless Friar Abbot Bishop Pontiff Deacon Curate";
    $nysus = $PM . ' ' . $MCF;
    Click here if you love Perl Monks

      Yes; one type library for your app/company or whatever can be used anywhere including standalone/tests and the like. And because it's just really well designed software. Teh Inkster's stüfs are worth investigating in general.