Welcome to MacForumz.com!
FAQFAQ      ProfileProfile    Private MessagesPrivate Messages   Log inLog in

scripting languages and Mac OS X

 
   Macintosh computer (Home) -> General Discussion RSS
Next:  Re: The 1st Annual 1-2K Text Adventure Competitio..  
Author Message
Tony Belding

External


Since: Jun 29, 2004
Posts: 31



(Msg. 1) Posted: Wed Jun 30, 2004 11:57 am
Post subject: scripting languages and Mac OS X
Archived from groups: comp>sys>mac>programmer>misc (more info?)

I know that Applescript is the "standard" scripting language of Mac OS
X. I haven't actually used Applescript -- frankly, it seems a bit hard
for me to get my head around. Maybe it's just the very strange-looking
syntax, I dunno. . . Anyhow, I noticed Mac OS X now comes with a
handful of other language interpreters already installed: perl,
python, ruby, and who knows what else.

I remember reading somewhere long ago that an Applescript port was an
openly documented feature, so that any language could theoretically
send Applescript messages to applications and thus take the place of
Applescript. Has anybody done this? Could I, for example, use Ruby to
write scripts for my Objective-C application?

Also. . . Is Applescript really as lame as it looks? Apple seem
pretty proud of Applescript Studio, but I had a hard time imagining
myself developing real apps in that language.

--
Tony Belding, Hamilton Texas

 >> Stay informed about: scripting languages and Mac OS X 
Back to top
Login to vote
Paul22

External


Since: Jun 25, 2004
Posts: 53



(Msg. 2) Posted: Wed Jun 30, 2004 6:04 pm
Post subject: Re: scripting languages and Mac OS X [Login to view extended thread Info.]
Archived from groups: per prev. post (more info?)

"Tony Belding" <zobeid RemoveThis @techie.com> wrote in message
news:2004063008572316807%zobeid@techiecom...
 > I know that Applescript is the "standard" scripting language of Mac OS
 > X. I haven't actually used Applescript -- frankly, it seems a bit hard
 > for me to get my head around. Maybe it's just the very strange-looking
 > syntax, I dunno. . . Anyhow, I noticed Mac OS X now comes with a
 > handful of other language interpreters already installed: perl,
 > python, ruby, and who knows what else.
 >
 > I remember reading somewhere long ago that an Applescript port was an
 > openly documented feature, so that any language could theoretically
 > send Applescript messages to applications and thus take the place of
 > Applescript. Has anybody done this? Could I, for example, use Ruby to
 > write scripts for my Objective-C application?
 >
 > Also. . . Is Applescript really as lame as it looks? Apple seem
 > pretty proud of Applescript Studio, but I had a hard time imagining
 > myself developing real apps in that language.
 >
 > --
 > Tony Belding, Hamilton Texas
 >

There is a free 3rd party scripting system for Cocoa apps called FScript
(google) that I can't tell you much about but that seems to be going
somewhere.

There was (I think still is) a "plugin" for Applescript that spoke
Javascript instead - check latenightsw.com.
The downside is that it's really just a translator, so you're relying on on
individual apps to support scripting fully and correctly. IIRC , the
company was started by one of the original AS guys from Apple, which
explains how they got the information to develop it: scripting system
internals are very, very poorly documented - lists of functions w/ no
descriptions, no discussion of how any of it works. If there was a Ruby /
Applescript connection like you mention, I'd be very cautious until I saw it
working well.

As far as Applescript Studio - I'm a C++ guy, but I'd go with RealBasic in
99.9% of the cases I can think of. It has good support for using
applescripts where they're needed.



Applescript as a language isn't too bad. Its biggest problem (aside from
verbosity) is that support for it is so limited. Few apps do scripting
beyond the very basics, and no two work the same way. The OS9 Finder was
notorious for providing multiple apparently valid ways to do something, but
only one or two worked as opposed to doing nothing at all or returning
cryptic errors. The OSX Finder is the same + it isn't recordable (last I
checked), so non-trivial scripting is REALLY non-trivial.

Part of the reason is that it is horrendously difficult to make an
application scriptable, much less recordable. Scriptability never really
works works right unless it's designed in from the very beginning, and most
developers tend to skip it in their first version. Powerplant has a good
builtin infrastructure, but it takes a while to learn to use it and it
doesn't retrofit easily.

Realistically, Applescript is most useful when you use it for just a few
applications and use it a lot (it does really well w/ Quark, for example,
because Quark spent years getting it right and users spent years getting the
nuances down.) Shell/Perl scripts work much faster, easier, and better for
most file system stuff than scripting the Finder.<!-- ~MESSAGE_AFTER~ -->

 >> Stay informed about: scripting languages and Mac OS X 
