r/C_Programming • • 7d 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?

214 Upvotes

159 comments sorted by

259

u/RainbowCrane 7d 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++

51

u/non-existing-person 7d ago

Apple is still atrociously miserable at attracting developers to their platform.

In the past I was doing some extreme portability for my program. I even got QNX and some obscure unixware from the 2000s to work in qemu. Mac tho? Mac said "fuck you". No hardware. No system.

30

u/OrwellWasGenius 7d ago

I am pretty sure this is Apple's deliberate strategy: make its technologies as painful as possible to use on other platforms, so that the only way out is to buy Apple's hardware. There is just no way this level of ignorance is accidental.

Microsoft: C# and the .NET platform for Windows, Linux, and macOS (and it works even better than Java on non-Microsoft platforms). C# for developing Android and iOS apps. TypeScript for everyone. VS Code for all platforms. Hell, they even offer PowerShell for Linux and macOS. Windows Subsystem for Linux.

Apple: You can't even compile for iOS if you don't have a Mac and Xcode.

16

u/Netris89 7d ago

I am pretty sure this is Apple's deliberate strategy

I'm mean, yeah. It's part of their "walled garden, we know better than you what you want" strategy.

6

u/chipperclocker 7d ago edited 7d ago

They're a hardware company first and foremost. The software ecosystem is just a means to sell more hardware.

