Hacker News new | ask | show | jobs
by tzs 1183 days ago
From your article on how you wrote that:

> I've been stubbornly refusing to learn AppleScript for nearly twenty years at this point. Thanks to ChatGPT I can continue not to learn it, but I can now use it to solve problems

The Apple scripting stuff can also use JavaScript. It might be better to continue not to learn in JavaScript instead of AppleScript, if ChatGPT is as adept at Apple scripting in JavaScript as it seems to be in AppleScript.

That way if you want to tweak what ChatGPT gives you it will probably be easier. With AppleScript both interacting with other things and control flow or computation can be weird and confusing. With JavaScript at least the control flow and computation will likely be more normal.

4 comments

Huh, that's a great tip! ChatGPT knew how to convert my AppleScript to the equivalent JavaScript and showed me how to run it too: https://gist.github.com/simonw/86c2153b7882747122f1e3d501260...

Added a section about this to my TIL: https://til.simonwillison.net/gpt3/chatgpt-applescript#user-...

I was trying to do a thing with AppleScript, and the barriers I ran into were not with the language, but with discovery of the APIs that Apple surfaces to the end user. In that regard, you’re better off with AppleScript. I can’t believe just how bad the AppleScript documentation is, but the js documentation is even worse; using js is just using AppleScript but with an additional layer of indirection that doesn’t provide any productivity gain.
There's an O'Reilly AppleScript book that's pretty good.

The problem I always had with AppleScript is that it wasn't clear when I was writing AppleScript and when I was talking to an application's OSA dictionary (its "terminology" as Apple calls it in OSA).

Once I switched to Appscript (https://appscript.sourceforge.io/), that confusion went away. Of course I haven't used that in years since it's no longer supported and today I'd use JavaScript.

The issue though is that each application's terminology is isn't really documented. You can usually figure it out using Script Editor, but not always.

Some of this is documented here:

https://developer.apple.com/library/archive/documentation/La...

IggleSniggle expresses it well. As ugly as the AppleScript expressions are, they force you to write in a way that's sympathetic to the API, so, in addition to returning errors at all in more cases, they're easier to diagnose or minimize.

https://gist.github.com/mcint/561f72e6baa3e5c68c2577b04dad78...

I've linked some of my scripts, bash calling applescript, that I use extensively to export tabs from browsers.

I did a bit of AppleScript recently (scripted changing between draw and erase in zoom annotations from the buttons on my tablet pen). In my reading I got the impression that not everything is implemented in js so you might get stuck.