AppleScript by Hanaan Rosenthal
Posted on November 29th, 2006
AppleScript was the first programming language I came across when I was first learning to use a computer. Being the de facto scripting tool that every Macintosh computer came preinstalled with, AppleScript was just right there ready to be used. But somehow I never really did.
There was always disparity between the things you could do with AppleScript and things you necessarily needed to do. I still find that to be the case today, even after reading AppleScript: A Comprehensive Guide to Scripting and Automation on Mac OS X. I have a better sense of the language and can go further with it than I would have otherwise been able, but hesitations still remain.
The first of these is whether AppleScript is even the best choice. Written in 2004, AppleScript precedes the debut of Automator in OS X Tiger. Automator makes it extremely simple to write scripts ("workflows") by mixing together a palette of pre-defined commands. Although it doesn't do everything, Automator can be the superior choice in some cases. Why fuss with AppleScript's syntax if you don't need to? Even if you do, Automator has provisions for executing arbitrary AppleScript code.
AppleScript assumes little or no programming experience, and I think that contributes to a second hesitation: how to jump from theory to practice. The book starts off with introductions to AppleScript's basic data types and control structures. It isn't until Chapter 13, Working with files, that we get into more pragmatic subjects. Chapter 13 also happens to be quite longer than other chapters. This was the real starting point of the book for me-- everything prior was more like the inevitable drudgery you have to slog your way through for your own good. Sure, it's important to understand coercion and other fundamentals. Rosentahall's coverage is both thorough and gradual. At the same time, it's much more exciting to move and manipulate files and folders than it is to do date arithmetic.
After the main course of Chapter 13, there were a few more meaty chapters but also many places that I skipped away from for lack of immediate need. The material on scripting FileMaker was interesting, but not something I needed from a reference to the language overall. Likewise for the final chapter, The Business of Automation, which offers some career advice for would-be professional AppleScripters.
Aside from these pockets of filler-in-the-eye-of-the-beholder, reading AppleScript can help you pick up some good script writing habits and give you a solid grounding in the particulars of the language. But when it came time for me to write my first significant AppleScript, I still found myself trawling through Google and Macscripter for missing clues and example code more in line with what I was trying to accomplish. AppleScript was a good started book, but I think I'll want to turn to other sources for just that extra bit more.
