Compilers and interpreter programs
The text of the program describing the algorithm is created using a programming language. But, in order for the program to be executed, it is necessary either to translate all of its text into machine code-this is done by special programs - compilers, and then transferred for execution to the processor, or immediately execute language commands, translating into machine language and executing each team in turn - this is done by other interpreter programs.
Interpreters function as follows: take the next language operator from the text of the program, analyze its structure and then immediately execute. After successful execution of the current command, all interpreters pass to the analysis and execution of the next command. If the same operator is executed several times in the program, the interpreters each time perceive it as if they met for the first time. Therefore, programs that require a large amount of repetitive computation will work slowly. To execute the program on another computer, you also need to install the interpreter, since without it the program is a set of words and can not work.
Compilers completely process the entire text of the program. They search for syntactic errors, perform a semantic analysis and only then, if the text exactly corresponds to the rules of the language, it is automatically translated (translated) into the machine language - object code. Often the optimization is performed using a set of methods that allow increasing the speed of the program. The generated object code is processed by a special program - an assembler or linker, which binds object and machine codes. The text is converted to a ready-to-execute EXE file. It can be transferred to other computers with a processor that supports the appropriate machine code.
Compilers have a big drawback - the complexity of translating programming languages, oriented to processing data of complex structure, previously unknown or dynamically changing during the program. For such programs, additional checks and analysis of the availability of operating system resources, means for dynamically capturing and freeing the computer's memory are introduced into the machine code, which is quite difficult at the level of statically specified machine instructions, and for some tasks it is practically impossible.
In contrast, interpreters can, at any time, interrupt the operation of the program, organize a dialogue with the user, perform any complex data conversions and at the same time constantly monitor the hardware and software, which ensures high reliability of the program. Interpreters, when executing each command, check and analyze the necessary resources of the operating system, and when errors occur, they report error messages.
In real programming systems, compilation and interpretation technologies are mixed. In the process of debugging, the program can be executed in steps (trace), and the resulting code does not necessarily have to be a machine code; it can be, for example, a hardware-independent intermediate abstract processor code that will later be translated in various computer architectures using interpreters or compilers into the corresponding machine code.
