开发者

What is the best scripting language to embed in Mac OS X 10.6 applications?

开发者 https://www.devze.com 2022-12-13 23:07 出处:网络
Is the开发者_Go百科re any other scripting language that can be used to embed scripts inside applications, which can access Mac OS X, or application classes with the same features, or most of the featu

Is the开发者_Go百科re any other scripting language that can be used to embed scripts inside applications, which can access Mac OS X, or application classes with the same features, or most of the features seen in F-script?


The scripting language with the best support on the Mac is still AppleScript. But unlike F-Script, it cannot directly access the Objective-C level, it can only use what the target application chooses to expose for scripting.

There are Objective-C bridges for Perl, Python, and Ruby. I suppose those can embedded to provide scripting to your application.


Nu is an interesting option, although it isn't very popular yet.


A lot of people seem to like JSTalk.

But probably Applescript is your best bet: integrated into the system and all that.


I would say F-Script for many reasons. It has many unique features and is extremely tightly integrated with Cocoa and the Objective-C runtime. You can for example inspect various Finder classes (windows, icons, coverflow view...) and it's very easy (one or two lines of code) to start or control other processes. I don't think there is any good reason to prefer AppleScript. It's good for very short scripts, but will probably drive you crazy if you want to do something more complex.

Also, MacRuby is going to rock when it's a bit more stable, and some serious stuff has been accomplished using PyObjC as well, although I don't think it's very actively maintained anymore.


If you don't need F-Script graphical introspection tools, which are quite unique, there are some decent scripting languages that you can embed in applications. See in Particular RubyCocoa (for Ruby), PyObjC (for Python), JSTalk (for JavaScript) and CamelBones (for Perl). They are based on bridges between Cocoa and a foreign object model, which leads to some complexities. This is different from F-Script, which is directly built for the Cocoa object model. When ready, MacRuby might be an option too, but the syntax for manipulating Objective-C objects is not very nice (it improves on RubyCocoa, though). Nu is also an option: directly built for Cocoa like F-Script, but with a strong Lisp flavor.


MacRuby is an implementation of Ruby 1.9 that uses the Objective-C runtime and garbage collector. It can be embedded in a Objective-C application. Even if the last available version is only 0.6, it is reported to be stable enough to be used in applications.

0

精彩评论

暂无评论...
验证码 换一张
取 消