ORGANISATION OF PROGRAMMING
LANGUAGES
(CMP 401)
Egena Onu, Ph.D.
LANGUAGE DEFINITION
Languages are defined on the basis of characters and symbols
which are strung up to form words or signs.
The input/output of any algorithm must be presented as a
finite string of symbols – the raw contents of some contiguous
portion of the computer’s memory.
Reasoning about computation, from this view therefore
requires reasoning about strings.
Suppose there is an arbitrary set Σ called alphabet.
The elements of Σ are called symbols or characters.
LANGUAGE DEFINITION
A string (or word) over Σ is a finite sequence of zeros or more
symbols from Σ.
Formally, a string w over Σ is defined (recursively) as either:
The empty string, denoted by ԑ (epsilon), or
An ordered pair (a,x), where a is a symbol in Σ and x is a string over Σ.
Normally, either a·x or simply ax is used to denote (a,x).
Similarly, explicit strings are simply written as a sequence of
symbols instead of nested ordered pair.
For example, STRING is a convenient shorthand for the fromal
expression (S,(T,(R,(I,(N,(G,ԑ)))))).
LANGUAGE DEFINITION
The set of strings over Σ is denoted by Σ* (sigma star).
All the elements in Σ* is a set of finite string, although
Σ* is an infinite set containing strings of every possible
finite length.
The length |w| of a string is formally defined as:
For example, the string SEVEN has length 5.
LANGUAGE DEFINITION
The Concatenation of two strings x and y, denoted either x·y or simply
xy, is the unique string containing the characters of x in order followed
by the characters in y in order.
For example, the string NOWHERE is the concatenation of the strings
NO and WHERE.
That is NO·WHERE = NOWHERE.
Concatenation is formally defined as:
When describing concatenation of more that two strings, dots and
parentheses are normally omitted.
This is done by simply writing wxyz instead of (w·(x·y)·z.
FORMAL LANGUAGES
Following from strings, a formal language is a set of finite
alphabet Σ, or equivalently, an arbitrary subset of Σ*.
For example, each of the following sets is a language:
The empty set Ø.
The set {ԑ}.
The set {0,1}.
The set {THE, OXFORD, ENGLISH, DICTIONARY}.
Formal languages are not languages in the same sense that
English, Python and Klingon are languages.
Strings in a formal language do not necessarily carry any
meaning nor are they assembled into larger units.
LANGUAGE EVALUATION CRITERIA
When it comes to computing, except they are standardised, not many
concepts are agreed upon.
This is the case on the criteria for evaluating programming languages.
As a programmer, it is important to understand the underlying concepts of the
various constructs and capabilities of the language.
Some of the commonly used criteria for evaluating a programming language
are:
Readability
Writability
Reliability and
Cost
Though it may be seen as rather controversial, a list of evaluation criteria is
presented in the following table.
LANGUAGE EVALUATION CRITERIA
LANGUAGE EVALUATION CRITERIA
Readability
The ease with which a program can be read and understood is one of the most
important criteria for judging programming languages.
There was a time when programming was largely thought of in terms of
writing codes.
At this stage, the primary positive characteristic of programming languages
was efficiency.
Language construct were designed more from the point of view of the
machines instead of the users.
Things changed when it SDLC integrated maintenance in the cycle.
Readability became an important criteria for measuring the quality of
programming languages because maintenance depends largely on readability.
LANGUAGE EVALUATION CRITERIA
Writability
Writability is a measure of how easily a language can be
used to create programs for a chosen problem domain.
Like readability, writability is also considered in the context
of the target problem domain of the language.
Writability eases the ability to chose languages in solving
problems in particular domains.
For example, the writabilities of Visual BASIC (VB) and C
are dramatically different for creating a program that has a
graphical user interface (GUI) for which VB is particularly
designed for.
LANGUAGE EVALUATION CRITERIA
Reliability
A program is said to be reliable if it performs to its
specification under all conditions.
Reliability is measured based on characteristics such as:
Type checking
Exception handling
Aliasing
Readability and writability.
LANGUAGE EVALUATION CRITERIA
Cost
The total cost of a programming language is a function of many of its
characteristics:
1. Cost of training programmers to use the language
This is a function of the simplicity and orthogonality and
experience of the programmer.
Although more powerful not necessarily more difficult to learn,
they often are.
2. Cost of writing programs in the language
This is a function of the writability of language which depends in
part on its closeness in purpose to the particular application.
The original efforts to design and implement high level languages
were driven by the desire to lower the costs of creating software.
LANGUAGE EVALUATION CRITERIA
Cost
3. Cost of compiling
For example, the major impediment to early use of Ada was the
prohibitively high cost of running the first generation of Ada compilers.
4. Language design
The cost of executing programs written in a language isi greatly
influenced by the design.
Some language that requires many run-time type checks will prohibit
fast code execution, regardless of the quality of the compiler.
A simple trade off can be made between compilation cost and execution
speed of the compiled code using optimisation.
Optimisation is a collection of techniques that compilers use decrease
the size and/or increase the execution speed of the code they produce.
INFLUENCES ON LANGUAGE DESIGN
Apart from the language evaluation criteria, there are
other factors that influence the basic design of
programming languages.
The most important of these factors are computer
architecture and programming design methodologies.
INFLUENCES ON LANGUAGE DESIGN
Computer Architecture
The basic architecture of computers has had a profound effect
on language design.
Most of the popular languages of the past 60 years have been
designed around the prevalent computer architecture, called
the von Neumann architecture.
John von Neumann is one of the originators of this
architecture therefore it is named after him.
INFLUENCES ON LANGUAGE DESIGN
Von Neumann Architecture
In a von Neumann computer, both the data and programs are stored in
the same memory.
The central processing unit (CPU) which executes the instruction is
separate from the memory.
Therefore, instructions and data must be transmitted, or piped from
memory to the CPU.
Results of operations in the CPU are then moved back to the memory.
Nearly all the digital computers built since the 1940s are based on this
architecture.
INFLUENCES ON LANGUAGE DESIGN
Von Neumann Architecture
INFLUENCES ON LANGUAGE DESIGN
Von Neumann Architecture
The execution of a machine code program on a von Neumann
architecture occurs in a process called the fetch-execute cycle.
Always remember that the program resides in the memory but are
executed by the CPU.
Each instruction to be executed must be moved from memory to the
processor.
The address of the next instruction to be executed is maintained in a
register called the program counter.
The fetch-execute cycle is as follows:
initialize the program counter
repeat forever
fetch the instruction pointed to by the program counter
increment the program counter to point at the next instruction
decode the instruction
execute the instruction
end repeat
LANGUAGE IMPLEMENTATION
METHODS
From the von Neumann Architecture, two of the primary
components of a digital computer are: the processor and
internal memory.
The internal memory stores program and data.
The processor is a collection of circuits that provides a
realisation of a set of primitive operations or machine
instructions such as arithmetic and logic operations.
Some of these machine instructions are sometimes called
microinstructions which are defined at lower levels.
LANGUAGE IMPLEMENTATION
METHODS
Language implementation methods provide the facilities
through which high level programming languages get to speak
the language of the machine.
Implementation methods require a large collection of programs
(operating system) which supplies higher-level primitives than
those of the machine language.
These primitives provide
System resource management
Input and output operations
File management system
text/ and/or program editors
And a host of other functionalities.
LANGUAGE IMPLEMENTATION
METHODS
Because language implementation systems need many of the
operating system facilities, they interface with the OS rather than
directly with the processor.
The OS and language implementations are layered over the machine
language interface of the computer.
These layers can be thought of a virtual computers, providing
interface to the user at higher levels.
Most computer systems provide several different virtual computer.
The user programs form another layer over the top of the layer of
virtual computers.
LANGUAGE IMPLEMENTATION
METHODS
Layered interface of virtual computers, provided by a
typical computer system
LANGUAGE IMPLEMENTATION
METHODS
There are several methods of implementing a
programming language:
Compilation
PureInterpretation
Hybrid Implementation Methods
LANGUAGE IMPLEMENTATION
METHODS
QUESTIONS!