Slash Boxes
NOTE: use Perl; is on undef hiatus. You can read content, but you can't post it. More info will be forthcoming forthcomingly.

All the Perl that's Practical to Extract and Report

The Fine Print: The following comments are owned by whoever posted them. We are not responsible for them in any way.
More | Login | Reply
Loading... please wait.
  • Well, my opinion obviously is heaily biased, however I am actually using Moose in real $work, so I figured I am still qualified to comment :)


    Well Moose takes care of a lot of redundant and tedious code (constructors, accessors, etc), basically making easy things even easier and much less tedious. Sure you could use the more standard solution of Class::Accessor, but that forces you to put Class::Accessor in your @ISA, and it does not initialize attributes for superclasses automatically like Moose will. Anyone who has programmed in another OO language should appreciate things like this Just Working.

    Moose tends to also make code more readable. Once you learn the basic "syntax" (which is heavily based on Perl 6), most people find Moose very easy to read and very descriptive since Moose allows you to put in lots meta-information in your attributes. Not only does this give you basic type checking, it makes you intentions for the attribute much clearer, which makes it easier for someone 6 months down the road to see whats going on.

    And lastly, Moose (more specifically Class::MOP) makes class introspection very clean (no more symbol table hackery needed). This is usually not needed for 90% of code out there, but when programming "frameworks" it can come in really handy.

    In short, Moose can help save developer time (see item #1), help increase mantainability (see item #2) and makes tricky thing look less like line-noise (see item #3).


    It would be unfair if I didn'd list some of the cons of Moose.

    To start with, speed is an issue. Currently Moose is much slower than lovingly hand coded Perl. We are working on this and have made some signifigant strides towards speeding things up (and there is still room to speed up more), but it is not there yet. Currently we are optimizing for "theoretical correctness" which we hope will make it easier to optimize for speed later (see Haskell for more info :)).

    Next would be memory consumption. Moose creates a number of meta-objects to power many of it's features, however they are per-class and not per-instance so this is probably not that big of a deal unless you have hundreds of classes in your system.

    And lastly, startup time. Because Moose does much of it's calculations and such during compile time, it will increase startup time. This will be even more true when we add the optimizations to benefit the runtime. It is possible that we can overcome this using Module::Compile and .pmc files to cache the compiled results, but that is still a ways off.

    Hope this helps.

    - Stevan