Beefy Boxes and Bandwidth Generously Provided by pair Networks
Your skill will accomplish
what the force of many cannot
 
PerlMonks  

Lets talk Moose

by EvanCarroll (Chaplain)
on Jun 28, 2006 at 20:42 UTC ( [id://558143]=perlquestion: print w/replies, xml ) Need Help??

EvanCarroll has asked for the wisdom of the Perl Monks concerning the following question:

Has anyone done anything *really* cool with Moose? I've decided to try and make another ORM tailored more towards Postgres and schema loading. I've discussed my ideas with others; and I think they will never be implemented in DBIx::Class, nor do I want to learn DBIx::Class to implement them myself. Point being, I'm considering using Moose; but, really disenchanted by the lack of mention of it. I never heard of it before this week, and after having a look at it, I think it brings Perl one small step closer to ruby. Which is a good thing.

Has anyone done anything with Moose worth mentioning? I'm not all that fond of the complexity of what should be simple tasks, like adding prefixes to the writer/reader, 'set_', and 'get_', or making those prefixes defaults. And, I generally think lowly of classes that reference users with such trivial needs to the source of the parent class. Is there any class-builder preferred over Moose, by anyone?

I see Moose fitting in pretty well to model a relationship between
columns => tables => schemas => dbs

Would you use Moose's type validation components? Or is there a better way to validate SQL datatypes, without really calling the DB?

So it seems now moose has a new class to remedy the problems mentioned. Moose::Policy, more information can be found at http://use.perl.org/~Stevan/journal/30604


Evan Carroll
www.EvanCarroll.com

Replies are listed 'Best First'.
Re: Lets talk Moose
by stvn (Monsignor) on Jun 28, 2006 at 22:06 UTC
    EvanCarroll

    Let me start out by saying the documentation for Moose (and it's parent module Class::MOP) is sorely lacking and that this will change. However, given the amount of $work I currently have on my plate, this is likely to change fairly slowly.

    The reason why you have not heard much about it here is because I am purposefully not screaming about it from the mountaintop. It is currently only really ready for the "Early Adopter" crowd. We need adventurous people to build make cool stuff in it to work out all the deep ugly corner case bugs and such.

    Now, to answer your questions:

    Has anyone done anything *really* cool with Moose? ... Has anyone done anything with Moose worth mentioning?

    nothingmuch (who is also a core Moose/Class::MOP developer right now) has written Class::Workflow in it. He is also working on a drop-in Catalyst dispatcher replacement built on Moose, but this is not released yet.

    It is also being used/experimented-with by chansen and marcus (two of the core Catalyst developers), as well as mst, the author of DBIx::Class. Also sri's new web framework Mojo was (last time I checked) using Moose as well.

    On the Perl 6/Pugs front, fglock recently added Moose support to v6-pugs (although I am not sure that has yet to be released). The current plan (which I will be discussing in more detail with audreyt during this weeks hackathon) is to use Moose as the meta-level for the Perl 6 on Perl 5 runtime.

    I'm not all that fond of the complexity of what should be simple tasks, like adding prefixes to the writer/reader, 'set_', and 'get_', or making those prefixes defaults.

    The simplest way to do this is to explicity set the reader and writer's for an attribute. The code would look like this:

    package Foo; use Moose; has 'bar' => (reader => 'get_bar', writer => 'set_bar');
    There currently is no way to set this as the default behavior. If you would like that, please come to #moose on irc.perl.org and we can talk it out. However, keep in mind that this cannot be set as default on a Moose-wide basis because it would interfere with other Moose based modules, and what they expect. But this is not an unsolvable issue, I simply need a good solid use case, and to work out the API.

    And, I generally think lowly of classes that reference users with such trivial needs to the source of the parent class.

    Again, I apologize for the poor docs. Patches are always welcome :)

    Is there any class-builder preferred over Moose, by anyone?

    Of course I am biased, so I won't answer this directly. However, please keep in mind that Moose is more than a "class builder", it is a full object system for Perl. There is much work done "under the hood" to make Moose possible, and to make it play well with non-Moose classes. The only other module which has such ambitious (aka - completely insane) goals is Class::Meta.

    I see Moose fitting in pretty well to model a relationship between columns => tables => schemas => dbs

    Yes, I have had several conversations this week at YAPC::NA with people about exactly that. The level of meta-information stored by Moose could be very effectively used by an ORM.

    Would you use Moose's type validation components? Or is there a better way to validate SQL datatypes, without really calling the DB?

    This is actually something mst (of DBIx::Class fame) has been experimenting with, and again something I have been discussing with people here at YAPC. Currently the big problem is that Moose's type validation features store the actual validation in a code block. This makes it difficult to introspect in a way which can be translated to SQL (unless of course you are a serious B hacker that is). But since Moose's type validations are actually stored as meta-objects themselves, it should be very possible to fiddle with this and get what you are looking for.

    So, I hope this has answered some of your questions. Feel free to ask on #moose (on irc.perl.org), I will try to be there the rest of this week (connectivity was a bit spotty at YAPC, so i was not around). Or feel free to email me at the address listed on my CPAN page. As I have said, we are always looking for a few brave souls to help us work out all the edge cases and bugs.

    And lastly, if you want, the slides from my YAPC talk on Moose they are now online here, and apparently a video of it will be released soon by the hard-working YAPC organizers.

    -stvn
Re: Lets talk Moose
by ForgotPasswordAgain (Priest) on Jun 29, 2006 at 08:42 UTC
    Has anyone done anything with Moose worth mentioning?

    The way I learn about modules is generally is from the Module Listings on use.perl.org. Here's what I'd see there with Moose:

    Moose - Moose, it's the new Camel

    Since that tells me nothing, I'd probably ignore it.

    Now it's mentioned on perlmonks. Since I don't know anything about it, I look on search.cpan.org. One of the first things I read is:

    I am adopting the release early and release often approach with this module

    So I look in the Changes file, find that there were 5 releases during a one month period, then nothing since April. It goes back on my ignore list, since presumably the author had fun for a while then lost interest in it.

    (N.B. Artificially increasing the version number will NOT help.)

      So I look in the Changes file, find that there were 5 releases during a one month period, then nothing since April. It goes back on my ignore list, since presumably the author had fun for a while then lost interest in it.

      On the contrary, it is still under heavy development (although the release frequency has slowed a little, mostly because we are now working on the really hard parts, and they take more thought/experimentation). You were looking at the "official" releases. There have been a number of developer releases since April. There will likely be another official release by the end of the YAPC::NA hackathon.

      (N.B. Artificially increasing the version number will NOT help.)

      I would never do that, mostly because I am not sure I really agree with your opinions of quality anyway. There are many very stable, very solid modules which have not been touched for years.

      -stvn
Re: Lets talk Moose
by stvn (Monsignor) on Aug 11, 2006 at 20:13 UTC
    EvanCarroll

    Your problem is now solved by Moose::Policy, here is a quick example:

    package Point; use Moose::Policy 'Moose::Policy::FollowPBP'; use Moose; has 'x' => (is => 'rw', isa => 'Int'); has 'y' => (is => 'rw', isa => 'Int');
    Now Point has get_x, get_y, set_x and set_y methods generated for it's accessors.

    You can find a use.perl post here with some more details.

    -stvn
Re: Lets talk Moose
by Anonymous Monk on Jun 29, 2006 at 11:38 UTC

      No.

      Spiffy is a source filter, Moose is not.

      Spiffy is a class builder, Moose is complete object system, including a complete underlying meta system.

      Spiffy is written by Ingy, Moose is not ;)

      Spiffy is a only sort of based on Perl 6, Moose is heavily based on Perl 6 and will be meta-level compatible with Perl 6 (which should make Ponie's job much easier).

      There are a number of other differences, but they get into deep and heavy details, which I won't bother dumping here.

      -stvn
Re: Lets talk Moose
by demerphq (Chancellor) on Jun 28, 2006 at 20:49 UTC

    Moose?

    ---
    $world=~s/war/peace/g

Re: Lets talk Moose
by Lod (Initiate) on Jun 30, 2006 at 10:08 UTC
    Let's talk Sex ...

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: perlquestion [id://558143]
Approved by GrandFather
Front-paged by Arunbear
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others scrutinizing the Monastery: (4)
As of 2024-04-25 06:38 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found