-
Notifications
You must be signed in to change notification settings - Fork 1
/
__init__.py
38 lines (31 loc) · 3.29 KB
/
__init__.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
""" A compiler is a computer program that implements a programming language specification to "translate" programs,
usually as a set of files which constitute the source code written in source language, into their equivalent machine
readable instructions (the target language, often having a binary form known as object code). This translation
process is called compilation. We compile the source program to create the compiled program. The compiled program can
then be run (or executed) to do what was specified in the original source program.
The source language is always a higher-level language in comparison to machine code, written using some mixture of
English words and mathematical notation, assembly language being the lowest compilable language (an assembler being a
special case of a compiler that translates assembly language into machine code). Higher-level languages are the most
complex to support in a compiler/interpreter, not only because they increase the level of abstraction between the
source code and the resulting machine code, but because increased complexity is required to formalize those abstract structures.
The target language is normally a low-level language such as assembly, written with somewhat cryptic abbreviations for
machine instructions, in these cases it will also run an assembler to generate the final machine code. But some compilers
can directly generate machine code for some actual or virtual computer e.g. byte-code for the Java Virtual Machine.
Another common approach to the resulting compilation effort is to target a virtual machine. That will do just-in-time
compilation and byte-code interpretation and blur the traditional categorizations of compilers and interpreters.
For example, C and C++ will generally be compiled for a target `architecture'. The draw-back is that because
there are many types of processor there will need to be as many distinct compilations. In contrast Java will target a Java
Virtual Machine, which is an independent layer above the 'architecture'. The difference is that the generated byte-code,
not true machine code, brings the possibility of portability, but will need a Java Virtual Machine (the byte-code interpreter)
for each platform. The extra overhead of this byte-code interpreter means slower execution speed.
An interpreter is a computer program which executes the translation of the source program at run-time. It will not generate
independent executable programs nor object libraries ready to be included in other programs.
A program which does a lot of calculation or internal data manipulation will generally run faster in compiled form than
when interpreted. But a program which does a lot of input/output and very little calculation or data manipulation may well
run at about the same speed in either case.
Being themselves computer programs, both compilers and interpreters must be written in some implementation language.
Up until the early 1970's, most compilers were written in assembly language for some particular type of computer. The advent of
C and Pascal compilers, each written in their own source language, led to the more general use of high-level languages for
writing compilers. Today, operating systems will provide at least a free C compiler to the user and some will even include
it as part of the OS distribution."""
from . import interpreter