The XCode restrictions, virtualization restrictions, etc make more logical sense (I'm not passing moral judgement here, just recognizing the logic) if you view them through that lens. Apple sells appliances which, in some cases, are also useful as general purpose computers.

2

u/xpusostomos 6d ago

I don't think it's deliberate, it's history. When Next took objective C it was leading edge and didn't have a good competitor. Apple took and inherited it. Swift was a language deliberately designed to be a pretty objective C, same memory model, same dispatch model so that everything would be a painless switch over. Swift could call objective C objects like they were native.

1

u/New-Anybody-6206 7d ago

Apple: You can't even compile for iOS if you don't have a Mac and Xcode

https://github.com/xtool-org/xtool

11

u/OrwellWasGenius 7d ago

Yes, but it proves my point. It's reverse engineering by guys who don't like the situation. But God bless them.

0

u/spinwizard69 7d ago

The alternative view here is that Apple provides a way for third parties to succeed. Think about it why should Apple expend energy to get XCode to run on a notably poorer platform. On top of that a project like xtool provides a platform for innovation.

-2

u/spinwizard69 7d ago

Nope. At least not for developer tools.

Consider:

  1. Apple has supported LLVM/CLANG for years. CLANG has become the most widely available high quality C++ compiler out there.
  2. Apple has introduced Swift as an open project and frankly Swift is one of the best programming languages out there. The problem is the rest of the industry has a very negative attitude with respect to Apple developed languages.
  3. This negative attitude actually impacted Objective C.
  4. Some of those Microsoft Technology you reference are crap. Often common Linux / Unix technologies are more widely usable. Microsoft's primary desire is to try to control the whole industry with their technology.
  5. As for iOS, why would Apple bother with developing software to run on other platforms to build for IOS? That is really a third party problem, unless of course you expect Apple to try to control the market like Microsoft.

0

u/defmacro-jam 7d ago

I mean, Apple is a hardware company so they sell hardware.

10

u/stiggg 7d ago

Didn’t Apple first adopt objective c after they acquired Next in the late 90es?

13

u/qalmakka 7d ago

Yes but basically 100% of objective-c users before the acquisition were on NeXT. They were the one who wrote the GCC front-end for it, and basically nobody else was using it back then.

15

u/RainbowCrane 7d ago

Correct.

And by the late nineties Apple had lost the early wars for developers of end user software, both games and office apps. Moving to objective-c was a great architectural choice, as was the choice to move to the NeXT OPENSTEP model. But despite making some excellent business decisions about the release of i-everything, Apple has never really recovered from those early decisions to attempt to limit who had access to their developer tools.

Steve Ballmer’s infamous “Developers, Developers, Developers, Developers!” rant at one of Microsoft’s Developers Conferences was hilarious and unhinged to those of us who were around the dev community at the time - I wasn’t at that conference, I was at a MS Visual C++ conference a few months later. But that kind of hype and that feeling of excitement among the attendees was a common feature of every conference targeted towards Windows developers.

In the late nineties the development team that I worked on had an MSDN site license for about twenty seats for literally every piece of software licensed by Microsoft for about $20,000. That included MS SQL Server, Visual Studio and SourceSafe, MS Office, MS Project, etc. For comparison, that’s about $1,000/seat for everything. When we first licensed a Java IDE before Microsoft got into Java we spent about $100/seat. So $1,000/seat for everything in Microsoft’s portfolio is a pretty good deal.

When Microsoft came out with their Visual Studio addon for Java they handed out free copies at every developer’s conference.

And Microsoft’s certification program for MSVC++ and other core technologies was actually useful, and came with access to developer forums where the folks who worked on the APIs responded to questions.

Nearly every other tech company was behind Microsoft in supporting the developers using their products and it allowed Microsoft to gain a huge critical mass of loyal developers. One of Apple’s biggest success stories was wooing developers back with Steve Jobs’ charismatic keynotes at WWDC, and with better dev support.

6

u/sthlmtrdr 7d ago

Yes they inherited it. NextStep and OpenStep is pure Objective-C

1

u/thommyh 2d ago

Pedantically, Apple's period of charging for toolchains and its period of using Objective-C don't overlap. But it's hard to swim back upstream in terms of mindshare.

0

u/mdriftmeyer 1d ago

Apple was not NeXT during this period. NeXT and later Openstep (co-developed by NeXT and Sun Microsystems) was supplanted by Java at Sun which took over the Enterprise space. To this day, C++ is not king of the Enterprise. It is Java. The paradigms developed at NeXT are all being copied furiously by Microsoft, Oracle, IBM, so on and so forth.

C++ Syntax has always been ass. So is Swift, so is 99.9% of programming languages. C++ syntax was adopted by the FOSS communities and C++ was fore fed to Computer Science curriculums in the early 90s as they were transitioning from FORTRAN/C and the heavy computational aspects to Data Structures. Data Structures in C++ are spaghetti garbage.

Swift is a bastard child of ObjC/C++/C with functional computing aspects, generics, crap throw in from two dozen other theoretically over churned ideas the past 30 years after OOA/OOD took the globe by storm.

Meanwhile, Apple is a $5 Trillion ecosystem where the platform could as well modernize ObjC, give several new syntax approaches to STFU nerf crowds, take the advancements of Swift, Rust and other languages (all of which will never supplant C as it finally gets modernized) and people will still proclaim in two decades Linux is taking over the world.

One certainty, Apple will reach a $10 or $20 Trillion company and most likely split off into four separate corporations long before Microsoft achieves the status of $5 Trillion (even though they suffocated progress in computing for over 3 decades before NeXT reinvented Apple).

Ironically, FORTRAN is in high demand due to HPC/AI and is yes being brought up on C++ because it is the most overly written programming language with the most eyes on it so it's a safe bet to modernize the Flang via Clang and LLVM.

But let's talk about Rust. It's going to be the next blah, blah, blah, just like D was going to supplant C.

Most of Apple's macOS code is C/ObjC/ObjC++/C++ even though Swift is nearly release 7.0 and SwiftUI is around full of flaws, performance issues and more. Apple ripped out Swift/SwiftUI in Apple Music a few years back, modernized Cocoa some more an optimized their stacks in ObjC to fix all the issues they were having. Why? Because even though ObjC is officially 2.0 it has nearly 4 decades of brilliant minds who have worked on it.

K&R at AT&T Bell Labs were in charge and tightly controlled the evolution of C before Bjön Stroustrup left Bell Labs in '79; while there he was developing C++ in-house there. It was called C with classes back then.

He's fortunate people didn't legally shut down C++ development as it was clearly Bell IP.

Stepstone developed ObjC in 1985, NeXT adopted it in '89 as the top architects who followed Steve wanted OOA/OOD and a chance to develop a true workstation operating system. They succeeded. Microsoft hosed NeXT out of Office after committing to porting it as they feared adoption would have been high and Bill sandbagged the deal.

I write as someone who worked at NeXT. PIXAR took over Steve's focus after the release of NeXSTEP 3.1 on Intel hardware. By '96 we infiltrated Apple and brought our Quad FAT binary architecture and reinvented OS 9 into Openstep light 5.0 called OS X. We created the XNU hybrid kernel written in C/C++ with mach-o messaging which accelerated ObjC messaging immensely and made device driver development more rapid as 3rd party OEMs were strictly C/C++ houses for accessories.

Internally, we had Yellow Box, Red Box, Blue Box, etc, teams bringing up the OS. Ironically, just like NeXT, Apple did more with less resources and finances than Microsoft, Google, Sun, Oracle, etc., did in just five years. Apple and Steve's revenge began with the iPod/iPhone and expanded to what is today and continues to expand.

Windows by design is a kludge just like C++. C/C++ are each industry de facto standards, just as Windows and macOS are in consumer operating systems. Three operating systems with industry adoption in no more than realistic as standard, than three standard consumer operating systems. Linux is king on the server because UNIX vendors priced themselves out of control.

Apple reinvents CPU designs by pushing the envelope forward with Silicon and AMD rose from the ashes set ablaze earlier by Intel who suffocated IT along side Microsoft with their tightly coupled OEM all encompassing licenses. How did AMD do it? They mimicked Apple and have been steadily expanding their IP, talent, acquisitions and vision. Zen is juggernaut that keeps evolving even when ASIC designs keep sprouting everywhere like weeds in their market spaces. They'll sooner rather than later eclipse $1 Trillion without Nvidia's taint.

Apple will not compete in the enterprise beyond their own massive in-house deployments tethered to their own server scale Silicon chips. They don't need to do so. They'll continue to expand globally their deployments, have redundancy instances in AWS and extend their ecosystem into new frontiers never caring about market share while simultaneously being the most valued company on the planet.

What's sad is people spent decades fighting over programming languages and paradigms, and now many of those folks are being obsoletely by machine learning LLM/LLA solutions using FORTRAN/C/C++, but mostly FORTRAN where precision and vector scaling is king. It's mostly slop at the consumer level but vital at the applied science fields and advances hundreds of fields.

Most of these discussions now will be fighting over table scraps moving forward.

114

u/simonask_ 7d 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.

2

u/tastygames_official 7d ago

I so wish this were true:

"Clean" Code, Horrible Performance
Object-Oriented Programming is Bad
Programming - The Single Source of Truth Principle
The purest coding style, where bugs are near impossible

now I know you said "largely" for free or however you put it, and if done sparingly and in a very C-like way then yes - you can get very similar (still not exact) performance. But unfortunately modern "wisdom" and the OOP abstraction addiction means in reality you're something like a few hundred times slower for typical applications. Now we've 1 milion xed our hardware performance over that time so it's still a win, but it's the reason why all software seems to take the same amount of time to run despite massive increases in hardware capabilities.

29

u/simonask_ 7d ago

My point is that C++ (contrary to Objective-C) lets you opt in or out of things like dynamic dispatch, but you can still have nice things like encapsulation, generics (templates), and so on.

By the way, it's a misunderstanding to say that performant C++ is "C-like". C++ code can very often outperform equivalent C code, because of things like static dispatch. The classic example is std::sort versus qsort(): The former can inline its comparison function, the latter takes a function pointer, a form of dynamic dispatch.

For the record, I think C++ is a terrible mess of a language, but it certainly isn't slow.

7

u/Wertbon1789 7d ago

Yeah, one thing that makes C++ unreasonable good performance-wise is it's ability to almost completely throw away the abstractions used in the code. You can make readable code, reason about performance, and still have resulting assembly that's coming quite close to what one would've done in C, without some of the hassle. Also, that most of the C++ standard library (mostly templates, I think) is inlinable, and not a hard function call gap, is amazing.

7

u/gremolata 7d ago

On the flip side, with these abstractions it's also very easy to end up with kilobytes of code fronted by an innocent looking statement.

Something like if (! map[x]) map[x] = y; looks sensible, but will run 2x slower than a bit more verbose version.

1

u/b00rt00s 6d ago

The map example is great, but in my opinion, in favour of C++. This kind of code could be written by either junior or someone coming from a different, higher level language. However, if you think of it, then regardless the language you have two lookups into the map that must be slow. C++ at least give you a other options to make it faster. One can of course argue that C++ gives you false confidence of zero cost abstractions, when the truth is not that simple. Personally, I believe that anyone who knows the language knows also how complicated it is and wouldn't fall into this kind of a trap.

1

u/_usr_nil 6d ago

What's the better code ?

2

u/gremolata 6d ago

auto & z = map[x]; if (! z) z = y;

This does one lookup vs two in the simpler code. For a large map it matters.

0

u/Wertbon1789 7d ago

Yes, I more meant that you can represent code with more abstractions and not lose out on performance, not that it's always true. And especially C++ is infamous for its foot-guns.

1

u/antara33 6d ago

"C++ gives more of everything so have, including foot-guns".

That being said, C++ foot-guns are well known today AND we have incridibly good linters and AI tooling that can test execution paths to find those foot-shotguns.

-1

u/jerrygreenest1 7d ago

Well that’s the entire point: it depends on developer. You said initially:

Yeah, one thing that makes C++ unreasonable good performance-wise is it's ability to almost completely throw away the abstractions used in the code

And that «almost» word is nigh invisible, like it isn’t even there, it sounds so sweet like these free abstractions are automatically given to you by default just by using C++ . No. It’s not given. You can still write horrible code that works multiple times slower – and attached vids.

You technically aren’t wrong because of your careful «almost» word – these vids are basically the showcases of how that «almost» is actually  a  lot of C++ programming. Abstractions aren’t really free. You say it’s free, like mantra. But examples and examples show differences, proving the otherwise. The fact that in some case an abstraction can be free, doesn’t make it universal rule, and you say it like a  universal rule. Like it is a given (2). But it isn’t a given (2). It depends on the programmer using the language (2). Sorry for repeating.

Obviously it all just says: why C++ is often bad and costs us years of hardware development for all these «free» conveniences and «best (slow) practices» and it doesn’t really answer the question:

Why did historically C++ crush Objective-C?

And the answer is basically: C++ is bad and costs us years of hardware development, yes… but Objective-C is worse (heap allocation everywhere which is even worse than «free» abstractions – to which they might indeed look free).

That, and there was another good answer about the language being tied up too much to Apple in the 80s and 90s and requiring you to buy Apple to program in it whereas C++ was distributed for free for all and handed over like free candy. Superior distribution is worth a lot. And cheaper (but not free) abstractions = also better.

So two betters = C++ crushed Objective-C.

3

u/tastygames_official 7d ago

I personally never find abstraction more "readable". It just hides what's really going on and makes me have to dance around multiple files just to find out how it works. Now I know in really big teams this is actually a boon because you can just know that object.do_thing() will do the thing you request it to do and the documentation/function definition tells you what needs to go in and what comes out so you can work on more things faster, but when there's something that needs fixing inside of ObjectType::do_thing() then it's a royal pain in the ass to figure out what is actually going on and how to fix it. Especially when do_thing() calls multiple other functions and ObjectType implements multiple interfaces and inherits multiple classes and at the end you just have some function like:

PropertyValue BaseClass::get_property_value(PropertyType prop, ValueType val)
{
  return prop[val];
}

and yes - it's "elegant" that so many classes can utlize this very simple function to get at and validate all sorts of properties in a generic way, but debugging and performance-wise I just want to cry.

3

u/Illustrious_Trash117 7d ago

I also like the templating and compiler abstractions you can get with C++. You can get a whole of abstractions that after compiling boil down to a single function call. I use this in uC software where i wrote a template based abstraction of interfaces and sensors, so you can define multiple sensors and attach them to an interface. Then you just call read() on the sensor, this makes it clear what you want on what interface the sensor is and generally makes the code easy to read. Even with this level of abstraction it all boils down to inlining the register operations to controll the interface and read the data.

0

u/gremolata 7d ago

The classic example is std::sort versus qsort()

I'm pretty sure it's the only example :)

