News for hackers. Stuff that matters.
Re:Ruby is beautiful (but I'm moving to Python) by ashleyw on Sunday November 28, 2010 @02:47PM (#1948077)
I really didn't like some of his examples (especially the part containing 'longer_than_5', that was hideous IMO!) He tried explaining Ruby's simplicity…by using some of the most confusing idioms.

For example:

    array.select &:even?
Is really just:

    array.select{|n| n.even?}
I generally always use the latter. It's just cleaner. I hate overly clever code.
Re:Ruby is beautiful (but I'm moving to Python) by ionfish on Sunday November 28, 2010 @04:35PM (#1948380)
Which of these Haskell examples do you prefer, then?

    filter even xs

    filter (\x -> even x) xs
Re:Ruby is beautiful (but I'm moving to Python) by jpr on Sunday November 28, 2010 @03:22PM (#1948164)
Overly clever or confusing to you, idiomatic to others (and vice versa).
Re:Ruby is beautiful (but I'm moving to Python) by axod on Sunday November 28, 2010 @03:58PM (#1948280)
The former isn't guessable unless you know special modifier characters. It's also error prone if you typo a single character.

The latter is readable.

Re:Ruby is beautiful (but I'm moving to Python) by djacobs on Sunday November 28, 2010 @04:03PM (#1948292)
That's true, but the modifier character* (not more than one) is consistent: & says "take the named method, call to_proc on it, and pass it in as a block". Since many methods allow blocks to be passed to them, this kind of code is useful and well-understood, I think.

I want to note that the &:even? idiom is only used in the simplest cases.

Re:Ruby is beautiful (but I'm moving to Python) by chc on Monday November 29, 2010 @01:33AM (#1949586)
You're contrasting "not guessable" with "readable." The behavior of Ruby's `||` is not guessable for a lot of people but it's still quite readable if you know the language.