Beefy Boxes and Bandwidth Generously Provided by pair Networks
Your skill will accomplish
what the force of many cannot
 
PerlMonks  

Re^2: What's wrong with Perl 6?

by Arunbear (Prior)
on May 11, 2007 at 09:16 UTC ( [id://614856]=note: print w/replies, xml ) Need Help??


in reply to Re: What's wrong with Perl 6?
in thread What's wrong with Perl 6?

For example, while I read the article titled Perl 6 Now (from Perl.com), I couldn't help thinking to myself how every bit of code would be done in Ruby and reaching the conclusion that it would be much cleaner.

Can you show what those examples would look like in Ruby?

Replies are listed 'Best First'.
Re^3: What's wrong with Perl 6?
by spurperl (Priest) on May 11, 2007 at 14:38 UTC
    I started typing the whole thing but it's too long, so I'll just post the code relevant to my comment. I feel that sigils are unnecessary at all (and they are harmful to my wrists !)
    ## ## Sigil invariance ## array = [1, 3, 5, 12, 37, 42] # I use symbols here, but one can use strings: {'alpha' => 4, 'beta' = +> 6} # hash = {:alpha => 4, :beta => 6} third = array[2] # This would be hash['beta'] when using strings # beta = hash[:beta] # Ruby doesn't slice as a part of syntax - there are special member # methods for that. I personally see it as a good thing. odds = array.values_at(1, 3, 5) bets = hash.values_at(:alpha, :beta)

      You like having symbol names automagically spring into existence without even the namespacing protection of different prefixes?

        ...spring into existence without even the namespacing protection of different prefixes?

        The extremely miniscule benefit of having same-named variables of different types is one I would gladly trade for the reduction in typing and visual clutter. Some people code according to style guidelines which explicitly discourage the use of this feature — and for good reason, imho.

        Note that in a name like $x, the keystrokes involved are three times that necessary to type x. That really belies the alleged priority given to Huffman coding in the design of Perl.

        Of course one will argue that good Perl coders don't use names that short; but a keystroke penalty against them is not a good way to encourage better behavior. The two keystoke penalty is incurred on every variable name occurrence.

        I think it also worth mentioning that the elimination of sigils would have major PR benefit as well.

        As for springing into existence — this (undeclared variables) is the sort of behavior that the interpreter should be in the business of discouraging. The penalty of having to declare a variable is incurred only once per variable.

        A word spoken in Mind will reach its own level, in the objective world, by its own weight

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://614856]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others perusing the Monastery: (5)
As of 2024-03-29 14:24 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found