Well, maybe the inlining of virtual function calls when the pointer type is of a leaf class... but can't really think of anything else.

1

u/simonask_ 7d ago

Only because there are very few composable things in the C standard library, and qsort() is one of them.

Every time you have anything "generic" (i.e., some behavior is injectable, either in an algorithm, but also a data type like a collection), it makes a difference whether the compiler is able to statically specialize the instance of the generic function or data type, because it can produce optimally efficient code without indirect calls or undue heap allocations.

This is called "monomorphization". In languages without it (like C and Java, and every dynamically typed language), there is a pretty severe performance gap.

The only way to achieve this in C without losing your mind is by using macros to perform manual monomorphization, and you'll still lose your mind slightly. Or just go for the less efficient dynamic solution, which is good enough in many cases.

2

u/agentoutlier 7d ago

Java has monomorphization it’s just not done at normal compile time.

I say normal because the JIT is sort of a compiler.

Because of this and various other JIT related optimization particularly with allocation Java can sometimes run faster than naive poorly written C code but less often than C++.

1

u/simonask_ 7d ago

To my knowledge, Java never monomorphizes when the generic argument is a class type, and doesn't support non-primitive value types until "Project Valhalla". My knowledge could be out of date, though, I haven't kept up with Java for years.

2

u/agentoutlier 7d ago edited 7d ago

I just want to be clear here. I’m not talking compile time.

It absolutely does code specialization for types based on the JIT regardless of it being a Class but yes Valhalla would make more invariants and in theory a faster path to this.

Most JITs do this.

In some cases type erasure actually helps this process.

What they don’t do is have actual name mangled methods.

Edit some of this is covered here:  https://shipilev.net/blog/2015/black-magic-method-dispatch/

2

u/gremolata 7d ago

The only way to achieve this in C ... is by using macros

Well, exactly. It is doable, just not very convenient.

