Friday, September 1, 2023

Making Your App Extensible with JavaScriptCore

Christian Tietze:

The idea here is that JavaScript is basically the only way nowadays that you can ship plugins or scripts with your apps on macOS that is not broken since Big Sur, I think. Because Ruby and Python and all these other scripting languages were yeeted from the operating system.

Of course, apps can still offer places where users can hook in AppleScripts.

So it’s not like new technology. It works with really old stuff. And the thing I’ve found is that you can actually make plugins for your applications that don’t expose the app’s internals or the user’s file system or any sensitive data unless you actually decide to expose this. Which means that plugin installing can become rather safe. It’s easy to break things, but it’s also easy to make things secure.

[…]

The most important piece that I found is the context, and the JSValue that you see below, and the JSManagedValue, which is something we will completely ignore. If you have worked with CoreData, for example, you will know the NSManagedObject, and the JSManagedValue is kind of similar: It’s bridging into the JavaScript context and automatically updates when you mutate an object from within the script. And the JavaScript site sees values reflected as you change them in your swift code on these managed values. This is very handy, I guess, but it’s something that I find, well, utterly unnecessary for my purposes. And too hard to control.

[…]

I’m teaching the script to call a function for the input and I call function for the output.

Previously:

2 Comments RSS · Twitter · Mastodon

I believe Tcl is still part of the OS?

But that’s not the purpose of JSManagedValue. 🙈 JSManagedValue is immutable too. How can anyone take the article seriously after those few sentences?

Leave a Comment