Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl-Sensitive Sunglasses

comment on

( #3333=superdoc: print w/replies, xml ) Need Help??
First off, Catalyst is the attempt to port Rails to Perl. CGI::Application, Mason, Bricolage, AxKit and others are all solutions to the same problem. They all have their strengths and weaknesses.

I'm currently learning Rails and Ruby. Here's my experience. Basically, and I've said this on the P6 language list, Ruby is the closest to Perl6 that we have today. I want Perl6, and will joyfully use it when it's available. However, it's not, so I will use the thing closest to it, and that is Ruby. Perl is an excellent language and I will continue using it, as well. Perl has a number of strengths that Ruby cannot hope to match, not the least of which is CPAN.

BUT ... Ruby is a dream to code in. It has its shortcomings, just like everything else. But, as an experienced Perl developer, it solves the problems I have with Perl without exposing too many shortcomings to how I code. And, you cannot understand it without actually having programmed in a truly OO language that also has the same dynamic facilities that makes Perl great.

Rails is also a dream to work in. It has the same MVC architecture that Catalyst provides. But, the tools it has at its disposal are much better. A few examples:

  • Since everything in the language is an object, the xUnit framework actually works in Ruby vs. Perl. This makes testing quite a bit saner, and easier.
  • ActiveRecord makes Class::DBI look ... well, it makes it look sad. I spent two weeks rewriting Tree::Simple into Tree, borg'ing half the Tree namespace in the process, just to add a transparent persistence layer so that changes to $tree are automatically reflected in the database. Last night I read that ActiveRecord provides acts_as_tree() and acts_as_nested_set(). End. Of. Debate.
  • ERb is a templating system that provides everything TT does, everything JSP does, yet doesn't get in your way. It's the first JSP-like templating system I've even considered using, and I wish it could be done in Perl in such a clean fashion.

This is in addition to what Rails does for you:

  • This is what pagination looks like in Rails:
    def list @product_pages, @products = paginate :products, :per_page => 10 end
    One line of code, a few items in the associated template, and it's done. How many questions do we get on PM about pagination per month?
  • How about status messages back to the user? Well, this is how you send a message back to the user:
    def update @product = Product.find(params[:id]) if @product.update_attributes(params[:product]) flash[:notice] = 'Product was successfully updated.' redirect_to :action => 'show', :id => @product else render :action => 'edit' end end
    That flash[:notice] line is it. But, there's more! How about errors from whether or not the update was successful? Well, through the magic of ActiveRecord, if an error occurs, then the flash is updated with the list of errors. Through the magic of the right templates and CSS, those errors are sent to the user in the edit page (because we said that if update_attributes() fails, render the edit page) and the form is sticky. STICKY! And, it's just done for you.

The sample application in the book is a shopping cart. The fact that they consider this type of application simple enough for a demo (and it is, in Rails!) should be a good indication of the power that Rails puts into your hands. I haven't even discussed the configuration capabilities, logging, or anything else.

My criteria for good software:
  1. Does it work?
  2. Can someone else come in, make a change, and be reasonably certain no bugs were introduced?

In reply to Re: OT: Ruby On Rails - your thoughts? by dragonchild
in thread OT: Ruby On Rails - your thoughts? by Cody Pendant

Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post; it's "PerlMonks-approved HTML":

  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.
  • Log In?

    What's my password?
    Create A New User
    and the web crawler heard nothing...

    How do I use this? | Other CB clients
    Other Users?
    Others taking refuge in the Monastery: (8)
    As of 2020-12-02 13:28 GMT
    Find Nodes?
      Voting Booth?
      How often do you use taint mode?

      Results (41 votes). Check out past polls.