From: Chris Gehlker Date: 2002-07-31T13:19:44+09:00 Subject: Re: ActiveRubyScript and RubyAEOSA On 7/30/02 3:47 PM, "Hal E. Fulton" wrote: > ----- Original Message ----- > From: "Chris Gehlker" > To: "ruby-talk ML" > Sent: Tuesday, July 30, 2002 4:31 PM > Subject: Re: ActiveRubyScript and RubyAEOSA [Question about COM on MacOS] > > Offhand I'd say that it's different because each app > takes advantage of its OS features. As I see it, COM > is a Windoze thing, not an Apple thing; so even though > you have Windows apps on a Mac, they will expose > different kinds of interfaces because the OSes are > different (and Micro$oft simply hasn't created COM for > the Mac, which might well be difficult to impossible > even if they wanted to). Is this assessment accurate? There actually was a MacCOM in OS < X that Microsoft tried to license and they had a few takers. There is a limited implementation in OSX that is sufficient to make the VBA scripts in Office portable as long as they don't make system calls. Motorola also uses some OSX COM and it probably shows up a few other places. If memory serves, a programmer from MS's Mac Business Unit said that in OSX, COM is built on top of the Apple Event model. Certainly in Office you can use both models, COM or the Apple Event Model. [snip] > I find it hard to understand the XML concept, given that it's > hard to represent control structures and such in XML. Do they > use tags to mark the parts of a loop and the branches of an > if-then and that kind of thing? > > But if it works, and it's semi-elegant, I'm impressed. You're making it too sophisticated. The XML just presents a static representation of the objects that the target application understands together with a mapping to codes used to communicate with it. Control structures and iteraters are in the scripting language, whether that be Basic, AppleScript or what have you. Then the third place where there is some intelligence is in the editor. It has to take object oriented code and turn it into a bunch of result = send_msg(0x56988569, 0x43852391, 0x89658723,...) type calls by referring to the XML. > > Really? AppleScript is that bad? I'm not a Macoid. It's semantics are rather nice - clearly in the Smalltalk/Ruby/ObjC family. But it's syntax is from the natural language school. It actually uses the possessive form ('s) to refer to instance variables as in: Set the text of thePage's third paragraph to "This is some weird language" Set the textface of thePage's third paragraph to bold. It also suffers from the TIMTOWTDI syndrome but worse than perl. Because I can write an AppleScript app and save it to disk and what gets saved contains a bunch of those send_msg() calls. Then I open it again and the editor loads the XML and tries to recreate my code. But the editor has to guess. So my: Page1Count = count of words on page 1 of theDocument becomes: Set Page1Count to count of theDocument's first page's words. Or something like that. It's disconcerting. > > Yes, definitely! My dream for many months now has been to > control a bunch of Linux (or Unix) apps with Ruby. > > Of course, I was thinking of DRb (Distributed Ruby) for > that purpose. It would be easier if the app itself were > written in Ruby -- but I daresay the average C/C++ app > *could* be given an embedded Ruby interpreter that could > run a DRb server. > > Either way, that would require an investment in the > application writer's time. But learning Ruby is time > well spent. This is not a bad way to go at all. The only advantage of the XML method is it works where the app writer is so benighted that she doesn't prefer Ruby. Seriously, it's just a question of how the work gets divided up between the app writer, the language implementer and the person writing the editor. For MacOSX most important apps already have either the XML file or the old MacOS < X format file. And FUJIMOTO Hisakuni already wrote the Ruby library. So all I need to do is finish the smart editor and I really can control a bunch of apps with Ruby. But it would be nice if I could send Ruby messages to apps running on any platform. -- C++: The power, elegance and simplicity of a hand grenade.