History: History of Compiler Construction

Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1of 4

compiler is a computer program (or set of programs) that transforms source code written in


a programming language (the source language) into another computer language (the target
language, often having a binary form known as object code).[1] The most common reason for wanting
to transform source code is to create an executable program.

The name "compiler" is primarily used for programs that translate source code from a high-level
programming language to a lower level language (e.g., assembly language or machine code). If the
compiled program can run on a computer whose CPU or operating system is different from the one
on which the compiler runs, the compiler is known as a cross-compiler. A program that translates
from a low level language to a higher level one is a decompiler. A program that translates between
high-level languages is usually called a language translator, source to source translator, or language
converter. A language rewriter is usually a program that translates the form of expressions without a
change of language.

A compiler is likely to perform many or all of the following operations: lexical


analysis, preprocessing, parsing, semantic analysis (Syntax-directed translation), code generation,
and code optimization.

Program faults caused by incorrect compiler behavior can be very difficult to track down and work
around; therefore, compiler implementors invest significant effort to ensure compiler correctness.

The term compiler-compiler is sometimes used to refer to a parser generator, a tool often used to
help create the lexer and parser.

History[edit]
Main article: History of compiler construction

Software for early computers was primarily written in assembly language. Higher level programming
languages were not invented until the benefits of being able to reuse software on different kinds
of CPUs started to become significantly greater than the costs of writing a compiler. The
limited memory capacity of early computers led to substantial technical challenges when the first
compilers were being designed.

Towards the end of the 1950s, machine-independent programming languages were first proposed.
Subsequently several experimental compilers were developed. The first compiler was written
by Grace Hopper, in 1952, for the A-0 programming language.The A-0 functioned more as a loader
or linker than the modern notion of a compiler. The firstautocode and its compiler were developed
by Alick Glennie in 1952 for the Mark 1 computer at the University of Manchester and is considered
by some to be the first compiled programming language. The FORTRAN team led by John
Backus at IBM is generally credited as having introduced the first complete compiler in
1957. COBOL was an early language to be compiled on multiple architectures, in 1960.[2]
In many application domains the idea of using a higher level language quickly caught on. Because of
the expanding functionality supported by newer programming languages and the increasing
complexity of computer architectures, compilers have become more complex.

Early compilers were written in assembly language. The first self-hosting compiler – capable of


compiling its own source code in a high-level language – was created in 1962 forLisp by Tim Hart
and Mike Levin at MIT.[3] Since the 1970s it has become common practice to implement a compiler in
the language it compiles, although both Pascal and C have been popular choices for implementation
language. Building a self-hosting compiler is a bootstrapping problem—the first such compiler for a
language must be compiled either by hand or by a compiler written in a different language, or (as in
Hart and Levin's Lisp compiler) compiled by running the compiler in an interpreter.

Compiler output[edit]
One classification of compilers is by the platform on which their generated code executes. This is
known as the target platform.

A native or hosted compiler is one which output is intended to directly run on the same type of
computer and operating system that the compiler itself runs on. The output of across compiler is
designed to run on a different platform. Cross compilers are often used when developing software
for embedded systems that are not intended to support a software development environment.

The output of a compiler that produces code for a virtual machine (VM) may or may not be executed
on the same platform as the compiler that produced it. For this reason such compilers are not
usually classified as native or cross compilers.

The lower level language that is the target of a compiler may itself be a high-level programming
language. C, often viewed as some sort of portable assembler, can also be the target language of a
compiler. E.g.: Cfront, the original compiler for C++ used C as target language. The C created by
such a compiler is usually not intended to be read and maintained by humans. So indent style and
pretty C intermediate code are irrelevant. Some features of C turn it into a good target language.
E.g.: C code with #line directives can be generated to support debugging of the original source.

What is a Compiler?
A compiler is a program that translates a source program written in some high-level
programming language (such as Java) into machine code for some computer
architecture (such as the Intel Pentium architecture). The generated machine code can
be later executed many times against different data each time.

An interpreter reads an executable source program written in a high-level


programming language as well as data for this program, and it runs the program
against the data to produce some results. One example is the Unix shell interpreter,
which runs operating system commands interactively.

Note that both interpreters and compilers (like any other program) are written in some
high-level programming language (which may be different from the language they
accept) and they are translated into machine code. For a example, a Java interpreter
can be completely written in Pascal, or even Java. The interpreter source program is
machine independent since it does not generate machine code. (Note the difference
between generateand translated into machine code.) An interpreter is generally
slower than a compiler because it processes and interprets each statement in a
program as many times as the number of the evaluations of this statement. For
example, when a for-loop is interpreted, the statements inside the for-loop body will
be analyzed and evaluated on every loop step. Some languages, such as Java and Lisp,
come with both an interpreter and a compiler. Java source programs (Java classes
with .java extension) are translated by the javac compiler into byte-code files
(with .class extension). The Java interpreter, java, called the Java Virtual Machine
(JVM), may actually interpret byte codes directly or may internally compile them to
macine code and then execute that code.

One-pass compiler
From Wikipedia, the free encyclopedia

In computer programming, a one-pass compiler is a compiler that passes through the parts of


each compilation unit only once, immediately translating each part into its final machine code. This is
in contrast to a multi-pass compiler which converts the program into one or more intermediate
representations steps in between source code and machine code, and which reprocesses the entire
compilation unit in each sequential pass.

Multi-pass compiler
From Wikipedia, the free encyclopedia
A multi-pass compiler is a type of compiler that processes the source code or abstract syntax
tree of a program several times. This is in contrast to a one-pass compiler, which traverses the
program only once. Each pass takes the result of the previous pass as the input, and creates an
intermediate output. In this way, the (intermediate) code is improved pass by pass, until the final
pass emits the final code.
Multi-pass compilers are sometimes called wide compilers,[citation needed] referring to the greater scope
of the passes: they can "see" the entire program being compiled, instead of just a small portion of it.
The wider scope thus available to these compilers allows better code generation (e.g. smaller code
size, faster code) compared to the output of one-pass compilers, at the cost of higher compiler time
and memory consumption. In addition, some languages cannot be compiled in a single pass, as a
result of their design.

You might also like