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??
Ruby looks like a slightly crazier syntax than Perl to me.

Having used Ruby a bit and Perl a lot, I definitely prefer Ruby's syntax. It has a lot of the same shortcuts that Perl does, but is significantly more regular. With better defaults. And I find that as I go to more complex conceptual code, Perl is far more likely to get ugly on me.

As a random (unfair) example. Suppose that I want to do a sort on an array of arrays based on the contents of the first column. In Ruby that's array = array.sort; In Perl that's @array = sort {$a->[0] cmp $b->[0]} @array; Suppose that I want to do a lexicographic sort (first column, then second, then...) In Ruby that's the default. In Perl that turns into truly ugly code.

That is not an isolated example. Suppose that I have a hash of hashes and I want the keys of one of the subhashes. In Perl that's keys %{$hash_of_hashes{$foo}} while in Ruby that's hash_of_hashes[foo].keys. Which would you prefer to figure out in a hurry?

This is not to say that there aren't warts to Ruby's syntax. For a start, I loathe optional semicolons. Secondly, I strongly dislike the lack of a variable declaration, meaning that there is no easy equivalent of strict available. Thirdly the Ruby philosophy of, "Oh, add every alias someone might expect for this" has a conceptual cost when reading someone else's code.

But I still prefer it to Perl's. Significantly.


In reply to Re^2: OT: Ruby On Rails - your thoughts? by tilly
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 examining the Monastery: (4)
As of 2024-04-26 09:09 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found