The qsort example is more on point - as in, the standard library sort in C++ will always be faster than that in C - but as I said it's pretty much the only mainstream example of C++ speed advantage over C.

-1

u/tastygames_official 7d ago

yes, I do know individual implementations of some algorithms under some compiler conditions C++ can outpace C (I think I've even seen Rust do the same), but "out in the wild" a complex GUI program written in C++ will generally have way worse performance than the same thing written in C - not because the language or compiler is bad, but because the "standard practices" for the languages are bad ;-)

4

u/simonask_ 7d ago

I don't think that's every remotely true in any sense.

1

u/tastygames_official 7d ago

the great thing about truth is it holds true whether you believe it or not ;-)

also, which piece don't you believe is true? that under very precise conditions some languages can beat out C in performance? Or that over-engineered OOP crap will always be slower than beginner-level non-OOP software?

5

u/simonask_ 7d ago

The conditions do not have to be very precise for realistic C++ or Rust code to beat C in terms of performance. Neither forces any kind of OOP.

Spaghetti OOP ("clean" code) is bad and annoying for multiple reasons, but you're not going to feel it in a UI at all. You might feel a GC pause, or an expensive computation on the UI thread, but you can do many thousands of indirect calls in a millisecond, many more before we get into the territory of human perception.

1

u/catladywitch 7d ago

there are basically no complex GUI programs written in pure C "out in the wild"

3

u/glasket_ 6d ago

GNOME and all of their applications? I think Xfce still uses C for their stuff too.

I don't agree with the other comment, but there are complex GUI programs written in C.

3

u/xpusostomos 6d ago

Every Motif program was C and many gtk ones

1

u/xpusostomos 6d ago

What standard practice in C++ GUI programmes makes it slow? That's an odd claim

2

u/tastygames_official 5d ago

SOLID OOP and a bunch of other stuff/acronyms I never learned but have to deal with every time I work with "enterprise software" or "modern software". I just mentinoed GUI since I knew somebody would come up to me with some CLI tool that is done in C++ without OOP and that's not what I meant. I mean stuff like Chromium or Thunderbird or any web "app" or anything done in Electron or similar will just use some insanely abstracted and lose so much in performance. The reason they do this is it's easy to hire somebody who knows the framework and the OOP principles rather than hiring somebody who will be around for the long haul and take time to get up to speed with the codebase. So it's purely a business decision based off of saving moeny and comes at the cost of debuggability and performance. But many devs also bought into the "complex is cool!" pitch that bloated frameworks offer so that they are in alignment with the execs who want to copy what silicon valley is doing because it's the cool thing to do.

I know I'm in the minority on this, but it's tough to find real-world examples to convince people otherwise since this hasn't been done since the early '90s. I mean, I guess you could run a copy of win3.1 notepad and win11 notepad and see that although they have the exact same feature set, the latter runs probably a few hundred times slower due to its complicated MFC hierarchical abstraction. Or maybe if m$ft actually kept the original code and didn't turn it into OOP, then just have someone write an OOP notepad using some GUI library and see the performance difference. I'll just say this: there's a reason high-performance libraries tend to be written in C or at least with very minimal class nonsense.

But in the end it doesn't matter because that's the software we get these days and nobody knows we could have it better.

10

u/RappyPhan 7d ago

C++ doesn't mandate that you write 'clean' code, nor does it force you to abuse OOP, or even use it at all. C++ is multi-paradigm.

Your argument essentially boils down to "you can make terrible coding choices in C++, therefore all C++ code results in horrible performance", when the truth is that you can write terrible code in any language.

0

u/tastygames_official 7d ago

exactly. You can write C++ just like you'd write C and be totally OK. You can go nuts and use SOLID principles and every paradigm and design pattern under the sun and shoot yourself in the foot. But in my experience, if you *can*, then most people will. It's tough finding higher-level language projects that DON'T do this. Small utlilities and the odd plugin for some larger ecosystem: yes, but generally high-level = people take it way too far.

[Bruce_Banner.jpeg]
"you wanna know my secret? I ALWAYS write terrible code"

1

u/catladywitch 7d ago

I don't think corporate OOP architecture and the choice between slow, convoluted messaging paths and direct, spaghetti messaging paths are what they meant about C++'s zero-cost abstractions. Muratori's point is about OOP having wrong encapsulation boundaries. Nik Barker's point is about programming style, particularly when designing frameworks. As for functional programming, I personally love it but as a declarative paradigm, it tends to be very abstract, and having no state and no mutability can hugely impact performance depending on what you're doing and how the language you're using handles allocation. Those videos make some interesting or even great points but I'm not sure what the connection to the concept of "zero-cost abstraction" (i.e. constructs that get compiled away as much as possible and which don't make you pay a performance penalty for features you don't use) is.

Zero-cost abstraction is, for instance, a foreach getting compiled into a normal for. Non-zero-cost abstraction is LINQ in C# having both an allocation and throughput penalty over fors and ifs.

0

u/montymole123 7d ago

Agreed highly abstracted, templated C++ programs written in modern C++26 style can run much slower than the same algorithm expressed in C. When you compile with optimisation the compiler can often kick out some of the junk and get back to C like performance but it's often necessary for the debug non optimised code to run fast too (eg games). Templated code also takes forever to compile which matters when you code base grows to millions of lines. A C++ code might take 1 hour to compile while the equivalent C would take 5 minutes this makes a big difference to productivity.

50

u/an0th3rbrick 7d ago

probably because objective C is more dynamic which comes at a performance cost

51

u/MaxComfort 7d ago

This, and the weird brackety syntax.

Not to mention vendor lockin - is there any serious use of Obj-C outside NeXT/Apple platforms?

9

u/R-ten-K 7d ago

I never really thought C++ had particularly better syntax. If anything, Objective-C always felt (to me) it had a more coherent design when it came to expressing the original ideas behind object oriented programming, especially the message passing model. It felt like the language was designed around those concepts rather than having object orientation layered onto an existing programming model.

I also liked how explicit and expressive the messaging syntax was, even if it looked a little unusual at first.

