Ruby meets AppleScript with RubyOSA
Most days I'm totally happy with my Windows PC, but some days I want a Mac.* I've got a thing for scripting of all kinds, and the days I most want a Mac, it seems, are when I see someone doing something really cool with AppleScript, like RubyOSA. To quote its web site, "RubyOSA is a bridge that connects Ruby to the Apple Event Manager infrastructure. In big words, it allows you to do in Ruby what you could do in AppleScript." It fetches information from OS X apps about their components and then maps them directly to Ruby classes and methods. While AppleScript isn't exactly fugly, I'm a big Ruby fan and seeing it do stuff like this really gets my vitals up. I would love to say "I wish someone would do this kind of thing for Windows apps," but the tragedy is that Windows has no standard scripting interface like AppleScript, and certainly none that is widely implemented.*For the record, some days I want to ditch everything for Ubuntu instead. And now, back to your regularly scheduled not-quite-so-uber-geeky programming.












Comments
3
Subscribe to commentsEric JamesOct 27th 2006 10:37PM
Windows has a Scripting Interface called the "Windows Scripting Host". The Windows Scripting Host supports either VBScript or ECMAScript by default as well as (REXX, PHP, Perl, Python and others via plug-ins) and ECMAScript is a cross platform language support on Windows, Linux, UNIX and Mac making it much more of a standard interface. AppleScript is Mac only so using the word "standard" to describe the Mac OSX scripting interface is not exactly valid. If the language used for scripting on a Mac was ECMAScript (JavaScript) then it would be a Standard Scripting Interface. Both Windows and Apple Mac's support scripting and neither could be called a standard.
Jordan RunningOct 26th 2006 3:49PM
Eric: I'm well aware of Windows Scripting Host, but unfortunately among Windows apps it's implemented very haphazardly. If Windows ISVs implemented WSH scripting in their apps on a widespread basis, we'd have something. As it stands, we don't.
When I say AppleScript is "standard" among OS X apps, I mean in the de facto sense, i.e. a huge number of OS X apps have extensive AppleScript scripting support, which is what makes brilliant apps like Quicksilver possible on the Mac.
Eric JamesOct 26th 2006 4:19PM
The integration that you were talking about (although not as widely supported) in Windows scripting does exist through the use of WMI or the older (and long in the tooth) COM. This does give you the means by which you can script applications in a manner similar to what is made available to via AppleScript. Since most Windows users still use the Microsoft Office Suite for work they do get the same level of functionality using the Windows Scripting Host and the Office Object Model.
Is the Mac a better and more well thought out OS that incorporates the base tools to support a more robust scripting environment than Windows? Absolutely!
I was only pointing out that Windows does have a standard scripting interface and that when used with applications that support a COM interface or WMI interface the same level of integration is available; even if it is not a polished as the Mac's.