Impressed with Mason


I’ve got to say, I’m becoming more and more impressed with Mason. Today I wrote the frontend for a survey or polling system and got it done in relatively short time. Not only that, but with only minor tweaking, I can simply stick those components (ie: a component to display a poll) into pretty much any page and have it just work. Very cool. Course, mason isn’t going to win any speed contests. I can tweak out a pure mod_perl solution to give me 100 requests a second on a low end box with a fairly complicated page (with several database calls on each page), and from what I’ve seen mason doesn’t give anywhere near that sort of performance. More in the 20 requests a second area (could be wrong here, haven’t tested it at home yet). However, the speed of development makes up for this. I’m considering using it when I re-do Peer 2 Peer Personals.

5 Comments on “Impressed with Mason”

  1. I actually haven’t had any experience with the re-usable components under embperl. In fact, I didn’t know there were such things 🙂
    In Mason you can do something like the following. In your html page you want to say, display a poll, so you put:
    <& displayPoll.mc, pollid => 123 &>
    Then create displayPoll.mc in which you put something like:
    <%args>
    $pollid => undef
    </%args>

    html code / perl code to deal with whatever id is passed through the args section

    Of course, there is more to it than that (has the same idea as embperlobject for example) but the end result is that from any other page on the site you can call the displayPoll.mc file and get whatever small (or large) chunk of HTML and perl code you have it in.
    It takes a bit to get into I admit, but once you are in, it’s pretty quick and easy to do development. It also likes to enforce OOPerl programming, which is nice, you get that warm fuzzy feeling.

  2. Sounds pretty cool. Sounds like it’s pretty similiar to what Embperl can do.
    The Embperl equivalent would be very similiar:
    [- Execute (‘displayPoll.emb’, 123) -]
    Then in displayPoll.emb:
    [-
    $pollid = $param[0];
    ….
    -]

    html / perl here

    I think the biggest advantages of Embperl are still that it makes heavy use of mod_perl. This lets you do funky thinks with the familiar $r object. Or, it lets you say “run this block of perl code at compile time” and then “run this block of perl code at runtime”
    Of course trippy part is that with Embperl you can also have different syntaxes. So you can have a Mason block syntax if you wanted 🙂
    Although we didn’t do much of it at $oldjob (the SSI fan didn’t like it), we had some pages that used ooPerl. Ie, in base.htm you attach methods to the request object. Pages can then overwrite methods, inherit, etc. If you have displayPoll.emb in a sub directory, it would enherit the one in the parent directory if it existed etc.

  3. Embperl hasn’t been worked on much lately. Then again, it always has been primarily developed by one guy (Gerald) so it’s pretty amazing how far it did get.

  4. Mason also has access to $r, and the mod_perl environment. Different ways of doing the same thing I guess. Some of the architecture that it has (not covered by the above very simple example) is pretty trippy. I’ll see if I can find some good examples and send them over. Pretty much the same capabilities as embperl from what I’ve seen though…