47

I know that the Apple community – including Mac and iPhone developers – mainly use Objective-C for their development language. But it seems that not many people use Objective-C outside of the Apple community, such as in the Windows or Linux worlds.

What are the possible reasons that Objective-C is not particularly popular outside of the Apple community?

Alex Rozanski
  • 37,815
  • 10
  • 68
  • 69
Tattat
  • 15,548
  • 33
  • 87
  • 138

5 Answers5

24

Another way of thinking about this question might be: why did C++, rather than Objective-C, become the "Object-Oriented C"?

I learned C++ in 1991, and remember that C++ seemed like the hot thing while Objective-C was this weird little language that no-one (other than NeXT) wanted to use. I've been trying to remember why, and I think it boils down to 4 things (5, if you include C++ having AT&T behind it):

  1. Features: C++ had, even then, a much richer set of features than Objective-C.
  2. Syntax: Objective-C's syntax is a much bigger change from C than is C++.
  3. Performance: Stroustrup focused on making C++ features easily mappable to C, so that (in theory!) there was no performance penalty in using C++. And with judicious use of the "inline" keyword, you could even get better performance with C++ than with C. Even now, there is no way I would use Objective-C in a project where performance was critical.
  4. Style: Relatively strong, static typing was the fashion (for good reasons).

So compared to Objective-C, C++ in the early '90s gave you more features with less of a performance penalty, with a syntax that was both fashionable and more familiar than Objective-C's.

Dave S.
  • 41
  • 1
  • 7
  • 9
    The problem with C++ is that kept on adding feature after feature to the point where even after using the language for 4 years, I still come across new code. That's kind of annoying. The language isn't consistent. Moreover, for a language that is supposed to add Object-Orientation to C, it sure isn't designed that way. Objective-C makes good use of classes for the sake of abstraction. C++ is this mess of functions and methods scattered over a bunch of header files. The C++ String class still doesn't have methods like trim, toUpper, toLower. This problem can be circumvented but it's annoying! – W.K.S Jan 14 '13 at 18:39
  • I have used C++ more than 25 years. But I was attracted exceedingly to use Objective-C 5 years ago because it looks less error-prone and much more object oriented language. And then now I have no regret to change my main language to Objective-C since then. – Sungwook Kim May 27 '14 at 08:33
  • 9
    I use C++ for more than 6 years and recently had to develop an iOS application using Objective C. Even after first "shock" (now I get used to Objective C) I still think that this is the most ugly and annoying language I've ever come across. The syntax is so dirty and redundant. I just cannot imagine anyone who would prefer this to other popular languages. Maybe wise use of some advanced frameworks like ReactiveCocoa can make the difference, but still... – Aleksei Petrenko Aug 07 '14 at 22:58
  • 4
    Plus, there are no namespaces in objective C, and this is rather ugly for big projects. – ondrejdee Sep 10 '14 at 09:44
23

This is a complicated question; but in short; I think the answer most likely lies in the age of the operating systems, and their roots.

  • UNIX is C, so that's that.
  • Linux is envisioned as a straight-up clone of Unix, (Fine, this is slightly inaccurate, but close enough for this discussion) and as such, it is more or less written in C.
  • Windows is an old operating system; and one that is built by stacking hack upon hack going back all the way to Windows 3.1. C++ is heavily favored, and in .NET, C#.

    This new influx is of course based on whatever agenda Microsoft has with that platform.

  • Mac OS X; on the other hand, is a (comparatively) young operating system, and its new parts (while still quite old, being inherited from the NeXT and whatnot) are all based on Objective-C because, "Hey! Why not?".

    As backwards compatibility was not among the list of priorities with Mac OS X 10.0; the C/C++-based Toolbox and Carbon got the short end of the stick, and the entire operating system was more or less made as a reskinned version of NeXTStep.

The issue with Obj-C is that the power of the language comes mostly from the sizable frameworks, the generally high level of integration into the system, and so on. It's almost impossible to get a good jive like that going without a clean break from backwards compatibility and, as such, it would never really stand a chance on any platform that didn't dare to do this. Apple, with a small (at the time) and devoted user base, dared do this, and struck gold.

Microsoft is now trying, but are, in my humble opinion, failing. ("Failing?! .NET!? HOW DARE YOU!?": With 4 major revisions in about 8 years, they are doing more growing than maturation; which may be a good thing, if they can turn it around.)

Edit: There are some projects attempting to port OpenStep to Linux, but they are a bit clunky and hard to use; there are also smaller projects on NS/OS-likes with smaller problem domains, but it's uphill work.