Back to top
Login to vote
Michael Ash1

External


Since: Jun 01, 2004
Posts: 820



(Msg. 3) Posted: Wed Jun 30, 2004 7:56 pm
Post subject: Re: scripting languages and Mac OS X [Login to view extended thread Info.]
Archived from groups: per prev. post (more info?)

On Wed, 30 Jun 2004, Tony Belding wrote:

 > I know that Applescript is the "standard" scripting language of Mac OS X. I
 > haven't actually used Applescript -- frankly, it seems a bit hard for me to
 > get my head around. Maybe it's just the very strange-looking syntax, I
 > dunno. . . Anyhow, I noticed Mac OS X now comes with a handful of other
 > language interpreters already installed: perl, python, ruby, and who knows
 > what else.
 >
 > I remember reading somewhere long ago that an Applescript port was an openly
 > documented feature, so that any language could theoretically send Applescript
 > messages to applications and thus take the place of Applescript. Has anybody
 > done this? Could I, for example, use Ruby to write scripts for my
 > Objective-C application?

AppleScript compiles to AppleEvents that are sent to other applications.
It is certainly possible to generate these AppleEvents from other
languages, although it tends to be extremely clunky if there isn't a
framework geared towards emulating AppleScript in your language of choice.
I believe Perl, for example, has a module available that lets you script
other applications very easily using AppleScript-like scripting.

 > Also. . . Is Applescript really as lame as it looks? Apple seem pretty
 > proud of Applescript Studio, but I had a hard time imagining myself
 > developing real apps in that language.

Yes, it is. AppleScript is nice for small programs, but hard to use and
extremely slow for anything of significant size. It's great for doing what
its name implies, scripting other apps, but I wouldn't ever consider
making a large, or even moderately small, program with it.<!-- ~MESSAGE_AFTER~ -->
 >> Stay informed about: scripting languages and Mac OS X 
Back to top
Login to vote
Gregory Weston

External


Since: Jul 06, 2003
Posts: 1221



(Msg. 4) Posted: Wed Jun 30, 2004 8:02 pm
Post subject: Re: scripting languages and Mac OS X [Login to view extended thread Info.]
Archived from groups: per prev. post (more info?)

In article <2004063008572316807%zobeid@techiecom>,
Tony Belding <zobeid.DeleteThis@techie.com> wrote:

 > I know that Applescript is the "standard" scripting language of Mac OS
 > X. I haven't actually used Applescript -- frankly, it seems a bit hard
 > for me to get my head around. Maybe it's just the very strange-looking
 > syntax,

English, you mean? Yeah, that can be a bugger. ;)

 > Also. . . Is Applescript really as lame as it looks? Apple seem
 > pretty proud of Applescript Studio, but I had a hard time imagining
 > myself developing real apps in that language.

Depends on how lame one thinks it looks. AppleScript is not particularly
"lame" by any definition I'm aware of.

G

--
Standard output is like your butt. Everyone has one. When using a bathroom,
they all default to going into a toilet. However, a person can redirect his
"standard output" to somewhere else, if he so chooses. - Jeremy Nixon<!-- ~MESSAGE_AFTER~ -->
 >> Stay informed about: scripting languages and Mac OS X 
Back to top
Login to vote
Sherm Pendley

External


Since: Jul 09, 2004
Posts: 149



(Msg. 5) Posted: Wed Jun 30, 2004 9:05 pm
Post subject: Re: scripting languages and Mac OS X [Login to view extended thread Info.]
Archived from groups: per prev. post (more info?)

Tony Belding wrote:

 > I remember reading somewhere long ago that an Applescript port was an
 > openly documented feature, so that any language could theoretically
 > send Applescript messages to applications and thus take the place of
 > Applescript. Has anybody done this?

I don't know about the other languages, but I do know that there's a Perl
module available for this. You can send AppleScript, even creating the
script text on the fly if necessary. You can also send low-level Apple
Events.

There's also the 'osascript' tool. That can be called from any scripting
environment that allows you to run a command-line tool and collect its
output.

 > Could I, for example, use Ruby to write scripts for my Objective-C
 > application?

Probably - at the very least you could use the 'osascript' tool. There is a
Ruby/Cocoa bridge too, so you can write the apps themselves in Ruby.

 > Also. . . Is Applescript really as lame as it looks?

I wouldn't call it "lame". Lots of "casual" programmers swear by it. It does
feel dreadfully foreign to those who are accustomed to more traditional
programming languages though.

