Programming languages can be divided into two major categories: low level and high level. “Assembly language” and “machine language” are called low-level languages because they more than others “speak” the language the computer understands. On the other hand, C, C++, Pascal, Python, Visual Basic, Java, and COBOL are high-level languages because they require more manipulation by the computer, a process called compiling.
A compiler is a special program that processes statements written in a particular programming language and converts them into machine language, a “binary program” or “code,” that a computer processor uses. A compiler works with what are sometimes called 3GL and higher-level languages (3rd-generation languages, such as Java and C). Typically, a programmer writes language statements in a language such as C, Pascal, or C++ one line at a time using a tool called an editor. The “edited” file contains the source statements. The programmer then runs the appropriate language compiler (there may be several compilers for each language), specifying the name of the file that contains the source statements.
When executing the file, the compiler first parses or analyzes all of the language statements syntactically in a sequential manner and then, in one or more successive passes, builds the output code, ensuring that statements that refer to other statements are referenced correctly in the final code. The code is linked to various libraries, which are common code sections found in many programs. The use of libraries helps keep redundant coding to a minimum. The compilation output is sometimes referred to as object code or an object module. (Note that the term “object” as used in this instance is not related to object-oriented programming. The object code as used here refers to machine code that the processor executes one instruction at a time.)
High-level languages are usually compiled and are not limited to any particular computer architecture. High-level languages are much easier to read than assembly language. Compiled languages are preferred by many developers because, once compiled, the program runs faster than if it were interpreted. Once a program has been compiled, it cannot easily be changed, so there’s an element of security built in to compiled programs.
Interpreters translate code one line at time, executing each line as it is “translated,” much the way a foreign language interpreter would translate a book, by translating one line at a time. Interpreters do generate binary code, but that code is never compiled into one program entity. Instead, the binary code is interpreted each and every time the program executes. Some examples of interpreted programs are Python and Visual Basic . Where compiled programs can run on any computer, interpreted programs can only run on computers that also have the interpreter.
Interpreters offer programmers some advantages that compilers do not. Interpreted languages are easier to learn than compiled languages, which is great for beginning programmers. An interpreter lets the programmer know immediately when and where problems exist in the code; compiled programs make the programmer wait until the program is complete.