Compiler

A compiler is a computer program designed to take a source code file, check the file for syntax errors, and if none are found, produce an output file, which is then used to invoke that program. If there are syntax errors, the compiler informs the programmer of what they are, allowing her or him to edit the program to correct them, and recompile. The results [roduced ny a compiler can be done in any of several ways:


 * Produce an executable file, without using an intermediate linker (or linking the file internally), which can then be invoked immediately. This was a feature of the Turbo Pascal compiler, and is currently done by Free Pascal and Delphi.
 * Produce an object file, which must be linked with other routines such as external modules, a run-time library or Initialization system. At that point, it can now be invoked like any other program. Pascal compilers on mainframe and minicomputers did this, but Free Pascal and Delphi offer it as an option besides compiling to an executable.
 * Produce code in some other language. For Pascal, that can be C or C++ code, or assembly language. This must be then passed to a compiler for that language (or an assembler if it is assembly language), then that file must be compiled (or assembled), its output linked, and then that program can be invoked. The OMSI Pascal compiler for the PDP-11 minicomputer, produced assembly language it then passed on to its assembler, and GCC Pascal, which produced C code for the GNU C compiler/
 * Produce code in a special "virtual" object code or assembly language, which is fed into an interpreter, and executed using that method. The older P4 and P6 compilers, as well as the Stanford Pascal Compiler, do this. This is the same thing Java compilers do, produce bytecode for the Java Virtual Machine.

Sometimes the compiler does more than one of these anyway (or will do so on request, usually through a compiler directive), allowing programmers to examine the intermediate output, whether it's a program in another language, or an object file.

There are benefits and drawbacks to all three of these approaches.
 * In the case of a compiler that produces an immediate executable, this may mean the program might not be usable by other programs, such as being statically linked with them.
 * For compilers that produce an object file, the compiler doesn't have to also link programs, making it simpler. But this means it requires an extra step to produce an executable.
 * For compilers that translate a program into another programming language, this adds another step, as that file has to then be compiled (or assembled), then if that compiler does not itself produce direct executables, then link that program. This drawback may be lessened if the compiler invokes the other one after it finishes to process the intermediate file.
 * In the case of virtual object code, interpretive execution will be slower than code compiled to the object code of that machine.