I finally started writing AppleScript a few months ago when I realized GPT-4 can write it for me, which eliminated almost all of my previous frustrations with it: https://til.simonwillison.net/gpt3/chatgpt-applescript
I feel like scripting with non-standard languages (not Python, not JavaScript) is one of the killer features of GPT-4. It was trained on a large amount of this material and can spit out functional scripts for small tasks (which you can then chain together) incredibly quickly.
ChatGPT is bad at the AutoHotKey (Windows automation scripting language), which is down to having two major largely incompatible versions of the language out, and a dearth of code examples out on the Internet.
ChatGPT can even show you how to do this in Python BTW!
from ScriptingBridge import SBApplication
notes_app = SBApplication.applicationWithBundleIdentifier_("com.apple.Notes")
for folder in notes_app.folders():
for note in folder.notes():
print(f"{note.name()}\n{note.body()}\n")
That's interesting, and would be doable for small scripts that I could fully understand. But I would be hesitant to use it for larger jobs, where it might end up misunderstanding me, and I wouldn't necessarily realize there was a mistake. Applescript is very powerful, and I wouldn't want to risk it deleting/moving/editing files. Perhaps in the future, when people have used it for this purpose for years (without incident), I would trust it more.
> You can't write a BNF for it because its syntax depends on what program you're trying to control.
More importantly it AppleScript operates on sending and receiving messages from those external programs and thus has no insight into their current state/progress unless it's specifically communicated back to AppleScript.
Many programs would just return back to AppleScript immediately after getting a command even if the operation requested took a lot of time. There was no way to register callbacks (at least no obvious way) so you had to put in boilerplate to check for a file at a location to know when a long running process was complete.
The challenge level between writing any two scripts could vary wildly. A program's script dictionary might technically allow you to write a script but actually making it workable or reliable was fantastic amounts of effort.
My recollection of the English-like nature of Applescript is that there would be multiple ways to express something, and more than one of them would work, but it always seemed totally unpredictable which would work and which wouldn't. That's actually a bit worse (more frustrating) than the way you're describing it. Overall, I agree with you that it was unsatisfying for both professional programmers and non-programmers, and that's why it failed to take off.
1. You can't write a BNF for it because its syntax depends on what program you're trying to control.
2. It wants to be "English-like" which means you can always think of 20 plausible ways to express any action, only one of which will actually compile.
(1) frustrates professional programmers and (2) frustrates everybody, so almost nobody uses it.