• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: Guidance for Cocoa's steep learning curve
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Guidance for Cocoa's steep learning curve


  • Subject: Re: Guidance for Cocoa's steep learning curve
  • From: Jens Alfke <email@hidden>
  • Date: Thu, 15 May 2008 12:06:40 -0700


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)

Attachment: smime.p7s
Description: S/MIME cryptographic signature

_______________________________________________

Cocoa-dev mailing list (email@hidden)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:

This email sent to email@hidden

References: 
 >Guidance for Cocoa's steep learning curve (From: Erik Buck <email@hidden>)
 >Re: Guidance for Cocoa's steep learning curve (From: colo <email@hidden>)

  • Prev by Date: Re: Using NSThreads in command-line apps
  • Next by Date: Re: Cocoa Programming for Mac OS X 3rd ed Shipping?
  • Previous by thread: Re: Guidance for Cocoa's steep learning curve
  • Next by thread: Re: Guidance for Cocoa's steep learning curve
  • Index(es):
    • Date
    • Thread