Beefy Boxes and Bandwidth Generously Provided by pair Networks
Don't ask to ask, just ask
 
PerlMonks  

Re: Perl/Ruby comparison

by tall_man (Parson)
on Apr 12, 2005 at 15:48 UTC ( #447057=note: print w/ replies, xml ) Need Help??


in reply to Perl/Ruby comparison

There several things missing in ruby compared to perl that limit my desire to go to that language.

One thing I miss is the amenities to reduce the amount of quoting the user has to do when using hashes. Compare:

h = {"one"=>1, "two"=>2, "three"=>3 } h["four"] = 4

to this in perl:

%h = (one=>1, two=>2, three=>3); $h{four} = 4;

You can tell perl was written by a linguist -- there's more interest in making the language expressive, with natural shortcuts, rather than "pure."

Being able to convert input strings to numbers instantly is another nice shortcut. "Everything's an object" gets in the way of that in ruby.

The worst thing is the complete lack of a protective mode like "use strict;" as I discussed here. Writing in ruby feels unsafe to me.

Perhaps I am spoiled by some of the features in perl. If I had started first with ruby I might like it better.


Comment on Re: Perl/Ruby comparison
Select or Download Code
Re^2: Perl/Ruby comparison
by adrianh (Chancellor) on Apr 18, 2005 at 15:01 UTC
    h = {"one"=>1, "two"=>2, "three"=>3 } h["four"] = 4

    Then again in most Ruby code it would be more idiomatic to use symbols instead of strings as the keys so it would come out as:

    h = {:one=>1, :two=>2, :three=>3 } h[:four] = 4

    which rolls off the fingers quite nicely in my opinion.

    You can tell perl was written by a linguist -- there's more interest in making the language expressive, with natural shortcuts, rather than "pure."

    Then why do I end up typing less when I use Ruby? :-)

    Some things are shorter in Ruby than Perl. Some things are shorter in Perl than in Ruby. I certainly don't find Ruby more verbose than Perl. The opposite if anything.

    Being able to convert input strings to numbers instantly is another nice shortcut. "Everything's an object" gets in the way of that in ruby.

    It's not the everything-is-an-object bit of Ruby that gets in the way. Everything is an object in Perl 6 and it keeps the auto-conversion between numbers and strings.

    It's a design decision on how those objects behave. For me it's six of one and half dozen of the other - neither option makes a huge difference to the way I code.

    The worst thing is the complete lack of a protective mode like "use strict;" as I discussed here. Writing in ruby feels unsafe to me.

    I have to admit that I too thought that this would be a problem, but I've found this a complete non-issue when using Ruby.

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://447057]
help
Chatterbox?
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 2014-12-20 21:18 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    Is guessing a good strategy for surviving in the IT business?





    Results (99 votes), past polls