3 ms·
As usual a lot of discussions about AppleScript are about the english-like syntax, adopted for inexperienced users, less than the - in theory - amazing object b
by ttepasse 4y ago
As usual a lot of discussions about AppleScript are about the english-like syntax, adopted for inexperienced users, less than the - in theory - amazing object based App scripting.
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:
the first character of every word whose style is bold
French-like dialect:
le premier caractère de tous les mots dont style est gras
Professional dialect:
{ words | style == bold }.character[1]
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 https://www.cs.utexas.edu/~wcook/Drafts/2006/ashopl.pdf
- pjmlp 4y agoI love Office, yet one of the "features" I really hate is how Excel adapts its programming language to each locale.
- hhas 4y agoAppleScript’s dialects trick was clever, but many app developers didn’t have budget to localize their GUIs, never mind their scripting interfaces as well. Nowadays, with automated translation tools fast improving, localizable scripting languages should be, if not the norm, then at least the next-generation ground breakers. 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 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. -- [1] https://appscript.sourceforge.io https://appscript.sourceforge.io [2] https://www.npmjs.com/package/nodeautomation https://www.npmjs.com/package/nodeautomation