Slashdot Mirror


Teach Yourself AppleScript in 24 Hours

honestpuck contributes this review of Sams Publishing's Teach Yourself AppleScript in 24 Hours, writing "The market for books on AppleScript cannot be a large one, since there never seem to be many volumes in it; usually only one at a time is up to date and worth the money. Now that O'Reilly's AppleScript In A Nutshell is showing its age (and wasn't that great in the first place), and Danny Goodman's book is even older, I was pleased to hear that this volume had come along." Read on for honestpucks' mixed impressions of the book. Teach Yourself AppleScript in 24 Hours author Jesse Feiler pages 432 publisher Sams Publishing rating 7 reviewer Tony Williams ISBN 0672325187 summary Not a bad introduction to AppleScript but leaves off far too early.

Teach Yourself Applescript in 24 Hours (TYA) from Sams Publishing is certainly up to date: it covers Applescript under OS 10.2 and the use of AppleScript Studio to build GUI applications using the language. That's its strength. The book's first weakness, though, is that it starts too far down the learning curve in my opinion. The first few chapters of TYA could be read by someone almost totally new to the Macintosh -- they cover such basics as running the scripts installed with the OS and getting new scripts from Apple and installing them. At the same time, they introduce basic AppleScript programming terminology not really required for these sorts of tasks such as suites, classes and commands. This material would have best waited a few chapters. It is not really until 'Hour 6', most of the way through the first part of the book, that it really sorts itself out and gets down to really teaching you AppleScript.

The Basics The book is divided into four parts: 'Getting Started With AppleScript,' which covers using scripts and basic programming concepts; 'Writing Scripts With Script Editor,' which takes you through using the Script Editor, details AppleScript syntax and how to script the Finder and various applications and using AppleScript Dictionaries; 'Working With AppleScript Studio,' which covers building AppleScript-based GUI applications using Project Builder and Interface Builder all the way through to complex applications that can store and retrieve documents; and a final section 'Advanced Scripting,' which covers Script Objects, scripting across a network (including SOAP and XML-RPC), and integrating scripts with the terminal and cron.

Each section is then divided up into chapters designed to be worked through in less than an hour ,with a small number of short exercises at the end. I found that most chapters took me about half an hour before I reached the exercises, which then took ten to fifteen minutes.

As you can see, almost everything you could ask for is touched on in this book. Once over the introductory chapters, I found the book to be well laid out, well structured and well written. I particularly liked Part III on AppleScript Studio; it started easily and worked up to quite an advanced little application explaining everything well along the way.

The Bad There are some things missing, however. Debugging is hardly mentioned (3/4 of one lesson), and debugging is not exactly trivial in AppleScript. I also found no mention of my pet demon with AppleScript; its incredibly strong typing and problems with having data in the wrong type; this is a classic problem with files and file names. In reality, this book teaches you the language without really getting down to teach you how to program in the language. A fine distinction, I know, but after just reading Learning Perl Objects, References & Modules, I found TYA to be light on real examples and real world code. Even the best section, the one on AppleScript Studio, didn't touch on many things you will need to know.

Sams have a page devoted to the book at the Sams web site, but frankly the URL is so long and cumbersome I don't dare risk putting it in a post. Go to the site and type 'AppleScript' in the search box. It has the table of contents and a sample chapter and some of the code from the book. The sample chapter is the third chapter 'Running The Scripts You Already Have' and really doesn't give you a good feel for how the book teaches you AppleScript programming. The page to download the code examples says "All the code developed for the book in one convenient download," but in fact all you get are the AppleScript Studio projects and source from four of the chapters. Oh, and the introduction says "There are even a few goodies on the web site that aren't in the book" -- they sure must be good as I couldn't find them.

In conclusion, I think this book starts too far down the learning curve and leaves off too early, with not enough detail. It seems a shame, what we have here is well laid out and well written, I wanted it to be better after I had finished. This book might suit someone absolutely new to the Mac who wanted to learn enough AppleScript to perform a few basic operations, for everyone else it'll be better to wait till October when AppleScript 1-2-3 will be out from Peachpit and AppleScript: The Definitive Guide will be out from O'Reilly, and we might have a better option. If you absolutely need to get some help with AppleScript Studio then borrow someone else's copy or find one second hand.

You can purchase Teach Yourself AppleScript in 24 Hours from bn.com. Slashdot welcomes readers' book reviews -- to see your own review here, read the book review guidelines, then visit the submission page.

