News for hackers. Stuff that matters.
Re:GCC now includes Modula-2 and Rust. Do they work on OpenBSD? by scrame on Monday December 19, 2022 @03:03PM (#34056889)
This is the first I've heard of Objective-C++ [1]. What kind of masochist would you have to be to pick that?

[1] https://en.wikipedia.org/wiki/Objective-C#Objective-C++

Re:GCC now includes Modula-2 and Rust. Do they work on OpenBSD? by jaas on Monday December 19, 2022 @03:23PM (#34057154)
The OS X platform code for Firefox is written in Objective-C++. It's not without issues, but overall it's a nice way to use Objective-C from within a larger C++ code base. I didn't find it difficult to work with, particularly as opposed to what we'd have to do if Objective-C++ didn't exist.

If you want to see what this looks like, look at the .mm files here:

https://github.com/mozilla/gecko-dev/tree/master/widget/coco...

If you want a specific file to look at with good examples of how this works, here's one:

https://github.com/mozilla/gecko-dev/blob/master/widget/coco...

Basically what you're looking for is being able to make Obj-C calls (e.g. [[ChildView alloc] initWithFrame:r geckoChild:this]) from within what is otherwise normal C++, and vice-versa.

Re:GCC now includes Modula-2 and Rust. Do they work on OpenBSD? by MBCook on Monday December 19, 2022 @04:26PM (#34057949)
Thanks! I remember hearing it existed long ago but I’ve never heard of it being used. Great explanation.
Re:GCC now includes Modula-2 and Rust. Do they work on OpenBSD? by scrame on Tuesday December 20, 2022 @04:26PM (#34072828)
Ahhh, that makes sense. So you can have a cross platform c++ and then bind cocoa. Thanks!
Re:GCC now includes Modula-2 and Rust. Do they work on OpenBSD? by fathyb on Monday December 19, 2022 @03:06PM (#34056917)
I did, mostly for Metal-based rendering. It's great if you want to mix Apple's Objective-C APIs with your own C++ code.
Re:GCC now includes Modula-2 and Rust. Do they work on OpenBSD? by pjmlp on Monday December 19, 2022 @03:33PM (#34057277)
Which is a much better solution than using the incomplete C++ bindings released earlier this year.
Re:GCC now includes Modula-2 and Rust. Do they work on OpenBSD? by jxy on Monday December 19, 2022 @05:37PM (#34058783)
this? https://developer.apple.com/metal/cpp/

Doesn't it just use objc/runtime.h and if anything is missing you can just add your custom api calls?

Re:GCC now includes Modula-2 and Rust. Do they work on OpenBSD? by pjmlp on Monday December 19, 2022 @05:58PM (#34059010)
That is exactly it, the additional effort to add missing calls, no Metal frameworks integration, it is mostly for basic workloads.
Re:GCC now includes Modula-2 and Rust. Do they work on OpenBSD? by pjmlp on Monday December 19, 2022 @03:33PM (#34057265)
NeXT, as means to bring C++ software into NeXTSTEP.
Re:GCC now includes Modula-2 and Rust. Do they work on OpenBSD? by theg5prank on Tuesday December 20, 2022 @01:57AM (#34062547)
Objective-C++ was introduced in the early aughts (https://luminaryapps.com/blog/objective-c-a-history/index.ht... says 2002; I remember watching the WWDC video in which it was introduced but I'm having trouble finding it now, sorry).
Re:GCC now includes Modula-2 and Rust. Do they work on OpenBSD? by pjmlp on Tuesday December 20, 2022 @03:03AM (#34062972)
You're talking to someone that has hold NeXT manuals for an university porting project, and in fact the very first editions of Apple documentation have exactly the very same manual, rebranded for Apple.

And just not to be a random dude in the Internet, here are the NeXT documents straight out of 1993, page 173.

http://www.bitsavers.org/pdf/next/Release_3_Nov93/Object-Ori...

Page 31 on "Developing business applications with OpenStep"

https://archive.org/details/developingbusine00gerv/page/n7/m...

Finally, from the language authors themselves, chapter 15, Objective-C++ (1989-1990)

"The Origins of Objective-C at PPI/Stepstone and Its Evolution at NeXT"

https://dl.acm.org/doi/pdf/10.1145/3386332

Re:GCC now includes Modula-2 and Rust. Do they work on OpenBSD? by arcticbull on Monday December 19, 2022 @03:34PM (#34057285)
Objective-C is a superset of C, and Objective-C++ extends that to C++. It's really only meant as a shim layer to bridge C++ libraries with Objective-C. Or at least, that was the case in the pre-Swift days.
Re:GCC now includes Modula-2 and Rust. Do they work on OpenBSD? by dagmx on Monday December 19, 2022 @05:17PM (#34058532)
It’s really great when you need to call ObjC APIs from C++ or vice versa.

For the most part you can keep things as regular C++ and then just mix in some ObjC APIs when needed without splitting out your files and targets.

It’s extra useful because macOS provides a lot of really great utility libraries like dealing with media or networking, which means you can greatly reduce your dependency count on Apple platforms.

I try and take the approach of reducing dependencies in favour of platform native APIs where possible when making multi platform code, and this is great for that.

Of course it means you have different details on each platform, but I find it much more pleasant than having to keep building dependencies, and dealing with all the corresponding issues like security, size or dealing with platform specific acceleration.

Re:GCC now includes Modula-2 and Rust. Do they work on OpenBSD? by blt on Monday December 19, 2022 @08:24PM (#34060335)
> I try and take the approach of reducing dependencies in favour of platform native APIs where possible when making multi platform code, and this is great for that.

We need more developers like you!

Re:GCC now includes Modula-2 and Rust. Do they work on OpenBSD? by adamnemecek on Monday December 19, 2022 @08:08PM (#34060223)
So much of macOS is built in Objective-C++. Like so fucking much. It's kind of nice actually. Not Rust or Swift nice but kinda nice.