4 ms·
Those who don't understand Objective-C are bound to reinvent it...badly. "... you could even use the generated API with Lua, Python, Ruby or JavaScript" Guess
by mpweiher 3y ago
Those who don't understand Objective-C are bound to reinvent it...badly.
"... you could even use the generated API with Lua, Python, Ruby or JavaScript"
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.
No C code generation required.
This should be no surprise because that was exactly the stated goal of Objective-C, and they achieved it admirably. If you think Objective-C is a closed, vendor-specific language like Swift, you truly don't understand it. At all.
Someone once described Objective-C as "COM with language support" and that's pretty accurate.
- newZWhoDis 3y ago[flagged]
- 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.
- pjmlp 3y ago> Someone once described Objective-C as "COM with language support" and that's pretty accurate. That is what VB6, Delphi, C++ Builder and .NET Native do (yes not that much relevant nowadays). If anything I would describe that Objective-C is a better COM, which isn't quite the same.