I recently had to make a tool for resizing and compressing images. It was a complete nightmare. AppleScript has to be one of the worst development environments I've ever worked with.
One of the most fascinating things about the design is the concept of the
tell application clause. I don't know exactly how it works, but depending on what bundle you are within, the same syntax/code can have different results - or even what appears to be the same result, but further on in the program it doesn't work as expected. The syntax is also overly verbose, as can be seen in the example code. There appear to be multiple ways of doing the same thing, but sometimes with subtle differences.
Another thing I found overly complex is accessing and manipulating file paths. In, say, Ruby, we have
String for representing paths. It is all fairly straight forward. In AppleScript, we have
alias (not exactly paths - kind of like a hard link to a file),
folder. You can't have a file, folder or alias to a file that does not exist yet. Also, you have POSIX paths ("/a/b/c"), and also Mac OS paths ("Volume:a:b:c"). The "Image Events" tool was very peculiar, it required an alias as created in "System Events", the ones returned by "Finder" did not appear to work correctly.
Another fun fact, there is no simple to use function to tell if an alias is a file or folder (as far as I can tell). The only way I could do this was to create a "disk item" and check whether the derived class was "folder" or "file".
There is also no public type system. You just get errors when executing code. The documentation is also fairly difficult to access - you have to load up specific "dictionaries" of documentation and while they are individually fairly well structured, it is hard to cross reference material.
This code lets you drop items onto the application icon. It then descends into any directories you dropped and finds all image files. These files are then copied to the named folder you specify on the desktop. Once they have been resized as necessary, they are then compressed using ditto.
AppleScript has a lot of interesting ideas in terms of syntax and making code readable. I think that the access it provides to other applications is fantastic when compared to other similar tools. However, it has a high cost of entry for someone used to shell scripting / programming as its programming constructs are not consistent. I might need to use AppleScript again, and I'm sure as I use it more I will understand its peculiarities, but for now, I'm happy to be done with it.
This script, when files are dragged on top of the application icon, will resize them proportionally so the maximum dimension is 800px. It will then ask the user for a name and create an archive on the desktop containing all the images.
The compiled application is available.