image

Glossary: Bytecode

image

AppleScript code is compiled into bytecode. This means that, roughly speaking, the nouns and verbs of the original text are translated into a sort of compressed, coded equivalent, called tokens. These tokens are meaningful to the AppleScript runtime engine (and illegible to everyone else). The runtime engine interprets the bytecode in real time as the script runs, parsing whatever tokens it meets along its path of execution, accumulating them into chunks, and translating these chunks further, as necessary, in order to execute them.

The implication for you, the AppleScript programmer, is that in its compiled form, a script is illegible. So why are you able to read a compiled script file? It’s because AppleScript decompiles the bytecode, translating the tokens back into their English-like form. If the script targets an application, this decompilation requires the application’s dictionary.

Actually, a compiled script file contains not only bytecode but also some further information (such as variable names) needed to decompile the tokens. In a run-only script, this further information is not present, which is why the script cannot be decompiled (and therefore cannot be read by a human being).



image
Glossary: Bundle Glossary: Compiled Script File
image