Beefy Boxes and Bandwidth Generously Provided by pair Networks
Welcome to the Monastery
 
PerlMonks  

Re: RFC: Array::GroupBy

by grinder (Bishop)
on Jan 06, 2009 at 13:39 UTC ( [id://734433]=note: print w/replies, xml ) Need Help??


in reply to RFC: Array::GroupBy

Interesting. What does using Moose buy you in this particular case? Or to put it another way, how much make-work code would you have to add if you didn't use it?

This is more than an idle question, because if I really needed your module for the very specific problem it solves, I think I'd be a bit upset if I discovered that it pulled in a comparatively huge OO framework. This is in no way meant as disrepect to Moose. It's more a question of ratios: the Moose tarball is 250Kb, not counting its twenty or so dependencies. Sledgehammer, meet egg.

Would it take twenty lines to implement this as a dependency-free module? A hundred lines? Would it be painful? I guess it comes down to whether one considers Moose as a reasonable building block for small, special-purpose modules.

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

Replies are listed 'Best First'.
Re^2: RFC: Array::GroupBy
by jdporter (Paladin) on Jan 06, 2009 at 16:05 UTC
    Sledgehammer, meet egg.

    Ok.... But how many more such eggs will you need to see before you decide that this is one sledgehammer worth having in your toolbox?

      Why, a dozen of course!

      less flippant update: whether I think Moose is worthy of my toolbox (and I do) is beside the point. The question is whether you can yet decide that it is for everyone else.

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

Re^2: RFC: Array::GroupBy (Moose)
by kyle (Abbot) on Jan 06, 2009 at 16:24 UTC

    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.

      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.
      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://734433]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others contemplating the Monastery: (3)
As of 2024-04-23 22:51 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found