FROM : Jens Alfke
DATE : Thu May 15 21:06:40 2008
On 15 May '08, at 8:21 AM, colo wrote:
> I get messages and oop [Sender Dosomething] or in Ruby
> @sender.dosomething. OOP was easy for me as thats how I already
> thought code would be like. Of course I am still learning but I fail
> to see why Cocoa syntax could be any different than Ruby.
Um, because it's a different language? (Which is, FYI, called
"Objective-C", not "Cocoa".)
Objective-C message syntax is closely based on Smalltalk-80, the
granddaddy* of object-oriented languages. (Ruby is also strongly
Smalltalk-influenced, but in different ways, and ironically its
message syntax is more based on C.)
The idea is that selectors, by intermingling the method name with the
arguments, make the meaning clearer and let you create variant
versions of methods in a simple way.
In Ruby:
obj.useString("bar",true,7) # WTF do all those params mean?
Objective-C:
[obj useString: @"bar" caseSensitive: YES maxLength: 7]; // much
clearer!
Note that you can then add versions of this without the maxLength: and/
or caseSensitive: parameters, or with something else entirely:
[obj useString: @"bar" customTransformer: myTransformer];
which in Ruby would have to be a method called
"useStringWithTransformer" or something like that.
> I'll test Macruby when 1.9 comes out, but reading Cocoa is like bash
> my head into needless [] : @ syntax every which way.
It usually takes people about one day to get used to the syntax.
Complaining about it just because it isn't what you're used to isn't
very productive.
—Jens
* (as opposed to great-granddaddy Smalltalk-72, and family line
founder Simula)
DATE : Thu May 15 21:06:40 2008
On 15 May '08, at 8:21 AM, colo wrote:
> I get messages and oop [Sender Dosomething] or in Ruby
> @sender.dosomething. OOP was easy for me as thats how I already
> thought code would be like. Of course I am still learning but I fail
> to see why Cocoa syntax could be any different than Ruby.
Um, because it's a different language? (Which is, FYI, called
"Objective-C", not "Cocoa".)
Objective-C message syntax is closely based on Smalltalk-80, the
granddaddy* of object-oriented languages. (Ruby is also strongly
Smalltalk-influenced, but in different ways, and ironically its
message syntax is more based on C.)
The idea is that selectors, by intermingling the method name with the
arguments, make the meaning clearer and let you create variant
versions of methods in a simple way.
In Ruby:
obj.useString("bar",true,7) # WTF do all those params mean?
Objective-C:
[obj useString: @"bar" caseSensitive: YES maxLength: 7]; // much
clearer!
Note that you can then add versions of this without the maxLength: and/
or caseSensitive: parameters, or with something else entirely:
[obj useString: @"bar" customTransformer: myTransformer];
which in Ruby would have to be a method called
"useStringWithTransformer" or something like that.
> I'll test Macruby when 1.9 comes out, but reading Cocoa is like bash
> my head into needless [] : @ syntax every which way.
It usually takes people about one day to get used to the syntax.
Complaining about it just because it isn't what you're used to isn't
very productive.
—Jens
* (as opposed to great-granddaddy Smalltalk-72, and family line
founder Simula)






Cocoa mail archive

