This is longer than a tweet would be so instead of making a Twitter thread that’s super annoying that you have to scroll through, I’ll make an actual blog post like a gentleman.

I have a free idea for Apple: SwiftScript.

It’s the successor to AppleScript. It doesn’t replace Shortcuts, but it’s what you graduate to after you outgrow Shortcuts.

the basics

(note: I’m describing this in present tense like it exist, but it doesn’t. I’m sorry, I don’t mean to get you all excited over nothing; it’s just easier to describe it that way instead of constantly with qualifiers)

It’s an actual programming language. It can look Swift-like. Hell, it could even be Swift. I’m not really digging into details here; I just want to do broad strokes.

AppleScript is an actual programming language too, but SwiftScript drops the cutesy English-like syntax which always sounded great on paper but is a nightmare in practice. Instead, we make SwiftScript really easy and approachable by making everything super discoverable.

Unlike the AppleScript editor which is basically just an empty editor you type text into and click “Run,” hoping for the best, SwiftScript is always meant to be interacted with by offering a REPL. You are constantly expected to dig around with this REPL and figure out what’s what in the language and in the apps you want to automate. Everything you type is very much autocompleted, and things are strongly typed so that the SwiftScript environment can always tell you what a thing is, and what you can do with that thing.

You know how web browsers have inspectors that let you click on any element in a page and see it in the DOM? The SwiftScript inspector can let you do the same, except with all the applications on your device. You can look at the Mail app and click a message in the message list and it’ll tell you about the Message entity, what fields a message has, and what methods you can call on the message. Clicking on the Search box will show you related objects, like an object to construct a search for messages. No guessing at what something is called or poring through docs you don’t quite understand. You see something you want to automate, and SwiftScript will show you what you’re dealing with.

Now, for this to be useful, we have to make apps that have very rich SwiftScript libraries for the scripts to use.

What I mean here is that when an app supports SwiftScript, every single entity in the app exposes a SwiftScript API. Shortcuts has been a cool thing to see in iOS (and now the Mac) but far too often I find myself wanting to automate something only to find that it just can’t be done because there isn’t anything close to resembling an action for it. SwiftScript won’t be limited like that; as a programmer you’ll be able to programmatically do virtually anything you can manually do as a user.

going past just a scripting language

So far, the SwiftScript I’ve described is fundamentally a nicer AppleScript, mostly predicated on the idea that you invoke a script, and then run it.

But SwiftScript can do more. SwiftScript apps can offer hooks throughout the app where SwiftScript scripts you write can act automatically when those hooks happen.

For instance, Mail might offer a hook for a new message coming into the Resumes folder (a folder which gets populated by a filter, perhaps). You might then make a SwiftScript that watches for this event, and then whenever a message of this sort comes in, it searches the message for the resume attachment, saves that file to a designated folder, then creates a to-do item in OmniFocus directing you to review that resume complete with the name of the applicant (from the From field), a link to the file itself, and a link back to the original Mail message.

Then, you might add another script that watches for replies to messages, and if you’re replying to a message in the Resumes folder, and then it will present you with a small GUI that asks you whether you are moving forward with that applicant or not, and based on that response, fills out a message for you with the appropriate details supplied from a template, with fields that you can fill in with the right added information. If we want to get really elaborate, maybe when you email a candidate you want to interview, the email might even include a few options for interview times in the coming days based on your availability in the time you blocked off in the afternoons for interviews.

But SwiftScript goes beyond just the applications’ APIs and the hooks they can provide. SwiftScript also is a powerful general-purpose programing language in its own right, with access to super powerful libraries. So not only can you perform repetitive tasks, the kinds of tasks you can let the computer perform can get increasingly sophisticated.

For instance, you might make a script that fires when you favorite a tweet in Twitter, and then the script will save that tweet’s contents to a database. A lot of tweets’ contents are just an image of text, so your SwiftScript can check to see if the tweet includes images, and if it does, check the image to see if it’s text, and if so, OCR the image and save that text into the database so that it’s easily searchable later.

You could even watch that text for certain key words and then tag that tweet in your database if appropriate.

apple: please take this idea and run with it!

The thing that’s just beautiful about SwiftScript here is that it turns any user into an application developer. But you don’t have to know how to develop a full application yourself; you really just get the power of all the apps you already have, but SwiftScript is there to help you fill in the gaps.

It’s clear that Apple looked at its automation story and saw that although AppleScript is quite powerful and continues to have a cult following (think of how amazing it is that AppleScript actually made the jump from classic MacOS to OS X and it’s still around and even works with Shortcuts), they saw a product that’s too complex, and decided that the future of automation on Apple platforms had to be not just made easier to user, but watered down.

I’m so glad that Shortcuts is a thing, and I’m glad that it’s energizing people about automation on their Macs and iOS devices. But it’s less capable than AppleScript.

SwiftScript tries to fundamentally change what automation means to you as a user. It’s an advanced tool because it’s a programming language but it’s making programming highly approachable by being an exploratory language that you are meant to tinker with at runtime as you build your scripts. It’s still for that sophisticated user, but it has the potential to give that user massive leverage by putting programming-shaped handles on every aspect of their computer. I’d love to live in the alternate universe where Apple built this.

But I guess building a car is cool too.

Leave a Reply

Your email address will not be published. Required fields are marked *