Why Ruby?

Nick Sabalausky a at a.a
Mon Dec 13 09:39:21 PST 2010


"Stephan Soller" <stephan.soller at helionweb.de> wrote in message 
news:ie4srq$138c$1 at digitalmars.com...
> On 12.12.2010 18:01, Simen kjaeraas wrote:
>>
>> Absolutely not. Ruby reads like Yoda-speak, while D is almost plain
>> English. Had foreach used 'in' instead of the semicolon, only
>> punctuation and 'ln' would be off.
>>
>
> Unfortunately I have to disagree here. If you have well written Ruby code 
> (like Ruby on Rails usually provides) it can usually be read like plain 
> English. That's the reason why I dropped writing documentation comments 
> for Ruby code: it's just redundant.
>

This common Ruby idiom is totally Yoda-speak to me:

    doSomething unless condition?

The order-of-execution is completely backwards. Plus the "unless" instead of 
"if" makes my mind pause to process an "inverted-context" because *now* 
seeing a "blah" really means "not", and a "!blah" no longer means "not".

Yea, "(action) unless (condition)" is fairly normal English, but code has 
different requirements than normal speech. And besides, it's also perfectly 
normal, easily-understandable English to say "unless (condition), (action)", 
or even a negated if: "if you don't have x, do y". In fact I'd argue the 
English "if you don't have X, do Y" is much easier to understand than "do B 
unless you have C".

With normal English, it's easy enough to hear "do this", and then 
appropriately modify it in your head when you hear it followed by "unless 
that". This is largely because instructions in normal English tend to be 
*much* simpler than instructions in code. With code, there's so many other 
instructions to consider that that extra little mental work of modifying 
something you already processed suddenly makes a difference. But if you see 
something start with the modifier (the condition, in this case) then your 
mind automatically knows it's still an incomplete thought and doesn't do a 
premature "commit". At least that's how my (twisted?) mind works.

Also, Ruby reading like English might be part of why I'm *not* quite won 
over by Ruby's syntax: I'm a native English speaker and I still think 
English makes no sense!




More information about the Digitalmars-d mailing list