Williham Totland
  • 28,471
  • 6
  • 52
  • 68
  • +1 for "sizable frameworks". I think that's probably one of the key factors. – Alex Rozanski Apr 06 '10 at 09:44
  • 41
    I'm sorry, are you suggesting that Microsoft should let .NET develop incredibly slowly like Java has done? The major revisions have added a lot of functionality to both the languages and the platform. I don't see why that should be regarded as a failure. – Jon Skeet Apr 06 '10 at 09:49
  • .NET 1 came in 2002, so 4 revisions in 8 years - not so bad. – Kimi Apr 06 '10 at 09:53
  • 3
    @Jon;@Al: Changes need to be slow and deliberate. Just "adding stuff" doesn't make for a good framework. **Edit:** This isn't a discussion about .NET, and I didn't intend to turn it into one. I will edit the post accordingly. – Williham Totland Apr 06 '10 at 09:54
  • 4
    @Williham: I agree that "adding stuff" doesn't make for a good framework - but it doesn't make for a *bad* one either, as you're implying. This isn't being done in a giant ad hoc manner (although there are plenty of projects *not* in the core framework if you want to look for experimental stuff). – Jon Skeet Apr 06 '10 at 10:06
  • @Jon Skeet: Adding stuff is fine. "Merely adding stuff", on the other hand, is not. I freely admit that I do not do a lot of work using .NET, and when I do, I loathe it. ;I But from what I've seen, and correct me if I'm wrong, it seems that .NET revisions have a propensity for adding complete replacements for things where simply adjusting the existing behavior should suffice. I guess it all comes down to perceptions, or, if indeed I am correct; a crippling fear of breaking backwards compatibility. – Williham Totland Apr 06 '10 at 10:09
  • 17
    @Williham: Well, I think you're wrong. Where there have been "replacements" (e.g. WPF for WinForms, WCF for web services / remoting, Parallel Extensions for manual threading, ASP.NET MVC for web forms) they're pretty widescale changes with a grander vision rather than "adjusting the existing behavior". .NET has certainly been evolving at a very rapid pace, but I'd be hard-pressed to point to many areas of that evolution which are unwelcome. – Jon Skeet Apr 06 '10 at 10:41
  • I always thought that ObjectiveC was used on Apple because Next used it as standard language (Not a bad one but not suitable for all projects). – user3658739 Nov 18 '17 at 07:53
  • This answer is incredibly ironic now in 2018, with Objective-C (the "gold") being phased out as obsolete while C# gets stronger by the day, _including_ as a mean to program for Apple devices by means of Xamarin and the like. – T. Sar Apr 20 '18 at 12:14
19

I was recently standing in a bookshop reading Masterminds of Programming where the creators of programming languages talk about their creations. There was one chapter about Objective-C where Tom Love (one of the creator of Objective-C, along with Brad Cox) was asked why C++ had gone so far, while Objective-C hadn't:

Why do you think that C++ was used more frequently than Objective-C?

Tom: It had the AT&T moniker behind it.

Just that?

Tom: I think so.

What do you think about Objective-C today?

Tom: It still exists. How about that?

nevan king
  • 112,709
  • 45
  • 203
  • 241
13

Objective-C is nothing but a thin layer(a bit thicker with 2.0) of syntactic sugar for message passing on top of standard C. Even the most basic object orientation is provided by the runtime library, which was proprietary for a long time. Inertia is an important factor in language use.

It shines especially on GUIs, but the only toolkits that support it are Apple's and the mostly unknown and catchup-playing GNUStep.

While there is some value for Objective-C outside of GUIs, and I think people would use the extensions were they imported to C, even in system code, there is little reason to choose it over alternatives, when little of your system is meant to work with it.

4

Off the top of my head, I believe C++ is older than Objective-C, and not only for this reason has a much bigger user base. Everywhere that OC may have come, C++ was already there :)

Also, C++ has more features. Many people are impressed by lots of features. And it's had more research and development poured into it... and so forth. Essentially, momentum.

Carl Smotricz
  • 66,391
  • 18
  • 125
  • 167
  • 1
    C++ isn't really older than Objective-C--they both date from the early 1980s. – shosti Apr 07 '10 at 05:24
  • 15
    For anyone interested in those dates on a finer scale, I looked this up: Development of C++ started in 1979 and it appeared in 1983; work on Objective C started in 1982 and it was published in 1986. – Carl Smotricz Apr 07 '10 at 07:25