Anyway, once OS X came along, a programmer dialect for AS would’ve been unnecessary as Mac OS X included the massively popular Perl, Python, Ruby languages as standard. Apple’s priority then should’ve been to put AppleScript-quality app scripting support[1] into those languages too, but as I noted upthread the Mac Automation team utterly wrecked that.
…
Here’s a working, testable example of your query:
tell application "TextEdit"
tell document 1
get first character of every word whose font is "Helvetica-Bold"
end tell
end tell
And here’s your filtering example, done right, in Node.js[2]: #!/usr/bin/env node
const {app, its} = require('nodeautomation');
const textedit = app('TextEdit');
let doc = textedit.documents[0];
let ref = doc.words.where(its.font.eq('Helvetica-Bold')).characters.first;
console.log(ref.get());
// => [ 'b', 'b', 'k' ]
…Cook’s paper is a terrific read, btw: a true lightbulb moment. ’90s Apple management were ranking idiots for driving Cook and Harris off. Here a video of them discussing their work and its goals back in happier days:
https://www.youtube.com/watch?v=1MaHJ_mzrTU
Both authors tragically passed in recent years too, still young. It is a shame that their amazing if imperfect work is probably not far behind now. They deserved far better.
--
Fun fact: Apple in 1991 in fact planned to have alternative dialects of AppleScript, meaning divorcing the logic of the script from its textual representation and storing the script in a language-independent representation.
One application would have been internationalization, instead of writing english-like writing in french-like or japanese-like and early 90s Apple seem to have released those dialects for a little time, although they depended on localization of the AppleScript dictionaries of the scriptable apps.
Also planned was a Professional Dialect, but sadly not released. According to William Cook, creator of AppleScript (the language/dialect) that would have look something like this:
English-like dialect:
French-like dialect: Professional dialect: I would have really liked something like that. One wonders what would have been. William Cook himself believes in hindsight that AppleScript should have adopted the professional dialect.AppleScript from Mac OS X onwards had adopted the Open Script Architecture with bridges which can be awkward because of some mismatches between features and syntax of the bridging language. Even Javascript (JXA), the most prominent, needs a somewhat awkward `whose` function to replicate the builtin filtering of AppleScript.
[1] Cook’s paper about AppleScript: https://www.cs.utexas.edu/~wcook/Drafts/2006/ashopl.pdf