Is Moose the best for Perl object-oriented programming?

Discussion in 'Perl Misc' started by Tim McDaniel, Jan 2, 2009.

  1. Tim McDaniel

    Tim McDaniel Guest

    I foolishly agreed to give a talk at the Austin Perl user's group on
    object-oriented programming in Perl. Originally, I was supposed to
    talk about inside-out classes, but I decided to look at what
    object-oriented modules are available, in case there was something
    great and new, or in case Perl 5.10 had something spiffy.

    When I started Googling, I hit Web pages that stated that Moose is the
    best thing since sliced beer. The examples that I've seen did look
    spiffy, making it look as easy as R?by.

    In case other people have already researched this, I'd like to put out
    a request for reviews: is Moose the greatest object-oriented
    programming module for Perl, or at least equivalent to the greatest
    out there?

    --
    Tim McDaniel,
    fearing <http://www.acronymfinder.com/Do-Your-Own-Homework-(DYOH).html>
     
    Tim McDaniel, Jan 2, 2009
    #1
    1. Advertising

  2. Tim McDaniel

    Ted Zlatanov Guest

    On Fri, 2 Jan 2009 18:16:20 +0000 (UTC) (Tim McDaniel) wrote:

    TM> When I started Googling, I hit Web pages that stated that Moose is the
    TM> best thing since sliced beer. The examples that I've seen did look
    TM> spiffy, making it look as easy as R?by.

    TM> In case other people have already researched this, I'd like to put out
    TM> a request for reviews: is Moose the greatest object-oriented
    TM> programming module for Perl, or at least equivalent to the greatest
    TM> out there?

    You should look at performance numbers. For me, Moose took between 20%
    and 50% more time than regular Perl OO to do the same work. This is
    fine in some situations and terrible in others.

    I'm not making a feature comparison, just timing simple get/put field
    accessors. I understand all the ways in which Moose is wonderful but
    they may not be relevant if you need speed.

    Ted
     
    Ted Zlatanov, Jan 2, 2009
    #2
    1. Advertising

  3. Tim McDaniel

    Tim McDaniel Guest

    In article <>,
    Ted Zlatanov <> wrote:
    >You should look at performance numbers. For me, Moose took between 20%
    >and 50% more time than regular Perl OO to do the same work. This is
    >fine in some situations and terrible in others.
    >
    >I'm not making a feature comparison, just timing simple get/put field
    >accessors. I understand all the ways in which Moose is wonderful but
    >they may not be relevant if you need speed.


    Thank you for the comments.

    To expand on "fine in some situations": one has to be careful to test
    in the context of the intended application. One major Perl ap I wrote
    takes only several minutes to run and is run once per month. Another
    runs 90 minutes, but that's dominated by calls to MySQL and Perforce.

    In general, I've generally found it useful to worry first and most
    about correctness, and only then consider performance: tweak or
    restructure only to the extent that performance is bad.
    "Micro-optimization gets micro-results", and
    "if it ain't broke, don't fix it", and all that.

    --
    Tim McDaniel,
     
    Tim McDaniel, Jan 2, 2009
    #3
  4. Tim McDaniel

    Uri Guttman Guest

    >>>>> "TZ" == Ted Zlatanov <> writes:

    TZ> On Fri, 2 Jan 2009 18:16:20 +0000 (UTC) (Tim McDaniel) wrote:
    TM> When I started Googling, I hit Web pages that stated that Moose is the
    TM> best thing since sliced beer. The examples that I've seen did look
    TM> spiffy, making it look as easy as R?by.

    TM> In case other people have already researched this, I'd like to put out
    TM> a request for reviews: is Moose the greatest object-oriented
    TM> programming module for Perl, or at least equivalent to the greatest
    TM> out there?

    TZ> You should look at performance numbers. For me, Moose took between 20%
    TZ> and 50% more time than regular Perl OO to do the same work. This is
    TZ> fine in some situations and terrible in others.

    also note the compile time. i recently compared (on a very slow box)
    template::teeny which uses and loads moose vs template::simple which
    loads very little. the times for just one run were extremely slow (2-3
    seconds) with teeny and a fraction of a second with
    template::simple. this won't matter on long running servers but for
    one run programs it may make a difference. moose is a large system and
    not something you want to always load into small programs.

    i am not against moose in general (i even helped optimize it during a
    hackathon a couple of years ago at chicago::yapc) but i feel it is
    overkill in some situations. i don't like seeing half of cpan installed
    when i install a new (and seemingly small) module. dependency on large
    amounts of cpan is a set of bugs waiting to happen (and it will!).

    uri

    --
    Uri Guttman ------ -------- http://www.sysarch.com --
    ----- Perl Code Review , Architecture, Development, Training, Support ------
    --------- Free Perl Training --- http://perlhunter.com/college.html ---------
    --------- Gourmet Hot Cocoa Mix ---- http://bestfriendscocoa.com ---------
     
    Uri Guttman, Jan 2, 2009
    #4
  5. Tim McDaniel

    Ted Zlatanov Guest

    On Fri, 2 Jan 2009 20:40:04 +0000 (UTC) (Tim McDaniel) wrote:

    TM> In general, I've generally found it useful to worry first and most
    TM> about correctness, and only then consider performance: tweak or
    TM> restructure only to the extent that performance is bad.
    TM> "Micro-optimization gets micro-results", and
    TM> "if it ain't broke, don't fix it", and all that.

    The problem with Moose is that if you rely on its features, it may be
    very painful to worry about performance later. It's an OO framework,
    not an algorithm with clear API entry points. In particular, method
    attributes (including data type hints) can be hard to replicate if your
    code relies on them to enforce data integrity.

    Ted
     
    Ted Zlatanov, Jan 2, 2009
    #5
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Joe Mayo
    Replies:
    168
    Views:
    3,499
    David Thompson
    Oct 22, 2007
  2. Replies:
    2
    Views:
    482
    Bruno Desthuilliers
    May 26, 2008
  3. rolo
    Replies:
    3
    Views:
    197
    Robert Klemme
    Apr 9, 2004
  4. Replies:
    2
    Views:
    197
    Brian McCauley
    Dec 22, 2005
  5. Rainer Weikusat

    some random remarks about Moose::Manual::Concepts

    Rainer Weikusat, Mar 2, 2013, in forum: Perl Misc
    Replies:
    12
    Views:
    399
    Steve May
    Mar 7, 2013
Loading...

Share This Page