But I agree that its initially proprietary ecosystem was a significant obstacle to wider adoption.

4

u/techoptio 7d ago

I was surprised I had to scroll this far for someone to mention the syntax. It just feels so different from most other languages imo (especially other C-family languages).

2

u/aieidotch 7d ago

objfw, gnustep

ApplicationKit and FoundationKit are both well designed, elegant frameworks

2

u/Total-Box-5169 7d ago

OMG, is even worse than I expected.

33

u/R-ten-K 7d ago • Bravo

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.

21

u/PseudoFrequency 7d ago

C++ is a standard with many vendors. Objective C was virtually only Apple.

8

u/EpochVanquisher 7d ago

At the time, Apple didn’t use Objective C

1

u/xpusostomos 6d ago

That just pushes the "why" back another level.

8

u/Narishma 7d 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.

7

u/manicakes1 7d 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/thommyh 2d ago

I think you might be focussed on the wrong metric; with dynamic dispatch comes compact code — there is only one blob of code for NSArray whereas std::vector is potentially a fully distinct recompilation per type it holds. Ditto there's no need for the hidden code generation that goes with UI design on other platforms.

It helps a lot if you're trying to ship something of NextStep's relative modernity on the original 8mb hardware.

2

u/manicakes1 2d ago

Interesting perspective, thanks. Sounds like trading smaller binary size / memory footprint for a few extra instructions.

I knew a very senior engineer who was a key player in Swift’s early development. He was of the mind that Apple should have just invested more into Objective-C than inventing a new language. Objective-C evolutions of recent years like objc_direct (opting into direct dispatch while keeping method semantics - in certain situations) makes me think he’s right.

20

u/imMakingA-UnityGame 7d 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

8

u/stianhoiland 7d ago

back then felt like C syntax

Oh that's a good point.

11

u/finleybakley 7d 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

19

u/zhivago 7d 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.

8

u/xeow 7d ago

Wait till you learn that Objective C++ is actually a thing! :-)

5

u/gremolata 7d ago

Daaaamn... so it's basically Objective C code mixed with C++ ?

God almighty.

2

u/Mementoes 6d ago

Objective-C is a very small addition to C with deliberately weird/different syntax. You can just add those same things to C++, and it won't conflict.

1

u/xeow 6d ago

Exactly that!

1

u/thommyh 2d ago

In practice it mostly meant: doing the UI fully natively in Objective-C and leaping from there into your probably cross-platform C++ code to do all the substantial work.

So there was a small set of Objective-C++ bridging the two worlds, not a lot of it pervading the project.

2

u/xpusostomos 6d ago

I'll wait for objective zig++.

4

u/Responsible-Bar7165 7d ago

It might have something to do with the fact that reading objective-c code is like sticking pins in your eyes.

4

u/Leverkaas2516 7d 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/thommyh 2d ago

This undersells toll-free bridging, which Apple once relied heavily upon; there are plenty of Objective-C types that are also C types. So you can use the same pointer as an object or just pass it to a C function and the C function doesn't need to be aware of the Objective-C runtime at all.

So e.g. a CFString is an NSString (if memory serves).

4

u/nacaclanga 7d ago

Objective C and C++ follow a very different approach of adding Object oriented features to C.

To understand this one has to keep in mind, that object orientation was originally invented for dynamically typed interpreted languages. Binding a method to a message happens at runtime in these languages.

In Objective C the approach was to effectivly keep the dynamic, interpreted nature of this interaction and only compile the actual interpretation. This is then coupled with a runtime, which is basically an interpreter minus the functions that are easy to port to native code.

The usual runtime for Objective C is propietary and part of the NextStep / macOS ecosystem.

This approach is nice for GUI calls and the like but ultimativly rather slow.

In contrast C++ went further and modified the ideas of object orientations by imposing static typing and similar feature (like linking polymorphism to inheritance) to allow the OOT logic be fully lowered at compile time. Which is how C++ gets no performance penalty for it.

10

u/demetrioussharpe 7d 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.

4

u/Ok-Library-8397 7d ago

AFAIK, Objective-C used a messaging system from Smalltalk programming language. Instead of calling methods as in C++, in Objective-C, you are sending "messages" to objects. The problem is that finding the recipient of the message (i.e. an address of the procedure code) is done at run-time, where calling a virtual function on a C++ object requires just one index read from a virtual function table to get a code address (one memory read more, plus indirect jump, from CPU perspective). Even with various optimizations in Objective-C, the C++ approach is faster. I don't claim that C++ is a perfect programming language by any mean, but it allows to use OOP abstraction with relatively small performance hit, and a user can always implement his own messaging system on top. P.S.: I suspect exactly that was behind the decision of moving from Objective-C to Objective-C++ (i.e. adding C++ inheritance and virtual methods), before shifting to Swift programming language in Apple.

2

u/demetrioussharpe 7d ago

Message passing was always considered as too slow to be practice, for most usecases. However, over the past 3 decades we’ve seen message passing become more performant than it initially was in microkernel, system library, & language usecases. Combined with the fact that hardware advances have made slow paradigms fast enough to be acceptable (JVM), I have little doubt that the benefits that Objective C bring would’ve been beneficial enough to cause people to abandon C++.

2

u/Mementoes 6d ago

Opus 5.5 estimates an objc_msgSend costs 3ns vs a C function call costing 1ns on modern hardware.

NeXT computers were built on this in 1989 iPhone was build on this in 2007. This is not a bottleneck in practice.

And Objective-C is a C superset. So if you really have a hot path where this matters you can just use a C function.

1

u/xpusostomos 6d ago

Next and Apple only really used it for the UI which is the perfect use for it, very dynamic dispatch, but no need for high performance. Anything in next that needed high performance would just not use objective C dynamic dispatch.

1

u/Mementoes 4h ago

i think it wasn’t just UI. I know next used it for device drivers too

5

u/zlowturtle 7d ago

Objective C is slower than C++. There are plenty of industries where speed is critical. Your last sentence is incorrect.

8

u/demetrioussharpe 7d ago edited 7d ago

