Take the 2-minute tour ×
Programmers Stack Exchange is a question and answer site for professional programmers interested in conceptual questions about software development. It's 100% free, no registration required.

Objective-C features nice object orientation, simplicity, elegance, and (as a superset of C), low level ability. It could seem like the simple, modern alternative to C++ that many people look for and try to find in Go. But it is just used at Cocoa and post-NextSTEP environments, and even in this case is seen more as a burden for historical reasons than as an optimal choice.

Why it's not more widely used then? What are its problems?

share|improve this question
5  
"historical reasons" mean "lots of libraries" –  user1249 Aug 17 '11 at 18:51
    
@vartec you aren't forced to do that. See MonoTouch for example, it is C#. Oh and then you have Apple's rule about Objective-C, C and C++, right? They already abandoned that. –  rightføld Oct 28 '11 at 11:00

2 Answers 2

IMO, the problem with Objective-C isn't so much massive shortcomings, as minor shortcomings (especially early on) and lack of perceived advantages.

Objective-C was a pure superset of C, so C code could transition to Objective-C easily. The mindset to use Objective-C, however, differed from the C mindset a lot. The transition from C to Objective-C is easy for code but not easy at all for many programmers. A C programmer can't easily just pick a few new convenience features in Objective-C and get better productivity almost immediately -- he needs to learn a lot of new "stuff" before he can get anywhere at all.

C++ made the transition for some code a little more difficult, but the transition for most programmers much easier. C programmers who are accustomed to dealing with every detail of their code could still do so in C++ to exactly the extent they wanted. C++ also made it easy to use some new features (e.g., adding a ctor to automatically initialize members of your struct) without really changing your way of thinking. A lot of OO purists pushed radical changes in thinking, but lots of C programmers switched to C++ without doing anything of the sort (at least right away -- and often ever, from the looks of things).

C++ also looked much more familiar to most C programmers. It added a few new keywords, but (especially early on) the code still mostly looked fairly familiar. Despite its "pure superset" status, most Objective-C code looks fairly foreign to most C programmers. A lot of C++ is also fairly easy to explain and understand in terms of how things work in C. Switching to Objective-C has a lot more places that about all you can say is "just trust me and forget everything you think you know."

Many of the design decisions in Objective-C also made it (somewhat) slower than C++, especially on relatively old machines with slow processors, limited memory, etc. Rightly or wrongly, it was also seen largely as a single-company product, where C++ was freely available for anybody and everybody to implement.

These all led to C++ being adopted quickly enough early on that it achieved "critical mass" fairly quickly, so (among other things) it became the obvious choice for a lot of projects just because it was already a widely-used, well-known quantity.

Objective-C has never reached that point. In fact, it was well on its way toward fading into obscurity when Apple revived it by nearly forcing it on anybody who wanted to develop for their systems. Apple's market share isn't large enough for that to really give it critical mass either though -- just a larger niche. It's a "default" choice only where/because Apple makes it so.

I'd also add that at least in my opinion, Objective-C's Smalltalk-like object model means that in effect it's much more a direct competitor to Java than C++. Yes, it still has the C underpinnings, and yes you can still write low-level code without using a separate language -- but pure C and real Objective-C are enough different that it's less like a single language than two completely different languages that happen to both be handled by a single compiler (though it is handy that the two can talk to each other without something like JNI to join them).

share|improve this answer
    
An excellent historical review. I first coded in Objective-C on white box NextSTEP machines in the 90's and having already been taught C++ at university, hated Objective-C's bizarre syntax. As such I can appreciate many of the things you say here. –  Mark Booth Aug 18 '11 at 9:55
    
thanks, that's obviously the answer I was looking for. ritchie made C to make teamwork possible; "C is quirky flawed and an enormous success"; this quote MEANS you have to make a flat, simple language so that many people can understand it, and it doesn't mean it has to be an "awesome" language. Nobody wants to complain about objc, because nobody likes it. "there are language people complain about, and language nobody use" bjarne stroustup. At least windows was able to make the computer industry grow even with a corporate clusterfuck, and I hope apple fails because they don't care about devs. –  jokoon Mar 4 '13 at 11:35
    
Sorry for the rant, but even if being a developer means you have to learn new things, it doesn't mean you have to forget everything you already know. I heard the messenger functionality of objc is made with some optimized ASM code. What a mess, how can you tell devs to understand that ? How about drivers and kernels devs ? Macs are just Cadillacs you use to drive, they're just fancy expensive objects that sell so you can just check email, watch a dvd. Want to add some software to that thing ? good luck pal. forget all existing soft, and do the apple way TM. –  jokoon Mar 4 '13 at 11:42
    
+1, excellent explanation! –  Chan Dec 25 '13 at 10:08

Well, basically, Apple is the driving force behind Objective-C since some time now:

  • While the last version is virtually abandoned, Objective-C 2.0 is actually starting to become increasingly tied to some of the core foundation classes/protocols, which means, there is an inherent link between the language features and the framework, NSFastEnumeration springing to my mind, which is needed for objects to properly respond to for in loops. This means, there is a growing link between the language and the platform.
  • There's virtually no real alternative to Cocoa. And Cocoa in turn is starting to depend on more and more OSX features. While technically, you can have an Objective-C implementation running on any OS with any core framework, there's not really much recent stuff out there for any other platform.

As it is now, Apple has full control over Objective-C and drives the language according to its needs, while there's no organization on this planet interested in running Objective-C on a non-Apple device, that would be sufficiently large to provide a standard library and toolkit to start with, that could even remotely rival the ecosystems presented by .NET/Mono, C++ or Java.

share|improve this answer
2  
There's GNUStep. They try to keep up with Apple, though I haven't checked for a while how well they're doing. –  Per Johansson Aug 17 '11 at 20:30
1  
And there's Cocotron as well. –  ysdx Aug 17 '11 at 22:57
    
At the point of this answer written, there was really nothing possible to run Objective-C 2.0 on non-Apple platform. Anyway, a lot of efforts made after that, and now we can expect to run Objective-C 2.0 on FreeBSD using GNUstep pretty smoothly. –  Eonil Oct 16 '13 at 20:19

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.