18 of 202 comments (clear)

  1. $7.50 cheaper! by Anonymous Coward · · Score: 0, Informative
  2. Resources by daeley · · Score: 4, Informative

    For those with AppleScript Studio and the Developers Tools installed, head on over to this path for all kinds of cool info: /Developer/Documentation/CoreTechnologies/AppleScr iptStudio/

    There's also online resources, naturally: Apple's AppleScript site, AppleScript Studio Essentials docs, the AppleScript Studio mailing list, and lots of other stuff.

    --
    I watched C-beams glitter in the dark near the Tannhauser gate.
  3. Get it from just 12.49! by Anonymous Coward · · Score: 3, Informative
  4. Applescript Additions by Squidgee · · Score: 4, Informative
    Apple's beta of GUI Scripting allows for Applescript to click menus and buttons like a person; a fun addition you should check out if you're into Applescript.

    It adds a whole new dimension of customizability to Mac OS X; now you can script your Mac to the same level you can script Linux/*BSD/Unix. =)

    1. Re:Applescript Additions by Squidgee · · Score: 2, Informative

      Sorry, the link should be: this. Slight typo; sorry.

  5. Teach Yourself Programming in Ten Years by willpost · · Score: 2, Informative

    "either people are in a big rush to learn about computers, or that computers are somehow fabulously easier to learn than anything else. There are no books on how to learn Beethoven, or Quantum Physics, or even Dog Grooming in a few days."

    "Let's analyze what a title like Learn (this_language) in Three Days could mean:"

    "* Learn: In 3 days you won't have time to write several significant programs, and learn from your successes and failures with them. You won't have time to work with an experienced programmer and understand what it is like to live in that environment. In short, you won't have time to learn much. So they can only be talking about a superficial familiarity, not a deep understanding. As Alexander Pope said, a little learning is a dangerous thing."

    "* (this_language): In 3 days you might be able to learn the syntax of (this_language) (if you already knew a similar language), but you couldn't learn much about how to use the syntax. In short, if you were, say, a Basic programmer, you could learn to write programs in the style of Basic using (this_language) syntax, but you couldn't learn what (this_language) is actually good (and bad) for. So what's the point? Alan Perlis once said: "A language that doesn't affect the way you think about programming, is not worth knowing". One possible point is that you have to learn a tiny bit of (this_language) (or more likely, something like Visual Basic or JavaScript) because you need to interface with an existing tool to accomplish a specific task. But then you're not learning how to program; you're learning to accomplish that task."

    "* in Three Days: Unfortunately, this is not enough, as the next section shows."

    http://www.norvig.com/21-days.html

  6. Re:Somewhat off topic but... by davidsheckler · · Score: 3, Informative

    Okay, python Mac extensions:

    mac (Mac)
    macerrors (Mac)
    macfs (Mac)
    MacOS (Mac)
    macostools (Mac)
    macpath
    macresource (Mac)

    Carbon interface for GUI:

    Carbon.AE (Mac)
    Carbon.AH (Mac)
    Carbon.App (Mac)
    Carbon.CaronEvt (Mac)
    Carbon.CF (Mac)
    Carbon.CG (Mac)
    Carbon.Cm (Mac)
    Carbon.Ctl (Mac)
    Carbon.Dlg (Mac)
    Carbon.Evt (Mac)
    Carbon.Fm (Mac)
    Carbon.Folder (Mac)
    Carbon.Help (Mac)
    Carbon.List (Mac)
    Carbon.Menu (Mac)
    Carbon.Mlte (Mac)
    Carbon.Qd (Mac)
    Carbon.Qdoffs (Mac)
    Carbon.Qt (Mac)
    Carbon.Res (Mac)
    Carbon.Scrap (Mac)
    Carbon.Snd (Mac)
    Carbon.TE (Mac)
    Carbon.Win (Mac)

    I'm sure perl has similar extentions.

  7. Re:Somewhat off topic but... by taybin · · Score: 4, Informative

    Why applescript? That's because mac applications can include "dictionaries" of commands that applescript can use. Try scripting photoshop and filemaker in python or some other language.

    That's applescript's true power really. If it was just used as a standalone language without outside application support, it would be fairly weak.

  8. Re:WTF? Apple Script! Oxymoron! by proj_2501 · · Score: 2, Informative

    "Now I am really confused... On the many occasions I have dabbled with Apple Computers (after the Apple IIe I had in high school), they have been absurdly graphics-centric. Normally, scripting is associated with accomplishing tasks in a command line environment."

    Scripting and macros have been part of the Mac user interface since before the actual release of AppleScript. Many Macintosh applications have a second, non-graphical interface available to AppleScripts, allowing them to be controlled or recorded much like the macros in Microsoft Office or the Actions in Photoshop.

  9. Re:Somewhat off topic but... by follower-fillet · · Score: 5, Informative

    > Why applescript? That's because mac applications can include "dictionaries" of commands that applescript can use.

    Actually:

    "The Open Scripting Architecture (OSA) is an API that provides a standard mechanism for creating scriptable applications and for writing scripting components to implement scripting languages. The AppleScript component implements AppleScript, the standard scripting language defined by Apple, but developers can also write scripting components for additional scripting languages."

    -- <http://developer.apple.com/documentation/Carbon/R eference/Open_Scripti_Architecture/>

    So you're not restricted to using AppleScript to get those benefits.

    Python, for example, is able to both send and receive Apple Events.

  10. Re:Oh, Applescript... by Frobozz0 · · Score: 2, Informative

    Apple does let you use JavaScript OSA syntax. You can install it and start writing in a syntax you're more compfortable in.

    http://www.latenightsw.com/freeware/JavaScriptOS A/ index.html

    --
    "Politicians find new names for institutions which under old names have become odious to the people."
  11. Re:Oh, Applescript... by Johnny+Mnemonic · · Score: 2, Informative


    /me waits for Mac zealots to moderate this as a troll

    I wouldn't moderate it as a troll, but I would moderate it as "-1 uninformed".

    [jmibook:~] jm% whereis python
    /usr/bin/python

    [jmibook:~] jm% whereis perl
    /usr/bin/perl

    Maybe it requires the developer tools; a large download, but still free. Apple has simply left Applescript in place for those who prefer it. You can even call shellscripts from AppleScript Studio, so don't even have to use AppleScript to take advantage of AppleScript Studio's GUI hooks. Good enough?

    --

    --
    $tar -xvf .sig.tar
  12. Re:What is it good for? by larkost · · Score: 2, Informative

    I actually use AppleScript for a one-off project about every other week. I am maintaining a cluster of FileMaker Pro databases, and there is a lot of data that needs to be massaged. For things that need to touch outside files for their information, and can't be simple imports, I find AppleSctipt very useful.

    I have also worked with AppleScript Studio, and it makes creating small programs on MacOS X very simple. You can even use it to glue nice GUI's onto scripts or other small program segments. I wrote a small program in ObjC and used AppleScript to connect it to iTunes. It would have been possible with other methods (AppleEvents), but much more difficult.

    It is very appropriate to compare it to VBScript in Windows, but from experience it is much more elegant.

  13. Re:Somewhat off topic but... by WatertonMan · · Score: 2, Informative
    Applescript is an application scripting language. I sure there is YACC/LEX code floating around for the language. So in theory it wouldn't be that hard to port.

    Python, Perl and to a lesser extent Javascript aren't designed for this. (I say lesser extent Javascript, since there actually is a version of Javascript that compiles to the same format Applescript uses and works in the same way)

    Javascript OSA

    One must also point out that there are glue modules for Perl that allow it to do most Applescripting.

    Applescript Module
    Applescript Glue for Perl

    I agree that in general one would be better off using an other scripting language. But Applescript is useful -- especially for small tasks. (I think the majority of my scripts are less than 25 lines long)

    I've not tried using the more robust OSA features in Python. Ususally I just call applescripts. I plan on doing more of this during the upcoming weeks.

    Python OSA Applescript

    Unfortunately as I alluded in my other post, Applescript Studio doesn't really support OSA languages other than Applescript. (OSA is from a programmer's perspective something like the VM for Java - it lets you use other languages)

    I 100% agree that having a good general scripting book for OSX would be a great idea. It would have to be very practical. Here's hoping.

  14. Re:I've got a better book for you. by Bert+Altenburg · · Score: 5, Informative

    Hi,

    For a free starter on AppleScript, way more up to date that the above book, check out http://fischer-bayern.de/applescript/html/ebook.ht ml where you can find AppleScript for Absolute Starters (pdf). It teaches the basics of AppleScript with the much improved Script Editor currently available in beta.

    The web-page is in German, but if you look in the table, you'll find the English version of the booklet.

    Bert

    --
    PC manufacturers are guilty of perpetuating monopoly abuse by M$ until they include a partition with Linux pre-installed
  15. Re:Somewhat off topic but... by chigaze · · Score: 2, Informative

    Why Applescript? Because sometimes you are scripting things that are platform specific.

    For example I just finished up part of a Filemaker solution that uses PDF Services in OS X and Applescript to generate, name, and move to a destination folder PDFs from Filemaker records. Picking up the necessary Applescript knowledge to do this took extremely little time compared to what it would have taken me to learn PERL, for example.

  16. Strong typing? by MacDork · · Score: 2, Informative

    but because of its strong typing you have to write the sentences exactly correct

    You mean proper syntax? Most every language I've ever used enforces that. Strong typing in AppleScript?

    on run

    set x to "A string"

    foo(x)

    set x to 1

    foo(x)

    set x to x as string

    foo(x)

    end run

    on foo(some_var)

    display dialog some_var

    end foo

    That script will run. Definately not strong typing.

  17. tell people slashdot crowd check this out end tell by Ukab+the+Great · · Score: 2, Informative

    Here's a cool hack that someone did in applescript that illustrates why one would want to learn Applescript.