MacOSX is a meld of the traditional Unix IPC concepts (namely, unix sockets, shared memory, and semaphores) and the MacOS notion of AppleEvents (which is the basis behind AppleScript - FYI, Microsoft had attempted to license AppleEvent technology before Apple said no and Microsoft went on to develop COM).

The key difference between the traditional Unix way and the traditional MacOS way is structure (or the absence thereof). The data that flows through a unix socket or is kept in shared memory is unstructured - the OS has no notion of type or size. MacOS AppleEvents, however, have a notion of type, size, and other object-oriented notions such as class, inheritance, and so on.

So how do they fit together in MacOS X? They don't. MacOS has it's Unix heritage from NeXTStep, which had, in addition to the traditional Unix way of doing things, it's own form of IPC, which I know very little about. It had a notion of size (it involved message passing, and therefore had to) and was the basis for RPC in NeXTStep. Apple layered AppleEvents on-top of this NeXTStep form of IPC, and has something that translates them back and forth according to the various APIs (Classic, Carbon, and Cocoa) involved.

So AppleScript, as a scripting technology, exists on a totally different plane than "scripting languages" such as the shell, perl, tcl, and so on. There are some third-party ways of invoking one from the other, and there is even a standard AppleScript Scripting Addition to enable one to execute a shell command from within AppleScript, and vice versus, but other than that, they don't really play well together, ultimately because of the structure versus non-structure issue. AppleScript is designed to script existing applications (that have been augmented to support AppleScript) - that is, it tells them things to do - it is a generic scripting language for any application; but Unix IPC and Unix scripting languages exist to write short scripts - things that take more than one line in shell but that one doesn't want to write a program in C for. Unix scripting languages tend to only communicate via command-line arguments and environment variables, which are untyped and are structured only by convention.

In conclusion, MacOS scripting (AppleScript) and Unix scripting (the shell and other "scripting" languages) do not really work together well at all.



Creative Commons License
This work is licensed under a Creative Commons License.