Why Ruby?

Stephan Soller stephan.soller at helionweb.de
Mon Dec 13 05:43:00 PST 2010


On 11.12.2010 10:29, "Jérôme M. Berger" wrote:
> Ary Borenszweig wrote:
>> http://vimeo.com/17420638
>>
>> A very interesting talk.
>>
>> I used to like D. To write code in a high level while at the same
>> time being very close to the machine, with class invariants, unit
>> tests and many other features seemed very appealing. But I always
>> felt there was something wrong.
>>
>> About a year ago I met Ruby. Now I find languages like Java, C#,
>> Python and D kind of ugly and uncomfortable. Why? Exactly because of
>> what it is said in that video.
>>
>> This is not to start a flame war or trolling, it's just to show you
>> why I changed my mind so much about D, and why I think (IMHO) you
>> should care about naming conventions (like bearophile says), more
>> powerful unittests (and not having unittests integrated into the
>> language but rather being able to build your own test frameworks
>> with ease) and stop caring about being C-syntax friendly. The world
>> doesn't need that many semicolons and parenthesis. :-)
>
> 	There is a major syntax issue with Ruby. This line:
>
> foo(a, b)
>
> does not mean the same thing as this line:
>
> foo (a, b)
>
> 	!!WT?
>
> 		Jerome

Well, this is only a major syntax issue if you write Ruby code like you 
write C code (with many parenthesis). Usually method calls in Ruby don't 
contain any parenthesis:

	foo a, b

Parenthesis are only used if a parameter is an expression:

	foo (a + 1), b

Because of that coding style the above example is an rare edge case. I 
tried it in IRB (interactive Ruby console) and your two method calls 
actually do the same. The second one however generates a warning ("don't 
put space before argument parentheses").

ps.: For "foo (a, b)" to really screw up "," has to be a method defined 
on "a". I don't think that's possible in Ruby.

Happy programming
Stephan Soller


More information about the Digitalmars-d mailing list