Beefy Boxes and Bandwidth Generously Provided by pair Networks
Problems? Is your data what you think it is?
 
PerlMonks  

Re^2: RFC: Array::GroupBy (Moose)

by kyle (Abbot)
on Jan 06, 2009 at 16:24 UTC ( [id://734463]=note: print w/replies, xml ) Need Help??


in reply to Re: RFC: Array::GroupBy
in thread RFC: Array::GroupBy

I'll start by saying that I expect Moose to be ubiquitous. If it's not now, it will be. Also, anyone installing something as obscure as Array::GroupBy is sure to have something as mainstream as Moose.

Anyway, what I got in this particular case was mostly Moose::Util::TypeConstraints. At object creation, and any time an attribute is set, the attributes are checked against the constraints I set. If I weren't using Moose, I'd be using Params::Validate. Aside from that, I get the usual OO framework stuff: a constructor and attribute accessors.

The make-work code I'm saved from writing is, again, mostly the input validation stuff. My version of Moose is a ways behind the current, so I wound up doing some of this myself in order to get the detail I wanted. I found it pretty tedious, and the results challenge comprehension. With a newer version of Moose, this was easier to do and easier to read. Without Moose (or some module), it could have been more work than writing the actual functionality of the module.

Replies are listed 'Best First'.
Re^3: RFC: Array::GroupBy (Moose)
by grinder (Bishop) on Jan 06, 2009 at 16:59 UTC

    You know, I'm happy to point Moose out to non-Perl hackers, it usually shuts them up about how much of a mess Perl's OO is. They tend to glance at an example and say "Oh this is nice! This actually makes sense". On the other hand "anyone installing something as obscure as Array::GroupBy is sure to have something as mainstream as Moose" sounds a lot like wishful thinking.

    If you do release this to CPAN, I think Params::Validate as a prerequisite is a much more viable proposition. The fact that there's a very useful analog over in Moose land makes me think of someone saying "Hmm. I need to put my cup down somewhere. I know, I'll go out to my car and use the cup-holder."

    • another intruder with the mooring in the heart of the Perl

      I'd like to second this remark. I'm currently working with a codebase where pulling in Moose (and its dependencies) would be quite a task, so Array::GroupBy requiring it would very likely prevent me from using it.

        If you don't mind me asking, what about your environment makes it hard to pull in Moose?

        At this point, not having Moose would prevent me from writing something like Array::GroupBy.
Re^3: RFC: Array::GroupBy (Moose)
by salva (Canon) on Jan 08, 2009 at 18:44 UTC
    I'll start by saying that I expect Moose to be ubiquitous. If it's not now, it will be.
    Moose has a huge loading time that makes it unsuitable for many tasks. On my (somewhat old) computer...
    $ time perl -e 'package foo; use Moose' real 0m1.052s user 0m0.880s sys 0m0.044s $ time perl -e 'package foo' real 0m0.008s user 0m0.000s sys 0m0.008s
    I see no problem using Moose inside big long lived applications or frameworks like Catalyst and alike. But using it in a generic CPAN module unnecessarily limits where that module can be used.

    BTW...

    $ time perl -e 'package foo; use Params::Validate' real 0m0.066s user 0m0.028s sys 0m0.008s

      This is actually the problem that Mouse was written to solve, you might want to test that load time on your machine.

      And remember, nothing in life is free and in just about ever computing problem there are tradeoffs. You have to pay something somewhere to get all that Moose provides, we happened to have optimized for runtime over compile time.

      -stvn

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others admiring the Monastery: (2)
As of 2024-04-20 05:05 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found