sherm--

--
Cocoa programming in Perl: <a style='text-decoration: underline;' href="http://camelbones.sourceforge.net" target="_blank">http://camelbones.sourceforge.net</a>
Hire me! My resume: <a style='text-decoration: underline;' href="http://www.dot-app.org" target="_blank">http://www.dot-app.org</a><!-- ~MESSAGE_AFTER~ -->
 >> Stay informed about: scripting languages and Mac OS X 
Back to top
Login to vote
Simon Slavin1

External


Since: May 16, 2004
Posts: 625



(Msg. 6) Posted: Sat Jul 03, 2004 1:24 am
Post subject: Re: scripting languages and Mac OS X [Login to view extended thread Info.]
Archived from groups: per prev. post (more info?)

On 30/06/2004, Tony Belding wrote in message
<2004063008572316807%zobeid@techiecom>:

 > I know that Applescript is the "standard" scripting language of Mac OS
 > X. I haven't actually used Applescript -- frankly, it seems a bit hard
 > for me to get my head around. Maybe it's just the very strange-looking
 > syntax, I dunno. . . Anyhow, I noticed Mac OS X now comes with a
 > handful of other language interpreters already installed: perl,
 > python, ruby, and who knows what else.

OS X has always supported standard Unix tools. Pretty much all the
much-used open source tools are available, from emacs on up.

 > I remember reading somewhere long ago that an Applescript port was an
 > openly documented feature, so that any language could theoretically
 > send Applescript messages to applications and thus take the place of
 > Applescript. Has anybody done this? Could I, for example, use Ruby to
 > write scripts for my Objective-C application?

Okay, you're misunderstanding something here. The interapplication
communication system implemented by OS X is AppleEvents. This is
a perfectly open standard, completely documented, and any programmer
can make their application generate or react to whatever AppleEvents
they want. Apple tend to build lots of AE support into their own
applications in an effort to persuade others to follow suit.

There's no reason why perl, ruby, etc. shouldn't be able to
generate AppleEvents. I'm 90% certain I've seen something in perl
which would do it.

AppleScript is an English-like interface to AppleEvents. It lets
you write something that looks like English and turns it into calls
to AppleEvents. It's not a compiled language, it's tokenised, and
it's the sort of thing a Mac-head would use when a Unix-head would
write a shell script rather than firing up a compiler.

If your preferred tool doesn't support AppleEvents (which would
definitely require programming) you can still use it to generate
them using osascript, possibly as a shell command. For example

osascript -e 'say "all done"'

 > Also. . . Is Applescript really as lame as it looks? Apple seem
 > pretty proud of Applescript Studio, but I had a hard time imagining
 > myself developing real apps in that language.

If you're comparing AppleScript with a compiled programming
language then yes, it looks weird. If you're comparing it with a
shell script and bearing in mind that it's designed for
non-programmers to use, then it's pretty good at its job.

Simon.
--
Using pre-release version of newsreader.
Please tell me if it does weird things.<!-- ~MESSAGE_AFTER~ -->
 >> Stay informed about: scripting languages and Mac OS X 
Back to top
Login to vote
Luc Heinrich

External


Since: Jul 03, 2004
Posts: 1



(Msg. 7) Posted: Sat Jul 03, 2004 2:20 pm
Post subject: Re: scripting languages and Mac OS X [Login to view extended thread Info.]
Archived from groups: per prev. post (more info?)

Simon Slavin <slavins.delete.these.four.words.TakeThisOut@hearsay.demon.co.uk>
wrote:

 > There's no reason why perl, ruby, etc. shouldn't be able to
 > generate AppleEvents. I'm 90% certain I've seen something in perl
 > which would do it.

Yeah, sure. But before you are able to generate AppleEvents for a
specific application you have to know *what* AppleEvents to generate,
and the whole point is that loading an application dictionary is a
*major* pain in the butt and has never been documented correctly, as far
as I remember.

The 'O' in 'OSA' is nothing more than marketing bullshit.

--
Luc Heinrich - lucsky.TakeThisOut@mac.com<!-- ~MESSAGE_AFTER~ -->
 >> Stay informed about: scripting languages and Mac OS X 
Back to top
Login to vote
Display posts from previous:   
   Macintosh computer (Home) -> General Discussion All times are: Pacific Time (US & Canada) (change)
Page 1 of 1

 
You can post new topics in this forum
You can reply to topics in this forum
You can edit your posts in this forum
You can delete your posts in this forum
You can vote in polls in this forum



[ Contact us | Terms of Service/Privacy Policy ]