RubyOSA presentation to Northern Virginia Ruby Users Group

This evening’s NoVaRUG was a good time. Rodney Degracia spoke first about RubyCLR, which provides a dynamically generated bridge between a Ruby VM and the RubyCLR. If I ever need to get at .NET internals again, now I know how I’m going to do it. In fact, I dropped an e-mail to a colleague in the office about it — except that his assembly is executed from Python. A quick Google turned up “Python for .NET” as an option.

Then it was my turn to talk to RubyOSA and RB-AppScript. Admittedly, after using both, I’m strongly biased toward RubyOSA. I have the distinct feeling that, after my presentation, the audience felt the same way.

Well, the Mac users in the audience.

Out of twenty or so people in the room, it turned out that I was really presenting to perhaps five or six Mac users. I suppose that RailsConf is in no way representative of your average Right Coast Ruby developer. However, oddly, nearly everyone stayed for my presentation. I even fielded several good questions. All in all, I had a blast.

When Xandy asked for topics for next time, I asked if someone would present on RSpec. His next words were, “Thanks for volunteering, Evan.”

Time to learn RSpec…

Slides available here: OS X Scripting with Ruby

5 comments ↓

#1 Navjeet on 08.22.07 at 10:47 pm

Evan, It was great to learn about RubyOSA and Appscript and hopefully I can use it on my next/future dream MAChine. The presentation was a fairly good introduction.

#2 has on 08.24.07 at 7:39 am

Another slight quibble re. slide 12:

The appscript equivalent of your AppleScript code is:

iTunes = Appscript.app("iTunes") if iTunes.player_state.get == :playing iTunes.pause else iTunes.play end

The extra ‘get’ may seem counterintuitive at first, but it makes sense if you understand that Apple event IPC is based on RPC + queries, not COM/CORBA-style distributed OOP as it’s often mistaken for. This query-based behaviour tends to get a bit obfuscated by the OO-ish syntax favoured by AppleScript and other bridges, but don’t let that fool you: it’s merely syntactic sugar to make such code easier to write.

The AppleScript interpreter goes even further in that it can automatically send ‘get’ events for you - a behaviour that is generally convenient except when it isn’t. However, appscript only ever sends an Apple event when you tell it to - hence the need for the explicit ‘get’ in the above example. It’s a little tedious to write, but it’s simple, consistent and completely reliable, and you quickly get used to it.

Appscript is a solid technology but it’s not as forgiving of commonly held misconceptions than AppleScript, so users really need to develop a basic but accurate understanding of how Apple event IPC actually operates in order to use it effectively. While I do try to provide a quick grounding in the appscript manual, I know there’s still plenty room for improvement so any suggestions are very welcome.

#3 has on 08.24.07 at 7:42 am

[apologies - WP keeps eating my posts without explanation, so reposting previous post again]

“Admittedly, after using both, I’m strongly biased toward RubyOSA.”

I’d be very interested in discussing your thoughts behind this statement in more detail if you’d be willing to drop us an email.

While appscript is better technology than RubyOSA, it does seem to suffer a bit of a perception problem amongst some Ruby users. Obviously I’d like to remedy this, but I’ve been at this stuff for so long now that it gets hard to see it from other users’ points of view, so any fresh insight you could provide would be greatly appreciated.

BTW, I took a look through your slides and noticed your statement that rb-appscript lacks a documentation generator. In fact, ASDictionary has provided an export option for rb-appscript since last October:

http://sourceforge.net/project/showfiles.php?group_id=175009&package_id=208705

The only difference to RubyOSA’s rdoc-osa tool is that ASDictionary isn’t included in the rb-appscript distribution itself, as that would add an extra 4.5MB to the download size (it’s a PyObjC-based application).

ASDictionary has previously been linked to from both the rb-appscript homepage and documentation, but some users have been missing these links so I’ve added a new Downloads page in the hope of making it easier to find:

http://rb-appscript.rubyforge.org/downloads.html

Other suggestions for raising awareness of ASDictionary and other related tools are welcome.

#4 Evan on 08.24.07 at 10:34 am

Thanks, Has! That is terrific feedback! And you pegged me to a ‘T’. My first job was implementing portions of a RPC-based client-server app but I never did get into the RPC portion as a ‘newbie’. Instead, I quickly moved on to CORBA (blech!), RMI and Java’s suite of logical successors to CORBA services, and, fortunately of late, to Ruby. So, yes, I had exactly the misconception that you ascribed.

I will update the slides accordingly for future readers.

#5 has on 08.24.07 at 11:18 am

“That is terrific feedback! And you pegged me to a ‘T’.”

Happy to be of help.

BTW, don’t worry about initial misconceptions and stuff; been there myself, and it’s pretty much par for the course given what a rotten job Apple do of explaining the technology to their users (not to mention some of their own engineers!). I try to provide some public education via appscript’s documentation and general discussion, but I know there’s still an awful lot of room for improvement.

Anyway, as I say in my previous post, if you’d be willing to discuss things further via email it would be very much appreciated. You can contact me via the developer info link on the rb-appscript project page.

Regards,

has

http://appscript.sourceforge.net http://rb-appscript.rubyforge.org

Leave a Comment