Welcome to the MacNN Forums.

If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

You are here: MacNN Forums > Software - Troubleshooting and Discussion > Developer Center > Minor Syntax Diffs (obj-C & c++) --> very different mental models [long]

Minor Syntax Diffs (obj-C & c++) --> very different mental models [long]
Thread Tools
Grizzled Veteran
Join Date: Feb 2001
Location: Pittsburgh
Status: Offline
Reply With Quote
May 23, 2001, 08:50 AM
 
I recently found a shareware project small enough in scope yet significant enough to motivate me into learning objective C and Cocoa. I ended up reading and rereading everything available about OS X's preferred language and API. This put me on one of them academic self enlightenment / self realization kicks in which I began to think about object oriented programming paradigms in great detail. Don't get me wrong, I could have already lectured anyone about inheritance, polymorphism, dynamic-typing-linking-binding... blah blah blah.

What I noticed was that objective C and c++ syntax differences, although trivial to an experienced programmer, lead to drastically different mental models within a programmer's head. Please don't reply by pointing out all the major differences in capabilities. My point is that most people gloss over the effects of syntax conventions since they are relatively easy to pick up while objective-C's other advanced features obviously require learning/training.

The whole distinction between C++'s object.method(par,,,) notation and obj-C's [receiver message ar:::::] is incredibly significant. This became apparent when trying to explain the difference to some innocent by-standing-non-programmers. These two syntax are functionally identical even though the languages differ in what else is possible. However, obj-C's syntax seems more true to the aims of object oriented programming. The message/receiver analogy is more useful, abstract, and analogous to the real world or an efficient mental model of the real world. The message analogy is great since in the real world, messages can be sent to anyone and its understood that someone may or may not know how to deal with a message. If the receiver is confused, they'll probably (should) forward the message on to someone that can interpret it. Such a analog doesn't exist for the object.method() notation. Also, by thinking of method calls as "passing messages" implementation and interface are further abstracted. Programmers will think of messages as communication rather than an action. This is good! It should lead to better MVC design or at least encapsulation.

Yep, I love the fact that the IDEs push for an object's interface and implementation to be in separate files. With the includes/imports and other declarations in the interface file, it forces programmers to abstract these things to a higher level. Object oriented programming has always been about making the path of least resistance lead to good programming practices. Obj-C just carries it further than most people even realize. Instead of just permitting abstract or interface classes, every class (implementation file) is essentially inherited from of an interface class.

Am I just preaching to the choir? Anyway, at least now I understand why some people evangelize specific object oriented programming. While at first glance the code doesn't look too different, the mental models built around the code is! Amazing how good syntax and documentation for the syntax can lead to a more efficient mental model.

[This message has been edited by dfiler (edited 05-23-2001).]
     
Addicted to MacNN
Join Date: Mar 2000
Location: London, UK
Status: Offline
Reply With Quote
May 23, 2001, 03:06 PM
 
Yeah, I agree. Obj-C seems more naturally object-oriented than C++. Great post
     
Junior Member
Join Date: Mar 2001
Status: Offline
Reply With Quote
May 23, 2001, 03:16 PM
 
I once read that Alan Kay regretted coining the term "Object Oriented" because it put the focus on the abstract data types (objects) instead of on messages, which he felt was more important.

-Peter
     
Fresh-Faced Recruit
Join Date: May 2001
Status: Offline
Reply With Quote
May 23, 2001, 05:23 PM
 
While I am in complete agreement with you regarding the message/receiver metaphor being really the critical point in the OO frame of mind, I have to disagree about the definition and implementation being in separate files being a good thing.

Probably the single best thing about the Java syntax as far as I'm concerned is the fact that definition and implementation is all in the same file. This removes a useless middle man scheme and can save several hours of developer time. Obviously this can result in breaking true data hiding (but you can create the same problem in C++), but if you are using precompiled libraries (like is most often done in Java) you won't have that problem.

When I learned Java I was ecstatic that I didn't have to make header files anymore, but when I recently took the time to learn ObjC I was more than a little dissappointed to see that things were back to the same old same old.

-Nathan Aschbacher

-----------------------------------------------------------
"I invented the term Object-Oriented, and I can tell you I did not have C++ in mind." -- Alan Kay

[This message has been edited by NoAuthoritaw (edited 05-23-2001).]
     
tie
Professional Poster
Join Date: Feb 2001
Status: Offline
Reply With Quote
May 23, 2001, 07:57 PM
 
Gotta agree that Java compiling is way better than C++ or ObjC.

This idea of communication versus action I don't see. It's more static versus dynamic typing, and has nothing to do with using []s or ()s in function/method calls. I like Java's static type-checking, even with the hacks that result from not having templates.
The 4 o'clock train will be a bus.
It will depart at 20 minutes to 5.
     
tie
Professional Poster
Join Date: Feb 2001
Status: Offline
Reply With Quote
May 23, 2001, 08:06 PM
 
Gotta agree that Java compiling is way better than C++ or ObjC.

This idea of communication versus action I don't see. It's more static versus dynamic typing, and has nothing to do with using []s or ()s in function/method calls. I like Java's static type-checking, even with the hacks that result from not having templates.
The 4 o'clock train will be a bus.
It will depart at 20 minutes to 5.
     
   
Thread Tools
Forum Links
Forum Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On
Top
Privacy Policy
All times are GMT -5. The time now is 03:13 PM.
All contents of these forums © 1995-2011 MacNN. All rights reserved.
Branding + Design: www.gesamtbild.com
vBulletin v.3.8.7 © 2000-2011, Jelsoft Enterprises Ltd., Content Relevant URLs by vBSEO 3.3.2