views:

1937

answers:

4

I've been learning Objective-C and Cocoa by working my way through the Hillegass book and it occurs to me that I might be better off using Objective-C++. Objective-C seems like the clear choice for developing UIs but I have a very strong C++ background and would love to develop application back-ends in C++ and use Objective-C++ to do the UI integration. But I wonder if Apple will keep developing Objective-C++ or will it become a dead end.

Is anyone out there using Objective-C++?

+4  A: 

The only times I've used ObjC++ was to port libraries to make them accessible from my ObjC code. The clashes between how ObjC++ and ObjC handle things like exceptions and class creation and destruction just made it too much of a headache to juggle the two languages in one project.

I don't think support will go away soon as happened with Cocoa / Java since it is pretty solidly part of GCC, and the fact that Objective-C++ compiles down to straight C++ in the same way that Objective-C can compile down to straight C, but I still don't find it a very pleasant environment to build software in compared with Objective-C and being able to comfortably fully use the OS X-provided frameworks.

alxp
+1  A: 

Objective-C++ is likely to remain supported as long as Objective-C is. Obj-C++ is a basic goal for clang, which is expected to eventually replace gcc as Apple’s preferred compiler. Usage is likely to rise as Carbon applications are moved to Cocoa front ends.

Of course, the word “likely” appears twice above because Apple is so excitingly unpredictable. :-)

Ahruman
A: 

I suspect Apple will continue to support Objective C++ for a while, as I don't see any significant recurring effort required by Apple to maintain Objective C++ as Apple updates Cocoa and Objective C++.

Heng-Cheong Leong
+4  A: 

Disclaimer: I don't work or speak for Apple, so this is my opinion:

I can't speak for the major dev shops, but in my small group, we've used Objective-C++ both for integrating C++ libraries, and as you propose for writing backends in C++. As @alxp mentions, things like exception handling across the language boundary are painful, but with a little planning, most of these pains can be avoided. For experienced C++ devs, the gains can be well worth the pain.

In terms of support, I think you can assume that support in its current state won't go away any time soon. It's part of the GCC code base and the clang toolchain (presumably Apple's next compiler toolchain) explicitly plans to support Objective-C++. On the other hand, there isn't any official guarantee that Apple will continue to develop the integration—fixing some of the warts, for example.

For current projects, I would say that if using Objective-C++ provides benefit, it is safe to rely on the existing support and you should use it.

Barry Wark