I’ve been around long enough to know that languages that are open to the widest range of users have the largest amount opportunities for advancement. Given the opportunity to be used by the masses, the speed issue could’ve been solved. My last sentence isn’t incorrect, you’re simply fixated on what Objective C ended up being -you never considered what it could’ve been.

2

u/zlowturtle 6d ago

Objective-C is slower than C++ primarily because it relies on dynamic runtime message passing instead of compile-time resolution. I work in the financial trading industry. Nobody in my industry would have used it. It probably is ok for gui apps. Aerospace, industrial, medical, defense, robotics, AI, cloud servers, rely on absolute performance. Swift is faster than objective c yet C++ is still being used.

1

u/demetrioussharpe 6d ago

My previous comment still stands, regardless of industry.

1

u/xpusostomos 6d ago

If there's dispatch, then it's not compile time by definition. I didn't look too deeply at how objective-c dispatch worked, it seemed to be some kind of hash of the function signature which was slower than C++ but fast enough for many usages.

1

u/CowBoyDanIndie 3d ago

Compile time polymorphism through templates

2

u/RappyPhan 7d ago

> Otherwise, it would’ve most likely relegated C++ to the dustbins of history.

What do you base this on?

4

u/demetrioussharpe 7d ago

I based this on experience, especially as someone who’s C++ development started in the 1990s. The truth is that C++ is a cumbersome language with awful syntax in terms of OOP, & hacky mechanisms. The only reason that it’s survived this long is because nothing more elegant has been able to be presented as a general purpose multi-platform language. And each year, the standards committee has tried to fix C++’s shortcomings, only to make matters a bit worse each time. It doesn’t do C things better than C, but also doesn’t do OOP things better than Objective C. What it DOES do better than Objective C is speed. And if Rust wasn’t so cumbersome & filled with weirdo pro-rust, anti-everything else activists, Rust might have a chance at pushing C++ out of relevance. That’s just the raw truth of it. C++ is good enough, but it’s not great -and never will be. Objective C could’ve been great, but was stymied by Steve Jobs.

1

u/ICBanMI 7d ago

The biggest reason no one has pushed C++ off the top of the mountain is because no one wants to pay the massive cost to start rewriting stuff in Rust/Objective C/C#/etc.

That might change now that companies are getting endlessly cyberattacked by AI, but for the last decade C++ has kept the crown because no one wants to be the first to pay for that rewrite.

The vibe coded stuff isn't helping. Just causing more chaos.

1

u/demetrioussharpe 7d ago

No one really has to immediately rewrite anything. All that’s actually necessary is to replace the current incumbent platforms with platforms that other languages already have a solid foothold on. As time goes on, others will fill the gaps organically. When it comes to systems languages, one of the first things that usually happens is that utilities & libraries start being created in those languages anyway. However, when it comes to something like “libc” & “libstdc++” (or architectural equivalents), they don’t even have to be rewritten. Eventually, systems languages will start creating their own runtimes & higher layer systems will be ported to those libraries. Eventually, the majority of particular ecosystems will already be off of C & C++. But in order for that to happen, the replacement has to be an actual low level systems language & must have unlimited general access, instead of being chained to a singular platform. Rewriting old code isn’t as big of an issue as most developers assume it is, given enough time.

1

u/ICBanMI 7d ago

No one really has to immediately rewrite anything. All that’s actually necessary is to replace the current incumbent platforms with platforms that other languages already have a solid foothold on. 

That's not how it works for automotive, embedded (RTOS), medical, avionics, defense, databases, and a slew of other industries that are trapped in C/C++. That won't happen to programs that have been iterated on since the 1990s and still being used today: wallstreet, modern operating systems, etc. No one wants to rewrite, retest, and recertify something that is 200-600k lines of code. If a customer volunteered (PAID) to be first, could wait a decade, and could competely ignore its end users experience getting worse despite being the same product... then industries would eventually switch, and future customers would get the discount largely paid by the first. These industries are the backbone out of sight that support everything.

It's fine for students, new web apps, video games, and stuff newly being written for the first time. But the metric is talking about the entire backbone of modern life that can't just switch just because the investment and problems it would require fixing would be absolutely costly and devestating to their user base.

1

u/demetrioussharpe 7d ago

Ok, sure. In those cases, they’ll inevitably be forced to rewrite all of it from scratch, as the rest of the tech world eventually moves completely away from C++. It’s really a matter of time. Even if it doesn’t happen in your lifetime, it’s still going to happen eventually -assuming that those industries haven’t transformed into something else. Programming languages don’t live forever, no matter what they are.

1

u/ICBanMI 7d ago

Ok, sure. In those cases, they’ll inevitably be forced to rewrite all of it from scratch, as the rest of the tech world eventually moves completely away from C++. 

I love how you didn't know these industries existed. Don't know how massive they are. But are cocksure they'll all eventually have to capitulate to the people who don't know, don't care about their tech stack.

I'm not disagreeing with you, but you pivoted from... it's going to be easy to switch... to... everyone will have to switch eventually. Your goal post moving of saying it'll eventually happen is just proselytizing to someone who is already aware.

Until someone pays, the hardware/software becomes too obscure to support, or regulation forces us to update... the MBAs are never going to let us spend a single dollar on switching. It's not going to be cheap or easy. It's not going to be for any of your made up reasons.

1

u/demetrioussharpe 6d ago

I knew those industries existed, but honestly they don’t matter as much to the overall tech industry as other industries do. It’s fair to call them domain-specific, because most of those products are embedded. In pretty much every one of those industries, the entire tech stack could potentially be virtualized completely inside of a multi-core processor & wrapped in a memory safe shell. The same thing that happened to financial applications running COBOL could be done in those environments.

1

u/ICBanMI 6d ago

I knew those industries existed, but honestly they don’t matter as much to the overall tech industry as other industries do. 

You say that and then you immediately say something else completely wrong about this industry.... in a the C programming subreddit where most of us employed in it (not academics, students) are working on embedded devices or embedded systems: MPSoC, FGPAs, federated, and integrated systems.

It’s fair to call them domain-specific, because most of those products are embedded.

