Is it that Objective C is a better version of C with OO and C++ features?
If that’s the case why was Objective C++ created?
Is it that Objective C is a better version of C with OO and C++ features?
If that’s the case why was Objective C++ created?
> Objective-C++ does not add C++ features to Objective-C classes, nor does it add Objective-C features to C++ classes. For example, you cannot use Objective-C syntax to call a C++ object, you cannot add constructors or destructors to an Objective-C object, and you cannot use the keywords this and self interchangeably. The class hierarchies are separate; a C++ class cannot inherit from an Objective-C class, and an Objective-C class cannot inherit from a C++ class. In addition, multi-language exception handling is not supported
From a Stack Overflow comment / archived Apple docs: https://stackoverflow.com/a/3684159 https://web.archive.org/web/20101203170217/http://developer....
Things might’ve changed with Swift being around now, but as I understand one place where the Obj-C UI + C++ internals setup used to be common was Audio Unit extensions due to the high latency sensitivity of anything working with audio.
It’s functionally the equivalent of how you can use C code within C++ code, and a hint to the compiler to allow parsing of C++ syntax as well as ObjC
The biggest public user of it would likely be webkit, but plenty of closed software both in and outside of apple use it.
But the reality is that it is at this point primarily a bridging language. Post the introduction of ARC one of the biggest win/reason to use it over raw objc went away.
But it’s still tremendously valuable as a way to have a nice API that is also ABI stable in a way that isn’t the C and C++ misery pit. Of course now swift has the same ABI stability support as well as a slew of other improvements so there seems ever less reason to write new objc.
Long ago, c++ exceptions and objective C exceptions didn't play well together but they've been unified so that's not an issue anymore.
(In the beginning, Objective c exceptions were macros around setjump()/longjump(). Objective C 2.0 added actual language level support with @try/@catch/@finally/@throw which were compatible with C++ exceptions)