Where can I find a good comparison between “compiled script” and “application” where they list advantages and disadvantages, cases where they behave differently etc?
Script Debugger help files has the best description.
In a nut shell, an AppleScript applet is a stand alone script that can run by itself. It can be launched and run by double clicking it, or from the doc. It can also function as a droplet.
An AppleScript script is a document that contains executable code. If you double click its icon it opens in a script editor (Script Debugger or Apple’s Script Editor). It can be run from a script menu or from inside an application. (applets may also be launched from a script menu or inside an application).
Is that all? I was expecting differences when it comes to storing variables between executions, performance, memory usage and similar.
Thank you.
Since Catalina, Applescript no longer saves variables between execution
The same, which, as robertfern pointed out, is none.
Dependent on the environment the script is running in, but, largely the same.
There used to be a difference but with recent Mac OS, memory management is basically the same.
Your question is inaccurate.
For example, if you want to compare a compiled .scpt file with an application written in the Swift language - this is a comparison of a turtle with a supersonic aircraft. There is nothing to compare here. Naturally, the application will take up more memory, load more slowly, but it will retain properties between launches and give tremendous speed.
With AppleScript applications, there are many other nuances, since this is the same script wrapped in an endless “application main” loop, which is the main feature of any application. Here again, it is necessary to distinguish between applications that are terminated automatically (by some condition) and applications that are terminated by user intervention (stay-open app).
In any case, there is no single documentation about this, and it is better for you to experiment on your own in order to understand the nuances of interest to you yourself.
About the preservation of properties, memory occupied in Ram and performance, you have already been answered. What you yourself want to give preference to in a particular case is up to you. For example, for code compactness on disk, it is better to use the .applescript form altogether.
To be clear, in my response I was assuming you were asking about AppleScript applets and AppleScript scripts. Not any other kind of application.
Your assumption was 100 % correct.
I ran some brief tests and there was no difference in the time it took for code in an AppleScript application (aka applet) to execute as compared with a AppleScript compiled script. Almost certainly, there is a difference in the time it takes for a script or applet to load and commence execution, but that’s largely dependent on other factors.
There is a difference in the amount of disk space consumed, and the following is the size of a test script with 14 lines:
compiled script - 7 KB
compiled script bundle - 13 KB
application (applet) - 223 KB
The issue of applets saving persistent variables has been a pet peeve of mine for some time, and I raised this issue four years ago in a thread which can be found here. At the time, my test applet increased in size from 101 KB to 3.9 MB, but retested on my Ventura computer there was no change in size.
Anyways, there are instances where an applet is required. Otherwise, just as a matter of personal preference, I use a script or script bundle.