(1) Software that converts a set of high-level language statements into a lower-level representation. For example, a help compiler converts a text document embedded with appropriate commands into an online help system. A dictionary compiler converts terms and definitions into a dictionary lookup system.
(2) Software that translates a program written in a high-level programming language (C/C++, COBOL, etc.) into machine language. A compiler usually generates assembly language first and then translates the assembly language into machine language. A utility known as a "linker" then combines all required machine language modules into an executable program that can run in the computer. See
optimizing compiler.
The following is a conceptual example of source code being converted to assembly language and machine code by the compiler:
Source Code
IF COUNT=10
GOTO END-OF-JOB
ELSE
GOTO COMPUTE-AGAIN
ENDIF
Assembly Language Machine Language
Compare A to B Compare 3477 2883
If equal go to C If = go to 23732
Go to D Go to 23119
Machine Code
10010101001010001010100
10101010010101001001010
10100101010001010010010
From C to Assembly Language
A C/C++ compiler converts C and C++ code into assembly language as shown in this example. The red arrows point to various function calls, and the assembly code to perform those calls follows each statement.
Compilers and Interpreters
Compiled programs (right) are translated into the machine language of the target computer. Interpreted programs (left and center) are either kept in their original source code or are precompiled into an intermediate form. In both cases, an interpreter is required to translate the program into machine language at runtime, whereas the compiled program is "ready to go."