Remix.run Logo
waynecochran 4 hours ago

I still find Objective-C++ useful for writing MacOS apps that make heavy use of C++ libraries (e.g.; Eigen, OpenCV). The caveat is I have done a lot of Objective-C programming and Swift is still not as seamless as I would like bridging with modern C++ and the the STL.

billti 3 hours ago | parent | next [-]

I've been playing around with low-level Metal a bunch lately, any many of their docs and samples seem still be mostly in Objective-C/C++ and not Swift, so have been forcing myself to get into it.

At first I had the usual revulsion to the syntax, but after a few days getting used to it, I actually don't mind it at all now. (I still wouldn't say it's "elegant", but I can live with it).

Being Metal shader code is basically C++ anyway, and C++ is a language I'm familiar with, having a couple of .mm files to hold the Objective-C++ for API bridging and working in regular .cpp (and .h) files for the rest is pretty straight forward compared to having to learn Swift. (Especially with all the complaints I've heard about its complexity, including from Chris Lattner himself lately, which aligns with some of the other comments here).

Though to be fair, "Swift seems overly complex so use C++ instead" seems like a tough argument to make with a straight face ;-p

kridsdale3 39 minutes ago | parent | prev | next [-]

I made some camera and GPU-heavy features in the Facebook and Instagram app in ObjC++, and yes, it was nice to have that impedance match.

I don't work there anymore, I wonder if they're using the C++ - Swift interop that now exists.

frou_dh 2 hours ago | parent | prev | next [-]

Obj-C++ was used for some hall-of-fame OS X apps, e.g. TextMate

waynecochran an hour ago | parent [-]

I have my suspicion that it is still used heavily inside Apple. It especially caters to programmers that are control freaks like me -- you are a little closer to the metal (pun intended).

iainmerrick 3 hours ago | parent | prev [-]

Yeah, Objective-C++ is surprisingly great. It sounds like a terrible idea, but the bridging works pretty much seamlessly, and Obj-C and C++ don't actually overlap all that much so they don't step on each other's toes. Each language has strengths that shore up the weak spots in the other.

delta_p_delta_x 3 hours ago | parent [-]

+1 to Objective-C++. It makes for some surprisingly clean, compact code, best of both worlds, really. And the bridging between ARC and CF types is really quite magical, more languages should have that ability to be expressed in an older language without stripping everything out.

I just wish there were Objective-C bindings for more CF classes without having to mess with C.