HOME

TheInfoList




A programming language implementation is a system for executing
computer programs A computer program is a collection of instructions that can be executed by a computer A computer is a machine that can be programmed to carry out sequences of arithmetic or logical operations automatically. Modern computers can perform ...
. There are two general approaches to programming language implementation:
interpretation Interpretation may refer to: Culture * Aesthetic interpretation, an explanation of the meaning of a work of art * Allegorical interpretation, an approach that assumes a text should not be interpreted literally * Dramatic Interpretation, an event i ...
and
compilation
compilation
. Interpretation is a method of executing a program. The program is read as input by an interpreter, which performs the actions written in the program. Compilation is a different process, where a
compiler In computing, a compiler is a computer program that Translator (computing), translates computer code written in one programming language (the ''source'' language) into another language (the ''target'' language). The name "compiler" is primarily ...

compiler
reads in a program, but instead of running the program, the compiler translates it into some other language, such as
bytecode Bytecode, also termed portable code or p-code, is a form of instruction set In computer science, an instruction set architecture (ISA), also called computer architecture, is an abstract model of a computer. A device that executes instructions ...
or
machine code In computer programming Computer programming is the process of designing and building an executable computer program to accomplish a specific computing result or to perform a particular task. Programming involves tasks such as analysis, ge ...
. The translated code may either be directly executed by hardware, or serve as input to another interpreter or another compiler.


Interpreter

An interpreter is composed of two parts: a
parser Parsing, syntax analysis, or syntactic analysis is the process of analyzing a of , either in , or s, conforming to the rules of a . The term ''parsing'' comes from Latin ''pars'' (''orationis''), meaning . The term has slightly different meani ...

parser
and an
evaluator In computer science, an interpreter is a computer program that directly execution (computers), executes instructions written in a Programming language, programming or scripting language, without requiring them previously to have been Compiler, comp ...
. After a program is read as input by an interpreter, it is processed by the parser. The parser breaks the program into language components to form a
parse tree A parse tree or parsing tree or derivation tree or concrete syntax tree is an ordered, rooted tree (data structure), tree that represents the syntax, syntactic structure of a string (computer science), string according to some context-free grammar ...
. The evaluator then uses the parse tree to execute the program.


Virtual machine

A
virtual machine In computing, a virtual machine (VM) is the virtualization In computing, virtualization or virtualisation (sometimes abbreviated v12n, a numeronym) is the act of creating a virtual (rather than actual) version of something, including virtual co ...
is a special type of interpreter that interprets bytecode. Bytecode is a
portable Portable may refer to: General * Portable building, a manufactured structure that is built off site and moved in upon completion of site and utility work * Portable classroom, a temporary building installed on the grounds of a school to provide ad ...
low-level code similar to machine code, though it is generally executed on a virtual machine instead of a physical machine. To improve their efficiencies, many programming languages such as
Java Java ( id, Jawa, ; jv, ꦗꦮ; su, ) is one of the Greater Sunda Islands in Indonesia. It is bordered by the Indian Ocean to the south and the Java Sea to the north. With a population of 147.7 million people, Java is the world's List of ...
,
Python Python may refer to: * Pythonidae The Pythonidae, commonly known as pythons, are a family of nonvenomous snakes found in Africa, Asia, and Australia. Among its members are some of the largest snakes in the world. Ten genera and 42 species ...
, and C# are compiled to bytecode before being interpreted.


Just-in-time compiler

Some virtual machines include a just-in-time (JIT) compiler to improve the efficiency of bytecode execution. While the bytecode is being executed by the virtual machine, if the JIT compiler determines that a portion of the bytecode will be used repeatedly, it compiles that particular portion to machine code. The JIT compiler then stores the machine code in
memory Memory is the faculty of the brain A brain is an organ Organ may refer to: Biology * Organ (anatomy) An organ is a group of Tissue (biology), tissues with similar functions. Plant life and animal life rely on many organs that co-exis ...
so that it can be used by the virtual machine. JIT compilers try to strike a balance between longer compilation time and faster execution time.


Compiler

A
compiler In computing, a compiler is a computer program that Translator (computing), translates computer code written in one programming language (the ''source'' language) into another language (the ''target'' language). The name "compiler" is primarily ...

