Free Trial

Safari Books Online is a digital library providing on-demand subscription access to thousands of learning resources.

  • Create BookmarkCreate Bookmark
  • Create Note or TagCreate Note or Tag
  • PrintPrint
Share this Page URL

Introduction > Advantages and Disadvantages

Advantages and Disadvantages

AppleScript is by no means the only scripting language for OS X. Nonetheless, AppleScript has several advantages that make the best option for many jobs:

  • It's more like English than any other Mac language. AppleScript's greatest advantage is that it uses grammar that closely resembles the commands you'd give to your seven-year-old son. (A typical command, for example, would be "say cheese", which would have your computer speak the word "cheese" out loud.)

    If you've never learned a computer language before, you'll be grateful that AppleScript doesn't bother with semicolons, curly brackets, and all the other annoyances of more advanced computer languages. Even better, AppleScript is not case-sensitive—a feature you can appreciate only if you've ever had to search through reams of code just to find a mis-capitalized command name.

  • It works with the same programs that you do. Virtually every big-name Mac program supports AppleScript commands: Microsoft Word, Adobe Photoshop, FileMaker Pro, and so on. Lots of free programs support AppleScript, too: TextEdit, Address Book, Mac OS X Mail, iPhoto, and many more.

For a list of common programs that work with AppleScript, see Appendix A.

  • It works with other computer languages, too. AppleScript isn't just a little software island; it's got bridges to virtually every other programming language on Mac OS X. If you're a serious Unix hacker, for example, you can mix AppleScript commands right into your Unix programs (Chapter 13). And this cross-pollination works the other way around, too: you can mix Unix commands into your AppleScript programs just as easily (Chapter 13).

  • Lots of people use it. There are several popular gathering places for AppleScripters online, where you'll find useful pre-made scripts for free. If you're having a problem, chances are that someone else has had the same problem and posted a fix somewhere on the Web. And if you simply can't work a problem out, AppleScript's large community means that someone else can almost always help you fix it. (Appendix C has a list of these resources.)

Despite all its advantages, however, AppleScript isn't perfect. Several trade-offs had to be made to make it more like English, for example, and the language sometimes reveals all too well that it was designed with 10-year-old computers in mind. Here are some of AppleScript's biggest weaknesses:

  • Commands are sometimes inconsistent between programs. Because AppleScript has changed so many times over the years, some commands work differently in different programs. This isn't a complete showstopper, though; it just means you may have to dig deeper into a program's dictionary (Chapter 3) to find the right command.

  • Some programs don't support AppleScript at all. Certain programs, unfortunately, don't take advantage of all that AppleScript has to offer. Programs that show up in this category are usually old, free, and/or made by a company that doesn't make Mac support a top priority.

    Still, all hope is not lost. If a program you use regularly doesn't work with AppleScript out of the box, you may find that someone on the Internet has written a plug-in that adds AppleScript support. And as a last resort, you can use Apple's own GUI Scripting feature (Chapter 12) to bend non-scriptable programs to your will.

  • It's slower than most other languages. In exchange for all the power AppleScript grants you, the language has an unusually high overhead for running commands. In the real world, it probably won't make much of a difference—AppleScript is still dozens of times faster than you are. But if speed is of utmost importance to you (say, you work in a mathematical or scientific field), you might want to look elsewhere for a language that better suits your needs.

  • It only works with Macs. Furthermore, if you write scripts that take advantage of new AppleScript features, your scripts will only work in Mac OS X. Of course, if you're only going to write scripts for your computer, this isn't a big deal. But if you need to exchange scripts with Windows or Linux users, you'll need to find a cross-platform language.

In total, AppleScript is wonderful if you're an everyday Mac user who wants to automate things, but it's useless if you need your scripts to run on Windows.

  • Safari Books Online
  • Create BookmarkCreate Bookmark
  • Create Note or TagCreate Note or Tag
  • PrintPrint