News for hackers. Stuff that matters.
Re:Why I Like Ruby by joe_the_user on Friday July 16, 2010 @12:26AM (#1520278)
I find that

    display_warning() if problem_condition() 
feels much more expressive in some situations than

    if(problem_condition) display_warning()
The later just emphasizes the primary activity to me - again, in some circumstances. It's something I miss now that I'm not doing Ruby anymore.
Re:Why I Like Ruby by mahmud on Friday July 16, 2010 @12:52AM (#1520325)
That breaks efficient code reading. When you read code, you tend to skip through basic-blocks (i.e. consecutive statements without branches) and follow them to that intersection point where a decision has to be made. In traditional form, if you have:

  if (condition) consequence();
You're able to "run" the condition in your head and step into the consequence without loss of pace. But when you put the consequence before the condition, you will have to backtrack.
Re:Why I Like Ruby by v_ on Friday July 16, 2010 @01:01AM (#1520340)
unless the consequence itself is something that signifies the end of a basic block, like a break or a next or a return.
Re:Why I Like Ruby by brianto2010 on Friday July 16, 2010 @01:50AM (#1520408)

  backtrack = true unless consequence.signifies? :block_end
It doesn't seem that much harder to read.
Re:Why I Like Ruby by draegtun on Friday July 16, 2010 @10:09AM (#1521183)
Unfortunately though you are potentially adding subtle bugs here which can only be caught at run time.

To avoid excessive test coverage it would be more pragmatic to do:

  backtrack = (consequence.signifies? :block_end) ? false : true
But that's not as easy to read :(
Re:Why I Like Ruby by mahmud on Friday July 16, 2010 @12:27PM (#1521599)
I didn't reply to that one-liner because it is a one-liner.

A lot of software engineering lore crumbles into tautologies or is completely obviated when you're working at the microscopic level.