r/C_Programming • u/ThePenguinMan111 • 10h ago
Discussion Why did C++ crush Objective-C in popularity?
I know C and C++ are largely source-compatible with each other, but Objective-C is specifically a strict superset of C, not just a fork of it, like C++. You’d think that scratching that OOP itch while also giving you complete source compatibility with C would cause more companies or projects to utilize it, at least in some respect, but that may just be a naïve prediction. What does C++ have that Objective-C doesn’t that you think caused such a large popularity gap between the two languages? Am I missing some nuance?
80
Upvotes
134
u/RainbowCrane 10h ago
One major reason for Objective-C’s lower adoption in the eighties and nineties was that it was strongly tied with NeXT and Apple, and Apple was fairly miserable at attracting developers to its platform.
I was a UNIX (Berkeley and AT&T) and Windows (NT, Windows for Workgroups, 95) developer in the eighties and nineties and the toolchains for UNIX and Windows were either free or were handed out like candy at developers conferences. Apple toolchains were comparatively expensive.
So there were a whole lot more academic and amateur developers creating software for C++
74
u/simonask_ 10h ago
C++ tries and largely succeeds to provide zero-cost abstractions, meaning you can use most high-level features without any additional overhead.
Objective-C has a very different goal in mind, and only give you high-level features at the cost of dynamism and heap allocation everywhere. This is a very reasonable tradeoff in the UI space, but not in many of the niches where C++ dominates.
18
u/R-ten-K 5h ago
Besides the common points other posters have made already.
I think C++ ultimately won over Obj-C partly because of the New Jersey Unix School of Software Design: Worse is Better. Pragmatism, simplicity, and ease of adoption always beat overly complex elegance that requires jumping through hoops.
IMO, both languages sort of suck in different ways at translating the object oriented (OO) concepts of Smalltalk into a language built around C. Which may not be possible anyway.
Obj-C stayed closer to some of Smalltalk's original ideas, particularly dynamic message passing. It preserved more of the original OO model, but paid for that with a somewhat awkward syntax and the additional complexity of integrating that model into a language that retained C as a proper subset.
C++, on the other hand, is IMO a Frankenlanguage. It introduced OO features halfassedly, not fully embracing some of the underlying principles of the model, while also evolving into a language that wasn't a proper superset of C. In that sense, it ended picking up more the of the disadvantages than advantages of either (worst of both worlds?).
However, C++ was designed by a compiler expert, and that shows in its implementation philosophy; Static binding/compile time abstractions, aggressive optimization, and deterministic object lifetimes made it a better choice for performance and latency critical workloads (system stuff, and compute kernels/tight loops).
Its zero overhead abstraction philosophy was a particularly important differentiator. You could build relatively sophisticated abstractions without necessarily paying a runtime penalty for them.
Obj-C took a different approach. Its dynamic message passing model was to me more elegant and closer to Smalltalk's original philosophy. It also made experimentation, introspection, and iterative development considerably more natural. Which were also some of the goals of the original OO dev approach. But that flexibility came with runtime slowdowns vs C++.
So, IMO, both languages have fundamental limitations. IMO Obj-C was the more coherent expression of the original OO philosophy, while C++ offered more compelling performance.
TL;DR: both languages suck. It's just that C++ sucks faster.
42
u/an0th3rbrick 10h ago
probably because objective C is more dynamic which comes at a performance cost
18
u/PseudoFrequency 10h ago
C++ is a standard with many vendors. Objective C was virtually only Apple.
19
u/imMakingA-UnityGame 10h ago
Zero overhead performance in C++ and it actually more or less esp back then felt like C syntax, not being effectively locked into Apple ecosystem
17
u/zhivago 10h ago
Smalltalk and C were never good bedfellows.
The result was an uneasy frankenmonster unsure of what it was.
C++ on the other hand was consumed by the holy purity of its purpose and entirely sure of itself, especially where it was wrong.
You'll notice that C++ has quietly become much less C++ like over time.
5
u/finleybakley 4h ago
Have you written in obj-c? It's like dragging your skin against pavement. Truly a horrendous language to write in.
Not saying C++ doesn't have its learning curve and annoyances, but compared to obj-c it's a dream to write in
4
u/Narishma 9h ago
Probably because Objective-C started as a proprietary language and it took until the early- to mid-90s before there was an open implementation.
4
u/xeow 3h ago
Wait till you learn that Objective C++ is actually a thing! :-)
2
u/Physical_Dare8553 10h ago
at the very least, c++ has a whole bunch of features, from the beginning, Bjarn's second goal for the alnguage was popularity so that he didtn have to maintan ts himself
2
u/TheBestAtSpace 7h ago
Objective-C dynamic dispatch was much much slower.
6
u/ElectricSpock 10h ago
Because it was earlier, and there was no single company that pushed for it.
Next question.
4
u/demetrioussharpe 9h ago
The truth? Because Objective C was bought by Next before it had a chance to gain market usage, & became the default language of NextStep. Since next owned the language & targeted solely at NextStep, there were no real opportunities to use it outside of NextStep. So, its growth was stifled. When Apple bought Next, it became Apple’s main language, but it was still only used for that ecosystem. It never got a chance to thrive outside of those 2 companies. Otherwise, it would’ve most likely relegated C++ to the dustbins of history.
1
u/Engineer-4-fun 6h ago
With small changes to C, which do not reduce its utility or power or increase its complexity, but do enhance its clarity and safety, one can produce a language I think of as C-saner. C-saner is a proper subset of C++. Every C program is improved by conversion to C-saner and can then be compiled as if it was C++.
Objective-C was viewed as a niche language with proprietary aspects which, together with the appearance of C++, hindered its widespread adoption.
1
u/Sniffy4 6h ago
Obj-C was used for Apple platforms (because Apple bought NeXT in 1997) and nowhere else. That is the simplest explanation.
>You’d think that scratching that OOP itch while also giving you complete source compatibility with C would cause more companies or projects to utilize it,
C++ also has overwhelming compatibility with C. The difference is the style of OOP they implemented.
1
u/podule-games 6h ago
Obj-C was basically NeXTSTEP only until Apple bought NeXT, so even at its height, it was Mac/iOS only which isn't really a big market, especially considering it's not the *only* choice on Mac/iOS, you can easily write apps in something else, and most big players do.
The big players like Adobe might well make Mac apps, but they weren't using Obj-C, they'd be using C++. Same for most big Mac apps really. Obj-C was really mostly for "cottage industry" apps like I used to make, very few larger companies would bother with a Mac-only, or even an iOS-only language.
While I have a lot of affection for Obj-C, I won't pretend it's a good language, it's not. I have affection for a few languages like this, such as BASIC or RPG, languages that I find fun to use, but I don't attempt to make the argument they are good, well-designed languages that standard the test of time.
Basically Obj-C was Apple-only and really not that good.
1
u/YouFeedTheFish 4h ago
Objective-C combines the worst of C and smalltalk. Everything you can do in objective c, like message passing, you can do in a c++ library, but in a typesafe way.
1
u/BlockOfDiamond 4h ago
Probably because Objective-C uses slow dynamic dispatch whereas C++ calls functions directly with implicit first arguments.
1
u/Responsible-Bar7165 2h ago
It might have something to do with the fact that reading objective-c code is like sticking pins in your eyes.
1
u/Available_Safe1818 1h ago
Yes, your prediction is naive. C++ was first. Also, Obj-C syntax still looks like diarrhea.
1
u/Leverkaas2516 1h ago
Lots of great answers here, but that phrase "giving you complete source compatibility with C " just seems like a strange statement. Have you never read Objective-C code? It's fundamentally not C and not compatible with C. Once your code is littered with square bracket message passing, you are never going back to C. It's a one-way trip regardless whether you choose to convert your code to C++ or Objective-C, so compatibility is not a factor.
If you mean that your code can call C libraries, well, you can do that just fine from C++.
1
u/manicakes1 1h ago
Objective-C had poor performance characteristics out of the box. Dynamic message passing is great in many ways but also causes a table lookup and function call to every method invocation. When you use the collection types you have to convert basic C types into Objective-C objects (eg int has to be boxed up as NSNumber).
This made the language pretty bad for performance sensitive code because you wouldn’t want to use these abstractions in low level code or in hot loops. C++ with all its warts was usable in all levels of a big project.
Fun fact, all the core frameworks used by iOS and macOS developers are heavily written in C/C++. For the reasons I note above.
1
u/EpochVanquisher 9h ago
The major reason was tooling availability / licensing. It’s not really about the language.
1
u/LavenderDay3544 9h ago
One is an ISO standard that is completely vendor neutral while the other is tied to locked down proprietary vendor hardware, OS, and compiler platform.
0
u/HowardZyn 6h ago
Obj-C syntax just looks hideous
0
u/AdreKiseque 7h ago
Diaresis spotting
0
u/authorinthesunset 6h ago
Objective-c sucks. Though I will admit that NEXTStep was pretty rad at the time.
0
u/Ok_Outlandishness906 10m ago
for me c++ and object C are both terrible languages .