I mean. You can type into your llm and it'll tell you python and web development is the biggest and most popular thing, but they're not trained on companies IP or any one's company owned code bases for reference. Some of those code bases have in the millions of lines of code one just one project. Companies that have been around for decades often have several.

You said it could be easy, then you say it's inevitable (which no disagreed with you), and now you're saying it's a solved problem using virtualization, compatibility layer, or emulation. But you don't seem to grasp any of these software solutions would still need the same verification, test, and certification in a lot of industries as the software code and tools currently have costing millions to go through the same process the code went through for hundred of thousands or even millions of new lines of code, plus new hardware.

It's a major cost problem that no one wants to pay for which is why the US government has been asking us for years to move to rust, but we've barely budged.

→ More replies

1

u/septum-funk 5d ago

i mean, microsoft rewrote their os once when they started nt i believe they will again eventually, but they've waited far too long imho. and there's nothing wrong with continuing to use C and C++

3

u/azswcowboy 7d ago

Not op, and there’s no evidence — but the main point is a lack of portability. Objective C was single platform while c++ was an ISO standard implemented on lots platforms with several compilers maintained by vendors like Sun.

1

u/sreekotay 6d ago

Next only licensed objective-c. But that was the actual problem: it required a license

1

u/demetrioussharpe 6d ago

No, they licensed it in 1988, but outright acquired it around 1994-1995.

1

u/sreekotay 6d ago

Correct but that gap - C and C++ being open / no licensing fees is a big part of why objective c didn’t make it

Next acquire/hired in 94 because they had to

1

u/demetrioussharpe 6d ago

Whether they had to or not, they still did it -so, from 1994/5 they had the opportunity to open it to the world, because they owned it outright, but they didn’t. Even opening it back in 1998 could’ve revolutionized the industry in terms of general purpose languages.

3

u/Physical_Dare8553 7d 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

3

u/TheBestAtSpace 7d ago

Objective-C dynamic dispatch was much much slower.

3

u/Engineer-4-fun 7d 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.

3

u/Sniffy4 7d 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.

3

u/YouFeedTheFish 7d 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.

3

u/Available_Safe1818 7d ago

Yes, your prediction is naive. C++ was first. Also, Obj-C syntax still looks like diarrhea.

3

u/xpusostomos 6d ago

Objective C is a very very different beast than C++. It's slower, but very dynamic. Which makes it perfect for what Apple used it for: user interfaces. The syntax is half Smalltalk half C which made it an oddball stylistically. It didn't try to have all the bloat of C++ for better or worse. It was trying to be Smalltalk... Not strongly typed, but dynamic.

2

u/podule-games 7d 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.

2

u/BlockOfDiamond 7d ago

Probably because Objective-C uses slow dynamic dispatch whereas C++ calls functions directly with implicit first arguments.

2

u/Hopeful_Push_9712 7d ago

I'm convinced C++ took off because of STL

2

u/Living_Fig_6386 6d ago

Marketing. Objective-C was adopted by NeXT and seen as an important differentiator for their platform so they took moves to prevent adoption outside of NeXT and tied some core libraries into NeXTStep. C++, on the other hand was quickly adopted in UNIX environments. The GNU compiler collection had compliant implementations of C++ by 1987 and they didn’t get a full Objective C runtime until 1992. A lot of software was written in that intervening period. By 1992, Microsoft had decided that C++ would be the primary language for Windows native programming and they released MFC. Once the juggernaut that was Microsoft crowned it, it became king.

8

u/ElectricSpock 7d ago

Because it was earlier, and there was no single company that pushed for it.

Next question.

1

u/ReallyEvilRob 7d ago edited 7d ago

C++ was also considered a superset of C. Over time, the language standards have slightly diverged.

As far as why C++ is more popular, I think it's because C++ is just older and more mature. Objective-C dominated on Mac OS and iOS, but that dominance was eroded by Swift. On other platforms like Windows, C++ has dominated since before Objective-C had any relevance and just simply kept its place.

2

u/Nobody_1707 6d ago

Objective-C is from 1984, so they're basically the same age. Objective-C was just never popular outside of NeXT/Apple.

1

u/ReallyEvilRob 6d ago

I stand corrected. I never really know much about the history of Objective-C. I only became aware of it around the early 2000 with Mac OS X.

I've been programming in C and C++ since the late 1980s and back then, Turbo C++ was my programming environment of choice. I eventually upgraded to the larger Borland C++ suite.

To my knowledge, I don't think Borland ever developed an Objective-C programming environment so availability on the PC back then was probably pretty limited, unlike C++.

1

u/EatingSolidBricks 7d ago

ObjectiveC ew 🤢

1

u/Far-Championship-883 6d ago

Because university's and tooling companies pushed c++ because it was good for business. EG very profitable to make a bad programming language that then rely upon external software to build software.

1

u/gokhan_plt 6d ago

FunctionDeclerationWithLongLongDumbFunctionName

1

u/Guycrimson99 6d ago

Because learning it was a plus

1

u/vegaseat 6d ago

Apple did make an effort to replace clumsy Objective-C with Swift.

I enjoyed exploring Swift and some of its Python like features.

1

u/Leop0Id 6d ago

Even at this very moment Apple demands a $100 annual subscription just to put an app that only I will use onto my own phone.

2

u/OtherOtherDave 5d ago

You don’t need to pay anything to load your own apps on your own phone.

1

u/Leop0Id 5d ago

Did you go ask some AI or something? Or does even a test deployment that's practically useless since it has to be redeployed every few days, count as "doable" to you?

1

u/Mementoes 6d ago

I think probably the main reason is the C++ STL. Objective-C's Foundation was only available on NeXT (which later became macOS and iOS). All expensive platforms with small marketshare.

1

u/Mementoes 6d ago edited 6d ago

I think NeXT thought the dev environment was their main moat so they wanted to keep it exclusive to sell their hardware. But through that they also made C++ win and when transitioning NeXT to OS X they scrambled to move Objective-C stuff to Java and C and C++ because I think they were afraid they wouldn't get developers on board with Objective-C which was seen as obscure even then I think.

