4 ms·
MacOS apps are typically written in either Objective-C or Swift as these are the officially supported languages for the MacOS APIs. The code in this template i
by williamcotton 3y ago
MacOS apps are typically written in either Objective-C or Swift as these are the officially supported languages for the MacOS APIs.
The code in this template is interfacing with the Objective-C runtime but with pure C.
- rankam 3y agoDoes this mean that, theoretically, this could lead to the ability to build MacOS apps in higher languages that interoperate well with C such as Python? I know you can build MacOS apps with Python now, but does this potentially improve the experience?
- detourdog 3y agoThat is what objC scripting brige is for. https://developer.apple.com/documentation/scriptingbridge https://developer.apple.com/documentation/scriptingbridge
- jimbokun 3y agoI believe RubyMotion does basically this: http://www.rubymotion.com http://www.rubymotion.com It was fun building an app in this a few years ago, but was difficult to keep up with updates to MacOS breaking my code.
- CodeWriter23 3y agoThere’s already PyCocoa and pretty sure *Cocoa exists for a variety of languages.
- flohofwoe 3y agoYou can already do this in the traditional way by building an ObjC shim which exposes a C API. The solution shown here just skips ObjC and talks directly to the ObjC runtime (which has a C API but is not as convenient to use as doing the same thing in ObjC or Swift). In a highly simplified way you can think of Objective-C as preprocessor which replaces the ObjC syntax sugar with C function calls into the ObjC runtime (it's not how it works in reality, but how it could work).
- jackjeff 3y agoThat’s essentially what this project does. It creates the C code that the ObjC compiler would generate to “implement methods” or “send messages”. It’s somewhat doable by hand because Objc is a thin lawyer. Over 15 years ago I did stuff similar to this project to call some Objc code from a C++ app. Most of it was exposed to normal C APIs but one feature only available in AppKit. It was much simpler to do it this way than figure out how to make GCC or Objc like our C++ or any mess with bridging headers. I think the move to Swift has made that harder in some ways. But then again I don’t want to write C or C++ these days if I can avoid it.
- gwking 3y agoIn fact, early objective-c was a preprocessor according to Wikipedia!
- ChrisMarshallNY 3y agoThat has always been possible. Also, under the ObjC layer, is good ol' ANSI C (FreeBSD Unix). There's a number of apps that run on modern Macs, that were written in C, but it is unusual to see ones that leverage the GUI. That said, it's possible to walk from Boston to Portland (OR), but I'd rather take a plane.
- thenipper 3y agoYou know i took the train to Boston to PDX, it was really relaxing. Not quite walking but definitely a lot different then a plane...
- jonhohle 3y agoIt has, but there was also Carbon until around the Intel transition.
- LeoNatan25 3y agoFull Carbon was there until the 64bit transition officially, but much of it remained and still remains until now. For example, Apple only started using AppKit to draw menus in Sonoma; it was Carbon until now.
- ChrisMarshallNY 3y agoI think it’s cool that a lot of NextStep stuff is still there (all those “NSXXX” calls).
- saagarjha 3y agoWait until you see the NX* APIs ;)
- ChrisMarshallNY 3y agoI have not encountered them. Are they public?
- mycall 3y ago> officially supported languages for the MacOS APIs How often do you need to get support assistance from Apple? Just do what you want. If it means using Obj-C or Swift for ease, do that. If it means integrating another language, do that.