top | item 9670630

(no title)

Lrigikithumer | 10 years ago

Elegant to program with. Not write a parser for.

discuss

order

davexunit|10 years ago

An ambiguous syntax is not elegant to program with. Is this a variable reference? Is it a method call? I dunno!

Confusion|10 years ago

Boring arm chair language criticism. I have programmed professionally in Ruby for 5 years and it has never been a problem. You may as well complain that the ability to import an identifier leads to confusion about which identifier from which namespace you are calling when you reference one. I have 99 gripes about Ruby, but this ain't one.

adamlett|10 years ago

Among people who like Ruby, this is seen as a feature, not a bug. It makes refactorings easier when you change something from a local variable to a method call and don't have to search for all the places you would have to add parentheses in a language like Java. Granted, you could argue that your IDE should take care of that for you with automatic refactorings, but to a Rubyist this is a crutch and also something that forces her to use a particular IDE instead of her favorite editor.

jacques_chester|10 years ago

> Is this a variable reference? Is it a method call? I dunno!

Neither. It's a message sent to an object. The object decides how to respond to that message.

Caring about the implementation of the message receiver breaks information hiding. If you have to distinguish between .message and .message(), you already know more than you need to know to interact with that object.

Every language is confusing until you understand the mental model (even if you disagree with the utility of that model). If you come to Ruby thinking in Java/C++/C terms, you'll be unhappy, because the mental model is very different.

For Ruby, the book to read is The Well-Grounded Rubyist, which makes the language quite obvious.

JoeAltmaier|10 years ago

Wait - are we talking C/C++ here? where a function call, a variable declaration, an expression cast all look identical?

kentt|10 years ago

Have you written Ruby often and still felt like this? I'm asking because I'm newer to Ruby and this does come up a fair bit, but I was assuming that with time the ambiguity would disappear.