Beefy Boxes and Bandwidth Generously Provided by pair Networks
Think about Loose Coupling
 
PerlMonks  

comment on

( [id://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

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



  • Are you posting in the right place? Check out Where do I post X? to know for sure.
  • Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
    <code> <a> <b> <big> <blockquote> <br /> <dd> <dl> <dt> <em> <font> <h1> <h2> <h3> <h4> <h5> <h6> <hr /> <i> <li> <nbsp> <ol> <p> <small> <strike> <strong> <sub> <sup> <table> <td> <th> <tr> <tt> <u> <ul>
  • Snippets of code should be wrapped in <code> tags not <pre> tags. In fact, <pre> tags should generally be avoided. If they must be used, extreme care should be taken to ensure that their contents do not have long lines (<70 chars), in order to prevent horizontal scrolling (and possible janitor intervention).
  • Want more info? How to link or How to display code and escape characters are good places to start.
Log In?
Username:
Password:

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

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

    No recent polls found