Obviously, it'd be great if JSTalk was the system language instead of
AppleScript, but that's not the case.
So how would JSTalk help my users? I can see a couple possible uses:
Allow users to execute JSTalk scripts as a macro action, similar to
how they can currently execute AppleScript/Unix/Automator scripts.
But I'm not sure what they can do in JSTalk? AppleScript sucks
rocks. Especially its single threadedness (is JSTalk safe to use from
multiple threads, presuming you don't use any cocoa stuff that is not
thread safe?). But at least AppleScript does allow control of lots of
the system, which is where its value is.
Allow users to control Keyboard Maestro using JSTalk. Currently KM
has very minimal AppleScript support, and basically no scripted
programming or scripted access. It seems that JSTalk would not really
help much with that without adding all the support for scripted access
to the model (which would be nice to do, but hasn't made it to the top
of the todo list yet). If my app was properly scriptable already, I
could certainly see opening that up to a better scripting language
like JSTalk, but without that, I'm not sure there is a compelling use
case for it.
So, am I missing something?
And please don't misinterpret this to be against JSTalk - as I said,
if my app was actually scriptable, I could see if being very useful,
or if enough scriptable apps take it on, then it certainly could be
useful. I'm just trying to see if I can make it fit within Keyboard
Maestro as it currently stands, or if I have lots more work to do
before I can make it useful to my users.
Thanks,
Peter.
--
Clipboard Switching and Macros with Keyboard Maestro
Keyboard Maestro <http://www.keyboardmaestro.com/> Macros for your Mac
<http://www.stairways.com/> <http://download.stairways.com/>
> if enough scriptable apps take it on, then it certainly could be
> useful.
Well there you go :)
Where AppleScript requires you to build a dictionary of allowed
actions, JSTalk lets users call _everything_ in your app - any method
of any of your classes can be called. It's then a matter of
documenting what you want to expose.
If you add JSTalk to your app, you'll give your users the ability to
script anything - which is good and bad (particularly if you change
internal methods). On the other hand, maybe you have users asking for
one specific thing which you can write as a small piece of Javascript,
instead of turning your app into a one size fits all.
-Patrick
On Sep 13, 2009, at 6:36 PM, Peter N Lewis wrote:
> I'm trying to get my head around JSTalk and how to use it.
>
> Obviously, it'd be great if JSTalk was the system language instead of
> AppleScript, but that's not the case.
>
> So how would JSTalk help my users? I can see a couple possible uses:
>
> Allow users to execute JSTalk scripts as a macro action, similar to
> how they can currently execute AppleScript/Unix/Automator scripts.
> But I'm not sure what they can do in JSTalk? AppleScript sucks
> rocks. Especially its single threadedness (is JSTalk safe to use from
> multiple threads, presuming you don't use any cocoa stuff that is not
> thread safe?). But at least AppleScript does allow control of lots of
> the system, which is where its value is.
I'm pretty sure JSTalk is safe to use on another thread- I wouldn't
use the same instance across multiple threads at the same time, but I
don't think there's any dependency on the main thread that would screw
you up. I haven't tried myself though. If the user wrote a script
that modified the GUI, then that would have to be on the main thread,
just because the cocoa widget classes require it (for the most part
anyway- maybe this has changed a bit on 10.6?)
What can they do in JSTalk? Well- right now probably not much.
Myself, I've used it for playing with sqlite, automating tasks,
telling iTunes what to do, etc- but I'm not sure what your customers
would do with it.
> Allow users to control Keyboard Maestro using JSTalk. Currently KM
> has very minimal AppleScript support, and basically no scripted
> programming or scripted access. It seems that JSTalk would not really
> help much with that without adding all the support for scripted access
> to the model (which would be nice to do, but hasn't made it to the top
> of the todo list yet). If my app was properly scriptable already, I
> could certainly see opening that up to a better scripting language
> like JSTalk, but without that, I'm not sure there is a compelling use
> case for it.
>
> So, am I missing something?
I don't think you're missing anything. The advantage for adding
JSTalk support to something like Acorn was being able to write scripts
for folks which could then reach into Cocoa and do some powerful
stuff. And then they could take those scripts and tweak them for
their own needs. It was also a language that a lot more people are
getting familiar with, and it's kind of fun to write, as opposed to my
experiences with AppleScript.
Hope that helps,
-gus
--
August 'Gus' Mueller
Flying Meat Inc.
http://flyingmeat.com/