views:

1825

answers:

7

I have heard mention of Objective-C but I have never used it myself. I was curious what everyones opinion of it was in general and also in relation to C++. Are there any types of projects where it would be more useful or less useful?

A: 

For Mac and iPhone development, it is definitely better. The latest version has a GC, so if you like that, you'll probably like it better than C++.

Lou Franco
The very loose binding of method invocations and separate interfaces make for quite stable code, and running objects in separate zones (memory address spaces) makes apps very stable, given that it's basically C.
Tim Williscroft
"The latest version has a GC, so if you like that, you'll probably like it better than C++." Note that this is a gratuitous argument. A GC is not necessarily the Graal of a C++ developer... :-p ...
paercebal
I agree -- that's why I said, "so if you like that"
Lou Franco
Also, only Mac OS X 10.5 has GC. GC isn't on the iPhone yet. Still waiting!
schwa
+3  A: 

My opinion is that the syntax of Objective-C is a little "weird" at first, particularly if you are coming from a C/C++ background (as I did). If you plan to write apps for the Mac or iPhone, Cocoa development is the way to go. I had an opportunity to do some development on the Mac for about a month this Spring and opted to write it in C++ using the Qt libraries since I was quite familiar with those and time was of the essence.

If you have a Mac, give it a shot! There is a LOT of info out there on it and there are some good tools for development.

itsmatt
To add to these excellent answers I want to point out that there is also Objective-C++ if you feel more comfortable with that to begin with.
Jon Gretar
+2  A: 

If you're running Linux you can install GNUStep which provides pretty good compatibility with Cocoa. This can get you started on Objective-C/Cocoa development without owning a Mac. The best resources for learning Objective-C [in my opinion] are with Apple.

http://developer.apple.com/referencelibrary/Cocoa/index.html

dreamlax
+11  A: 

Like many others I've just started looking at Obj-C due to iPhone. I've done a lot of C++ and C# and from what I can see Obj-C has a basically different approach to OO in that it adds Smalltalk-like messaging to C. Like C++ it's basically still C-compatible but the OO extensions let you send any message to any object. In that sense it's not statically typed like C++ and C# where the things an object can do are tied to the class it is. In Obj-C you can send a message to an object even if it doesn't support it. The object can then forward it if it doesn't know what to do with it.

The really cool thing is that you can add interfaces (protocols) at runtime and you can add your own handlers that intercept and hide message handlers for existing classes.

All in all there's a lot more flexibility when it comes to message handling, more like what you would do in Ruby or Smalltalk. Whether it's a good idea to have this type of OO grafted onto C or not I can't tell yet, in some ways the C++ approach meshes better with the original idea of C but on the other hand the Obj-C OO approach is more what OO purists like.

Andrew Queisser
+7  A: 

From "Some nice features of the Objective-C language":

  • Classes are objects
  • Dynamic typing and optional static typing
  • Categories
  • Message sending
  • Expressive message syntax
  • Introspection
  • Dynamic run-time
  • Automatic garbage collection
  • C inside
  • C++ fluent
  • Simplicity
  • Access to Apple technologies
A: 

It is more dynamic than C++ and heavily influenced from SmallTalk. I don't find it "better" than C++ - on the contrary, but some people do.

Nemanja Trifunovic
+3  A: 

Part of what makes Objective-C so great isn't the language (although that is a big part ot it), it's the Cocoa (or CocoaTouch) framework that goes along with it (at least for 99% of objc users ;-)

In practical terms, I used to be a C++ programmer back in the old "classic" Mac days. Switching to Objective-C, Cocoa and Mac OS X i found I became much more productive. Hard to say exactly how much more productive, but 50% to 100% feels right.

schwa