4 ms·
I’ve been bitten enough by Objective-C++ compiler bugs (Apple’s attempt at mixing Objective-C and C++), as well as bugs in Apple’s code in the Swift ecosystem,
by meisel 3y ago
I’ve been bitten enough by Objective-C++ compiler bugs (Apple’s attempt at mixing Objective-C and C++), as well as bugs in Apple’s code in the Swift ecosystem, not to trust the stability here for at least several years. I also don’t see how this is much better than just creating a C or ObjC wrapper around a C++ library, rather than needing to keep C++‘s complicated language features, and Swift’s interop with it, in my head as I use the library. Were there people clamoring for this? I can’t really see the point.
- pjmlp 3y agoHistory class, Objective-C++ was created by NeXT.
- KerrAvon 3y agoActually compiler bugs or just badly documented interactions between the two models, leading to misunderstandings?
- plorkyeran 3y agoI don't think I've ever encountered an obj c++-related compiler bug in close to a decade of working on a ~200k loc Obj-C++ project, and we do pretty aggressively mix obj-c and c++ things
- zapzupnz 3y agoIt’s more direct is the point. Why add C in between when you can use C++ directly? Like actually, what’s the point of the C in between? It’s only adding yet another thing to maintain when your can just access C++ directly from Swift and vice versa.
- dagmx 3y agoGoing from C++ through ObjC++ to ObjC to Swift is pretty onerous. There’s a lot of type reduction and conversion along the way and a lot of manual binding generation. Performance and safety footguns are plentiful through that route. If you have large existing C++ libraries, this (in theory) would really help simplify the process and reduce that mental overhead you mention. I’m not sure how your suggestion of creating wrappers is better because you’d have to still keep the C++ side for those wrappers and introduce a new intermediary layer to manage as well. Surely having one less layer is desirable?
- gumby 3y agoYou might have better luck using g++ rather than clang for Objective-C++. We originally developed it on gcc (there was no llvm and the NeXT used gcc). By the time Apple switched to llvm I imagine they weren't as interested in Objective-c++
- pjmlp 3y agoGCC isn't that compatible with everything post Objective-C 2.0, there is only a kind of partial support. At WWDC 2023 there were a couple of sessions with Objective-C++ content, e.g. how to extend PyTorch on macOS.
- eschaton 3y agoYour imagination is incorrect.
- gumby 3y agoI'm glad to hear it. Getting ObjC++ to work in the first place 30 years ago was a crazy project.