They kinda failed at the Java transition so Mac and iPhone development ended up still being mostly Objective-C with some C and C++.

And then with iPhone Objective-C had decent market share for the first time. On modern Twitter there's a lot of memes about Objective-C being too verbose and having too many brackets in the syntax. But I think people who got more familiar with it mostly liked it a lot, even back to the NeXT days the dev environment was pretty well revered I think. (I personally really love it, and shill for it sometimes on the internet, because, even though Swift was my first language, I think the Swift transition has been mostly a bad idea and lots of good things have been lost, and Swift is a very poorly designed and unfocused language and goes against most things that make Apple great in my eyes, but that's another topic.)

Now that Apple has been signaling that 'Swift is the future' on their platforms for over 10 years Objective-C is naturally dying out. A modified Foundation became the standard library for Swift, which is now, finally, becoming a real multiplatform language with a multiplatform standard library. (It's a very unpragmatic convoluted language though, so it will never catch on.)

Chris Lattner said in some interview that when he proposed Swift, his management said, "But why? There is nothing wrong with Objective-C."

In a different timeline where the forces of good would have prevailed, maybe they would've skipped Swift and ported Objective-C Foundation to Linux and Windows instead, and then maybe, it could've really found a niche next to C++.

But oh well. That ship has sailed. Objective-C lost. All we can do is try to learn from it.

... And you can still use it if you're developing for Apple platforms!

1

u/roopjm81 6d ago

I mean have you tried Objective C? It's atrocious

1

u/happywoodcutter 5d ago

Have you tried [writing in objective C]?

1

u/a11yChief 4d ago

I can only speak for why I didn’t use it for long, the language was way less of an issue than the documentation. I was only a kid at the time, but I learnt several languages for windows, Visual Basic and VB.NET, a scripting language called AutoIt, php and eventually started looking at C for some short time before exams got in the way. Apple expected anyone getting onboard with Objective C to already know C front to back, which was way more common in 1990 than in 2007.

Then combine in the other stuff like the syntax looking like it was made for a bet, the main interface builder being separate to the code writer but still needing you to drag and drop to link code (I’m blind so that’s a nightmare), programmatic UI documentation was almost non-existent, you couldn’t use any other ui framework besides Apple’s, you couldn’t compile the code on anything other than Apple’s hardware, so in the end it just became easier to learn something else.

I stopped writing code for ages after I lost a hard drive, and the thing that got me back into it was the rust book, because it’s that well written. Documentation matters, and approachability matters. Apple’s languages have never had either at the same time.

1

u/Terminator_1_ 2d ago

I think because objective C is highly used for apple computers and early phones,while C++ was used in UNIX ,Linux and later windows. And people have been aleardy familiar with C because it was most used in UNIX and linux.

1

u/SauntTaunga 1d ago

Objective-C could be a bit clunky. It is C with a Smalltalk lookalike bolted on. It’s two languages stuck together.
The Smalltalk bits, conceptually sending messages to objects to get stuff done, was probably too strange for many.

1

u/me0262 22h ago

C++ was much more standards based and kept the same C syntax.

Objective C was more like the retarded cousin that no one really cared for, but with Apple using it for iPhone development, you had to use it most of the time (you could use C++ code in it, but you still had to have an Objective C framework to handle events and touches).

1

u/EpochVanquisher 7d ago

The major reason was tooling availability / licensing. It’s not really about the language.

1

u/HowardZyn 7d ago

Obj-C syntax just looks hideous

2

u/bacmod 6d ago edited 6d ago

Obj-C syntax just looks hideous

If I was a math person I could probably pick up stuff if I read C/C++ code syntax no problem. Variables, loops, functions - sure. Looks similar enough.

Not so much for Objective C. I would have to learn stuff to get a sense of it.

OC:

(void)printUserInfo:(NSString *)name age:(int)age city:(NSString *)city

C/C++

void printUserInfo(NSString *name, int age, NSString *city)

1

u/HowardZyn 6d ago

Yeah I think that’s probably where C and most other programming language syntax originated is from formal math.

2

u/bacmod 6d ago

There's a reason why Java, C#, Lua, JS, etc. are all following the same base syntax.

2

u/thommyh 2d ago

Hence Java.

Patrick Naughton relates:

When I left Sun to go to NeXT, I thought Objective-C was the coolest thing since sliced bread, and I hated C++. So, naturally when I stayed to start the (eventually) Java project, Obj-C had a big influence. James Gosling, being much older than I was, he had lots of experience with SmallTalk and Simula68, which we also borrowed from liberally.

1

u/xpusostomos 6d ago

Not to a Smalltalk programmer. But it didn't pretend to fit into C that's for sure

1

u/LavenderDay3544 7d 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/thommyh 2d ago

Minor overstatement there; most wouldn't call Clang a "locked down proprietary compiler platform".

Can't argue with the rest though.

0

u/LavenderDay3544 2d ago

Objective C and Swift are basically only maintained and have a working ecosystem on Apple OSes.

1

u/thommyh 1d ago
  1. is Clang locked down?
  2. is Clang proprietary?

Shifting the goalposts not to admit you were mildly wrong in a very small part of a comment isn't impressive.

To keep it up front:

Can't argue with the rest though.

i.e. the locked down and proprietary vendor hardware and OS, for any practical use of either language.

1

u/authorinthesunset 7d ago

Objective-c sucks. Though I will admit that NEXTStep was pretty rad at the time.

0

u/AdreKiseque 7d ago

Diaresis spotting

0

u/pedersenk 7d ago

You’d think that scratching that OOP itch while also giving you complete source compatibility with C would cause more companies

As per the C++ FAQ:

C++ is as much a superset of C95 as C95 is a superset of K&R C and as much as ISO C++ is a superset of C++ as it existed in 1985.

So C++ scratched the OOP itch whist giving complete source compatibility with C. Hence Objective-C wasn't very competitive.

That said, I really can see Objective-C++ coming back for Apple's ecosystem. Internal code never moved on to Swift and the drivers are all still C++.

-2

u/Ok_Outlandishness906 7d ago

for me c++ and object C are both terrible languages .