3 ms·
> Guess what, all these have Objective-C bridges, usually multiple ones, because the combination of being just a thin shim on top of C as well as that thin shim
by kccqzy 3y ago
> Guess what, all these have Objective-C bridges, usually multiple ones, because the combination of being just a thin shim on top of C as well as that thin shim being essentially a Smalltalk with full dynamic messaging and runtime introspection + intercession means interop is Objective-C's bread and butter.
Exactly.
In fact sometimes in lieu of shell scripts I write simple utility JavaScript files using Objective-C APIs and run them under osascript.
For Python, the easiest way to copy a file while not using twice the disk space (using reflinks) is still using the Objective-C API: https://github.com/RhetTbull/osxphotos/blob/20ef78bbd45a678772f3473242cc29298fc32812/osxphotos/fileutil.py#L137 https://github.com/RhetTbull/osxphotos/blob/20ef78bbd45a6787...
- whiddershins 3y agoCan you explain the JavaScript api more? Are you talking about a webView or something else. Edit: oh I see what you are talking about. The osascript aspect was what I wasn’t getting.
- kccqzy 3y agoAs an example, I had a utility (since no longer necessary) that removes files from Trash after a while: https://gist.github.com/kccqzy/8dbead563afdcd6a491a https://gist.github.com/kccqzy/8dbead563afdcd6a491a I couldn't write it as a shell script because I wanted to get the "date added" rather than the "date modified" or "date created" but this is available in Cocoa APIs.