compiler
translates a program written in one language into another language and Most compilers are organized into three stages: a front end, an optimizer, and a back end. The front end is responsible for understanding the program. It makes sure the program is valid and transforms it into an
intermediate representation An intermediate representation (IR) is the data structure or code used internally by a compiler or virtual machine to represent source code. An IR is designed to be conducive for further processing, such as Compiler optimization, optimization a ...
, a data structure used by the compiler to represent the program. The optimizer improves the intermediate representation to increase the speed or reduce the size of the
executable In computing Computing is any goal-oriented activity requiring, benefiting from, or creating computing machinery. It includes the study and experimentation of algorithmic processes and development of both computer hardware , hardware and ...
which is ultimately produced by the compiler. The back end converts the optimized intermediate representation into the output language of the compiler. If a compiler of a given
high level language In computer science Computer science deals with the theoretical foundations of information, algorithms and the architectures of its computation as well as practical techniques for their application. Computer science is the study of Algori ...
produces another high level language, it is called a
transpiler A source-to-source translator, source-to-source compiler (S2S compiler), transcompiler, or transpiler is a type of translator (computing), translator that takes the source code of a program written in a programming language as its input and prod ...
. Transpilers can be used to extend existing languages or to simplify compiler development by exploiting
portable Portable may refer to: General * Portable building, a manufactured structure that is built off site and moved in upon completion of site and utility work * Portable classroom, a temporary building installed on the grounds of a school to provide ad ...
and well-optimized implementations of other languages (such as C). Many combinations of interpretation and compilation are possible, and many modern programming language implementations include elements of both. For example, the
Smalltalk Smalltalk is an object-oriented programming, object-oriented, dynamically typed reflection (computer science), reflective programming language. Smalltalk was created as the language underpinning the "new world" of computing exemplified by "human ...

Smalltalk
programming language is conventionally implemented by compilation into
bytecode Bytecode, also termed portable code or p-code, is a form of instruction set In computer science, an instruction set architecture (ISA), also called computer architecture, is an abstract model of a computer. A device that executes instructions ...
, which is then either interpreted or compiled by a
virtual machine In computing, a virtual machine (VM) is the virtualization In computing, virtualization or virtualisation (sometimes abbreviated v12n, a numeronym) is the act of creating a virtual (rather than actual) version of something, including virtual co ...
. Since Smalltalk bytecode is run on a virtual machine, it is portable across different hardware platforms.


Multiple implementations

Programming languages can have multiple implementations. Different implementations can be written in different languages and can use different methods to compile or interpret code. For example, implementations of
Python Python may refer to: * Pythonidae The Pythonidae, commonly known as pythons, are a family of nonvenomous snakes found in Africa, Asia, and Australia. Among its members are some of the largest snakes in the world. Ten genera and 42 species ...
include: *
CPython CPython is the reference implementation In the software development process In software engineering, a software development process is the process of dividing software development work into smaller, parallel or sequential steps or subpro ...
, the
reference implementation In the software development process In software engineering, a software development process is the process of dividing software development work into smaller, parallel or sequential steps or subprocesses to improve Software design, design, So ...
of Python *
IronPython IronPython is an implementation of the Python programming language targeting the .NET Framework and Mono. Jim Hugunin created the project and actively contributed to it up until Version 1.0 which was released on September 5, 2006. IronPython 2. ...
, an implementation targeting the
.NET Framework The .NET Framework (pronounced as "''dot net"'') is a software framework In computer programming Computer programming is the process of designing and building an executable computer program to accomplish a specific computing result or t ...
(written in C#) *
Jython Jython is an implementation of the Python programming language Python is an interpreted high-level general-purpose programming language. Python's design philosophy emphasizes code readability with its notable use of significant indentat ...
, an implementation targeting the Java virtual machine *
PyPy PyPy () is an alternative implementation of the Python PYTHON was a Cold War contingency plan of the Government of the United Kingdom, British Government for the continuity of government in the event of Nuclear warfare, nuclear war. Background ...
, an implementation designed for speed (written in RPython)


References


External links

* {{DEFAULTSORT:Programming Language Implementation
Implementation Implementation is the realization of an application, or execution of a plan A plan is typically any diagram or list of steps with details of timing and resources, used to achieve an Goal, objective to do something. It is commonly understood a ...