Programming Paradigm
Programming Paradigm
Programming Paradigm
PRPARED BY
Contacts: +211920046044
willyakuoch@gmail.com
1|Page
COURSE OUTLINE
Machine Language
Assembly language
6. Language structure
Language processing
Interpretation
Translation
Enumerated Type
2|Page
6.2 Data Structure
Array
Linked List
Tree
Hash Table
Graph
Stack
Queue
3|Page
Course Objectives:
Course Aims
i. Introduce the concepts of programming language in preparation for the main course;
4|Page
1.0 Introduction:
Several Programming Language (PL) have been developed and most of it are in used. However,
some of these PLs have similarity while some are entirely different from each other. The
programming languages design and implementation. It handles the programing paradigm and
historical pattern of programming. The course also elaborates on language structure, data type
set of principles or mathematical theory. By the word paradigm, we understand a set of patterns
and practices used to achieve a certain goal. Millions of programming languages have been
They provide similar functionality (e.g., arithmetic, logic operations, and text
processing);
They are based on the same kind of hardware and instruction sets;
They have common design goals: find languages that make it simple for humans to use
5|Page
Designers of programming languages share their design experiences.
It is worthwhile to note that many languages belong to multiple paradigms. For example, we
can say that C++ is an object-oriented programming language. However, C++ includes almost
every feature of C and thus is an imperative programming language too. We can use C++ to
write C programs. Java is more object- oriented, but still includes many imperative features.
For example, Java’s primitive type variables do not obtain memory from the language heap
like other objects. Lisp contains many non-functional features. Scheme can be considered a
subset of Lisp with fewer non-functional features. Prolog’s arithmetic operations are based on
There are many programming paradigms in use today. A main programming paradigm stems
an idea within some basic discipline which is relevant for performing computations. Some
programming languages, however, are more similar to each other, while other programming
languages are more different from each other. Based on their similarities or the paradigms,
Functional paradigm,
Logic paradigm
Object-Oriented paradigm
Visual paradigm
Parallel/concurrent paradigms,
6|Page
Dynamic paradigms.
1 Introduction
This unit discusses structured and unstructured programming towards making programming
easier to understand. While drawing the difference between structured and unstructured
language, the unit deliberates on types and components of structured programming language,
and highlighted their advantages and disadvantages.
All modern programming languages support structured programming, but the mechanisms of
support, like the syntax of the programming languages, varies. Where modules or elements of
code can be reused from a library, it may also be possible to build structured code using
modules written in different languages, as long as they can obey a common module interface
or application program interface (API) specification. However, when modules are reused, it's
possible to compromise data security and governance, so it's important to define and enforce a
privacy policy controlling the use of modules that bring with them implicit data access rights.
7|Page
• Block: It is a command or a set of commands that the program executes linearly. The
sequence has a single point of entry (first line) and exit (last line). • Selection: It is the branching
of the flow of control based on the outcome of a condition.
Two sequences are specified: the ‘if’ block when the condition is true and the ‘else’ block when
it is false. The ‘else’ block is optional and can be a no-op
• Iteration: It is the repetition of a block as long as it meets a specific condition. The evaluation
of the condition happens at the start or the end of the block. When the condition results in false,
the loop terminates and moves on to the next block.
• Nesting: The above building blocks can be nested because conditions and iterations, when
encapsulated, have singular entry-exit points and behave just like any other block.
• Subroutines: Since entire programs now have singular entry-exit points, encapsulating them
into subroutines allows us to invoke blocks by one identifier.
These practices can also be supported with unstructured languages, but that will require specific
steps in program design and implementation. Structured programming practices thus date to
the emergence of structured programming languages.
The theoretical basis for structured programming goes back to the 1950s, with the emergence
of the ALGOL 58 and 60 languages. Up to then, code clarity was reduced by the need to build
condition/action tests by having programmers write linked tests and actions explicitly (using
the goto statement or its equivalent), resulting in what was often called spaghetti code. ALGOL
included block structure, where an element of code included a condition and an action.
8|Page
Modern programming languages are universally capable of producing structured code.
Similarly, they're also capable of producing code fairly described as unstructured if used
incorrectly. Some would say that an unstructured programming language contains goto
statements and, thus, does not require a "call" to a separate module, which then returns when
complete, but that definition is unnecessarily restrictive. It's better to say that the mechanisms
for enforcing structure vary by language, with some languages demanding structure and other
accepting less-structured code.
2. 1 Procedural programming.
Defines modules as "procedures" or "functions" that are called with a set of parameters to
perform a task. A procedural language will begin a process, which is then given data. It is also
the most common category and has recently been subdivided into the following: • Service-
oriented programming simply defines reusable modules as "services" with advertised
interfaces.
• Microservice programming focuses on creating modules that do not store data internally, and
so are scalable and resilient in cloud deployment.
• Functional programming, technically, means that modules are written from functions, and
that these functions' outputs are derived only from their inputs. Designed for server less
computing, the definition of functional programming has since expanded to be largely
synonymous with microservices.
Defines a program as a set of objects or resources to which commands are sent. An object-
oriented language will define a data resource and send it to process commands. For example,
the procedural programmer might say "Print(object)" while the OOP programmer might say
"Tell Object to Print".
9|Page
2.3 Model-based programming.
The most common example of this is database query languages. In database programming,
units of code are associated with steps in database access and update or run when those steps
occur. The database and database access structure will determine the structure of the code.
Another example of a model-based structure is Reverse Polish Notation (RPN), a math-
problem structure that lends itself to efficient solving of complex expressions. Quantum
computing, just now emerging, is another example of model-based structured programming
that demands a specific model to organize steps, and the language simply provides it.
At the high level, structured programs consist of a structural hierarchy starting with the main
process and decomposing downward to lower levels as the logic dictates. These lower
structures are the modules of the program, and modules may contain both calls to other (lower-
level) modules and blocks representing structured condition/action combinations. All of this
can be combined into a single module or unit of code, or broken down into multiple modules,
resident in libraries.
Structured programs and modules typically have a header file or section that describes the
modules or libraries referenced and the structure of the parameters and module interface. In
some programming languages, the interface description is abstracted into a separate file, which
is then implemented by one or more other units of code.
10 | P a g e
• It encourages top-down implementation, which improves both readability and maintainability
of code.
• It promotes code reuse, since even internal modules can be extracted and made independent,
residents in libraries, described in directories and referenced by many other applications.
• It's widely agreed that development time and code quality are improved through structured
programming.
These advantages are normally seen as compelling, even decisive, and nearly all modern
software development employs structured programming.
Structured programming can also be applied incorrectly if the type of structure selected isn't
right for the task at hand. The best-known example is the solving of math problems. RPL is an
efficient way to state and solve a math problem because it eliminates the need to explicitly state
execution order and eliminates recursion in code. However, if that problem was to be posed in
structured programming procedural or object form, the resulting code would be much less
efficient than the RPL version.
Conclusion
Structured programming is a paradigm that aims to make programs easier to comprehend from
a reader’s point of view. It does this by line arising the flow of control through a program. In
which case, execution follows the writing order of the code. Structured programming caught
favour with programming
11 | P a g e
4.0 Overview of Main Programming Paradigm
There are four main programming paradigms which are imperative paradigm functional
The imperative, also called the procedural programming paradigm expresses computation by
fully specified and controlled manipulation of named data in a stepwise fashion. In other words,
data or values are initially stored in variables (memory locations), taken out of (read from)
memory, manipulated in ALU (arithmetic logic unit), and then stored back in the same or
different variables (memory locations). Finally, the values of variables are sent to the I/O
devices as output. The foundation of imperative languages is the stored program concept-based
computer hardware organization and architecture (von Neumann machine). The stored
program concept will be further explained in the next chapter. Typical imperative programming
languages include all assembly languages and earlier high-level languages like FORTRAN,
Advantage:
Disadvantage:
12 | P a g e
Examples of Imperative programming paradigm:
Average = sum / 5;
The program is written as a collection of classes and object which are meant for
communication. The smallest and basic entity is object and all kind of computation is
performed on the objects only. More emphasis is on data rather procedure. It can handle almost
Advantages:
Data security
Inheritance
Code reusability
13 | P a g e
Flexible and abstraction is also present
import java.io.*;
class GFG {
System.out.println("GfG!");
14 | P a g e
class Signup {
intuserid;
String name;
String emailid;
char sex;
long mob;
System.out.println("Welcome to
this.userid = 132;
this.name = "Radha";
this.emailid = "radha.89@gmail.com";
this.sex = 'F';
this.mob = 900558981;
15 | P a g e
4.4 Procedural programming paradigm –
difference in between procedural and imperative approach. It has the ability to reuse the code
and it was boon at that time when it was in use because of its reusability.
#include <iostream>
int main()
cin>> number;
Fact = fact * i;
16 | P a g e
cout<< "Factorial of " <<num<< " is: " << fact <<endl;
Return 0;
The functional, also called the applicative, programming paradigm expresses computation in
and simple to use. However, programmers find it difficult to switch because they are already
familiar with the functional programming. The main difference is that there is no concept of
memory locations in functional programming languages. Each function will take a number of
values as input (parameters) and produce a single return value (output of the function). The
return value cannot be stored for later use. It has to be used either as the final output or
defining functions and organizing the return values of one or more functions as the parameters
of another function. Functional programming languages are mainly based on the lambda
calculus.
Typical functional programming Languages include ML, SML, and Lisp/Scheme. Python and
C# support direct applications of lambda calculus and many functional programming features.
17 | P a g e
Erlang : developed by Joe Armstrong, Robert Virding
It can be termed as abstract model of computation. It would solve logical problems like puzzles,
series etc. In logic programming we have a knowledge base which we know before and along
with the question and knowledge base which is given to machine, it produces result.
In normal programming languages, such concept of knowledge base is not available but while
using the concept of artificial intelligence, machine learning we have some models like
In logical programming the main emphasize is on knowledge base and the problem. The
execution of the program is very much like proof of mathematical statement, e.g., Prolog sum
sumoftwonumber(integer, integer)
clauses
sum(0, 0).
sum(n, r):-
n1=n-1,
sum(n1, r1),
18 | P a g e
r=r1+n
This programming methodology is based on data and its movement. Program statements are
defined by data rather than hard-coding a series of steps. A database program is the heart of a
business information system and provides file creation, data entry, update, query and reporting
functions. There are several programming languages that are developed mostly for database
application. For example SQL. It is applied to streams of structured data, for filtering,
PersonID int,
LastNamevarchar (200),
FirstNamevarchar (200),
City varchar(200),
State varchar(200)
);
19 | P a g e
Conclusion
Paradigm is a set of basic principles, concepts, and methods for how a computation or algorithm
between some of these programming languages. This unit emphasizes the need to know which
Summary
In this unit, you learnt that the history of programming language right from the beginning till
present. Also, the programming paradigms were discussed. The four common program
paradigm and groups were discussed as well as their similarities and differences.
5. PROGRAMMING LANGUAGES
They are used to create programs that control the behaviour of a machine. A programming
algorithm. However, some authors restrict the term "programming language" to those
languages that can express all possible algorithms. Thus, Programming language is a set of
There are two ways to describe a language: by its syntax or by its semantics. The syntax of a
language is a set of rules that defines what strings of characters (sentence or statements)
belong to this language; the semantics of a language describe the meaning of a given statement.
Syntax is a set of rules that define how the commands have to be arranged to make
20 | P a g e
Grammar is a set of rules of using different punctuation, quotation marks, semicolons,
and other symbols to divide and clarify the syntax of a particular language.
Semantics is a set of meanings assigned to every command of the language and is used
Programming languages are tools used in developing software thus this module discusses the
is used to refresh and prepare the leaners towards the main topics. The first unit of the module
presents the fundamental of programing language which is the foundation. It also discusses the
Programming languages have been in active over 40 years ago thus, all languages have their
link to the earlier versions developed. Hence, the second unit presents discussions on
programs, the last unit of the module deliberates on structured and unstructured programming.
Programming Language can be grouped into three namely; Machine Languages, Assembly
Machine Language:
Machine language is a collection of binary digits or bits that the computer reads and interprets.
Machine language is the only language a computer is capable of understanding. Machine level
language is a language that supports the machine side of the programming or does not provide
human side of the programming. It consists of (binary) zeros and ones. Each instruction in a
program is represented by a numeric code, and numerical addresses are used throughout the
21 | P a g e
program to refer to memory locations in the computer’s memory. Microcode allows for the
expression of some of the more powerful machine level instructions in terms of a set of basic
machine instructions.
Assembly language:
Assembly language is easier to use than machine language. An assembler is useful for detecting
programming errors. Programmers do not have the absolute address of data items. Assembly
High level language is a language that supports the human and the application sides of the
necessary to accomplish a task. A line in a high-level language can execute powerful operations
Consequently more programming is now done in high level languages. Examples of high-level
Programming Language is indeed an essential part of today’s tech world. There are lots of
programming languages which have their own syntax, sematic and features. This unit presents
Paradigm in programming language is the set of basic principles, concept and methods in which
22 | P a g e
1883: The Beginning …!!
In the early days, Charles Babbage had made the device, but he was confused about how to
give instructions to the machine, and then Ada Lovelace wrote the instructions for the analytical
engine.
The device was made by Charles Babbage and the code was written by Ada Lovelace for
computing Bernoulli’s number. That was the first time in history that the capability of computer
It is a type of low-level language. It mainly consists of instructions (kind of symbols) that only
machines could understand. In today’s time, assembly language is used in real-time programs
such as simulation flight navigation systems and medical equipment e.g. – Fly-by-wire (FBW)
1954: FORTRAN
FORTRAN was developed in 1954 by John Backus and IBM. It was designed for numeric
computation and scientific computing. Software for NASA probes voyager-1 (space probe)
and voyager-2 (space probe) was originally written in FORTRAN. It is first high level
language. It was developed using the first compiler and it is Machine Independent Language.
In 1958: FORTRAN 2nd version was developed which introduces subroutines, functions,
loops and primitive for loop. It started as a Project and later renamed as ALGOL58.
1958 ALGOL: ALGOL stands for ALGOrithmic Language. The initial phase of the most
popular programming languages of C, C++, and JAVA. It was also the first language
implementing the nested function and has a simple syntax than FORTRAN. The first
programming language to have a code block like “begin” that indicates that your program has
23 | P a g e
started and “end” means you have ended your code. ALGOL (ALGOrithmic Language) was a
It was Considered to be the first second generation Computer Language and Machine
Independent language. It introduced concepts like: Block structure code (Marked by BEGIN
and END), Scope of variables (Scope of local variables inside blocks), BNF (Backus Naur
Form), Notation for defining syntax, Dynamic Arrays, Reserved words and IF THEN ELSE,
1959 COBOL: It stands for COmmon Business-Oriented Language. In 1997, 80% of the
world’s business ran on COBOL. The US internal revenue service scrambled its path to
COBOL-based IMF (individual master file) in order to pay the tens of millions of payments
mandated by the coronavirus aid, relief, and economic security. COBOL was rated in May
teaching language in 1963 by John George Kemeny and Thomas Eugene Kurtz of Dartmouth
College.
Intended to make it easy to learn programming. In 1991 Microsoft released Visual Basic, an
updated version of Basic but the first microcomputer version of Basic was co-written by Bill
Gates, Paul Allen, and Monte Davidoff for their newly-formed company, Microsoft.
1970 PASCAL: is named after a French religious fanatic and mathematician Blaise Pascal. It
was created in 1970 with the intension of replacing BASIC for teaching language. It was
independent intermediate pcode. The compiler for Pascal was written in Pascal.
1972 C: is a general-purpose, procedural programming language and the most popular till now.
All the previous codes (like operating system and kernel) written in assembly language gets
24 | P a g e
replaced by the C language. C can be used to implementing operating system, embedded
system, and on the website using the Common Gateway Interface (CGI). C is the mother of
almost all higher-level programming languages like C#, D, Go, Java, JavaScript, Limbo, LPC,
The table 1: below listed some popular programming languages among the programmers.
language.
applications.
language.
25 | P a g e
scientists and analysts. A scripting language
independent language.
Thompson
language.
26 | P a g e
5.3 CHARACTERISTICS OF GOOD PROGRAMMING LANGUAGE
There are various factors why the programmers prefer one language over the other.
A Programming language provides both a conceptual framework for Algorithm planning and
means of expressing them. It should provide a clear, simple and unified set of concepts that can
be used as primitives in developing algorithms. It should be simple and regular as well as have
minimum number of different concepts, and rules for their combination. This attribute is called
conceptual integrity.
Orthogonality:
Orthogonality is one of the most important features of PL. It is the property that says "
Changing A does not change B". In real world, radio is an example of an orthogonal system.
For instance, changing a station in a radio does not change the volume and vice versa. When
the features of a language are orthogonal, language is easier to learn and programs are easier
There is always found that a substantial gap remaining between the abstract data structure and
operations that characterize the solution to a problem and their particular data structure and
Programming Environment:
27 | P a g e
Ease of program verification/Reusability:
checked by various testing technique like Formal verification method Desk checking Input
output test checking. We verify the program by many more techniques. A language that makes
program verification difficult may be far more troublesome to use. Simplicity of semantic and
Portability of programs:
Programming language should be portable means it should be easy to transfer a program from
which they are developed to the other computer. A program whose definition is independent
of features of a Particular machine forms can only support Portability. Example: Ada,
structures, data types and data structures, syntax design, support for abstraction,
expressiveness, type equivalence, and strong versus weak type checking, exception handling,
and restricted aliasing. While the performance of a program, including reliability, readability,
writability, reusability, and efficiency, is largely determined by the way the programmer writes
the algorithm and selects the data structures, as well as other implementation details. However,
the features of the programming language are vital in supporting and enforcing programmers
in using proper language mechanisms in implementing the algorithms and data structures.
28 | P a g e
Conclusion
In this unit, you have been introduced to the fundamental of programming language.
machine code and readable by the programmers. There are rules guiding the construction of
language. It has syntax, semantic and grammar rules. The features of the programming
language are vital in supporting and enforcing programmers in using proper language
Summary
In this unit, you learnt that a programming language is a set of symbols, grammars and rules
with the help of which one is able to translate algorithms to programs that will be executed by
the computer.
There are three categories of programming language which are machine language, assemble
language and high level language. Clarity, simplicity and unity, orthogonality, support for
Many languages provide features that can be extremely useful when used properly but waste a
large amount of time when used improperly. Algorithms behave similarly, so the habit of
making correct decisions with a programming language can carry over to making correct
29 | P a g e
2. To improve your use of your existing programming language
By understanding exactly how the features in a programming language are implemented, you
learn how to effectively use them. When you know how the language components such as
When thinking about a set of data/program structures to solve a problem, it's typical to only
think about the structures that are immediately available within the programming language
you're working with. By knowing the constructs of other programming languages, you can find
one that fits your scenario better and possibly implement it yourself.
Some languages are better suited than others for particular projects. You can reduce effort by
Though you may not be making the next C or Java programming language, it's actually fairly
30 | P a g e
DATA TYPES AND STRUCTURES
effectively its information can be stored in the computer. Each programming language contains
constructs and mechanisms for structuring data. A data structure is a way of organizing
information, so that it is easier to use. Instead of just the simple sequences of bits in the physical
machine, a high level language provides complex structured data which easily lends itself to
describe the structure of the problems that are to be solved. Data structures are often optimized
for certain operations. Finding the best data structure when solving a problem is an important
part of programming. Programs that use the right data structure is easier to write, and work
better.
A data type defines as a collection of data values and a set of predefined operations on those
values.
the ease with which they can perform this task is how well the data types available in the
language being used match the objects in the real world of the problem being addressed.
Therefore, it is crucial that a language supports an appropriate collection of data types and
structures.
A data type is the most basic and the most common classification of data; it is an attribute of
data which tells the compiler (or interpreter) how the programmer intends to use the data.
Basically data type is a type of information transmitted between the programmer and the
compiler where the programmer informs the compiler about what type of data is to be stored
and also tells how much space it requires in the memory. Data type can be grouped into three
namely;
31 | P a g e
• Scalar: basic building block (boolean, integer, float, char etc.)
• Composite: any data type (struct, array, string etc.) composed of scalars or composite types
• Abstract: data type that is defined by its behaviour (tuple, set, stack, queue, graph etc).
If we consider a composite type, such as a ‘string’, it describes a data structure which contains
a sequence of char scalars (characters), and as such is referred to as being a ‘composite’ type.
Whereas the underlying implementation of the string composite type is typically implemented
using an array data structure. An abstract data type (ADT) describes the expected behaviour
associated with a concrete data structure. For example, a ‘list’ is an abstract data type which
represents a countable number of ordered values, but again the implementation of such a data
type could be implemented using a variety of different data structures, one being a ‘linked list’.
#include <iostream.h>
void main()
{ int a; a = 5;
float b; b = 5.0;
d = "example";
32 | P a g e
As seen from the theory explained above we come to know that in the above code, the variable
‘a’ is of data type integer which is denoted by int a. So the variable ‘a’ will be used as an integer
type variable throughout the process of the code. And, in the same way, the variables ‘b’, ‘c’and
‘d’ are of type float, character and string respectively. And all these are kinds of data types.
All data in computers based on digital electronics is represented as bits (alternatives 0 and 1)
on the lowest level. The smallest addressable unit of data is usually a group of bits called a byte
(usually an octet, which is 8 bits). The unit processed by machine code instructions is called a
word (as of 2011, typically 32 or 64 bits). Most instructions interpret the word as a binary
number, such that a 32-bit word can represent unsigned integer values from 0 to or signed
integer values from to. Because of two's complement, the machine language and machine
doesn't need to distinguish between these unsigned and signed data types for the most part.
There is a specific set of arithmetic instructions that use a different interpretation of the bits in
word as a floating-point number. Machine data types need to be exposed or made available in
The C programming language, for instance, supplies integer types of various widths, such as
short and long. If a corresponding native type does not exist on the target platform, the compiler
will break them down into code using types that do exist. For instance, if a 32-bit integer is
requested on a 16-bit platform, the compiler will tacitly treat it as an array of two 16 bit integers.
Several languages allow binary and hexadecimal literals, for convenient manipulation of
machine data.
In higher level programming, machine data types are often hidden or abstracted as an
implementation detail that would render code less portable if exposed. For instance, a generic
33 | P a g e
numeric type might be supplied instead of integers of some specific bit-width. The following
The Boolean type represents the values true and false. Although only two values are possible,
they are rarely implemented as a single binary digit for efficiency reasons. Many programming
languages do not have an explicit boolean type, instead interpreting (for instance) 0 as false
• The integer data types, or "whole numbers". May be subtyped according to their ability to
contain negative values (e.g. unsigned in C and C++). May also have a small number of
predefined subtypes (such as short and long in C/C++); or allow users to freely define
• Floating point data types, sometimes misleadingly called reals, contain fractional values.
They usually have predefined limits on both their maximum values and their precision. These
• Fixed point data types are convenient for representing monetary values. They are often
• Bignum or arbitrary precision numeric types lack predefined limits. They are not primitive
34 | P a g e
Composite types are derived from more than one primitive type and can be done in so many
ways called data structures. Composing a primitive type into a compound type generally
• An array stores a number of elements of the same type in a specific order. They are accessed
using an integer to specify which element is required (although the elements may be of almost
• Record (also called tuple or struct) Records are among the simplest data structures. A record
is a value that contains other values, typically in fixed number and sequence and typically
indexed by names. The elements of records are usually called fields or members.
• Union. A union type definition will specify which of a number of permitted primitive types
may be stored in its instances, e.g. "float or long integer". Contrast with a record, which could
be defined to contain a float and an integer; whereas, in a union, there is only one value at a
time.
• A tagged union (also called a variant, variant record, discriminated union, or disjoint union)
contains an additional field indicating its current type, for enhanced type safety.
• A set is an abstract data structure that can store certain values, without any particular order,
and no repeated values. Values themselves are not retrieved from sets, rather one tests a value
• An object contains a number of data fields, like a record, and also a number of program code
fragments for accessing or modifying them. Data structures not containing code, like those
35 | P a g e
This has values which are different from each other, and which can be compared and assigned,
but which do not necessarily have any particular concrete representation in the computer's
memory; compilers and interpreters can represent them arbitrarily. For example, the four suits
in a deck of playing cards may be four enumerators named CLUB, DIAMOND, HEART,
SPADE, belonging to an enumerated type named suit. If a variable V is declared having suit
as its data type, one can assign any of those four values to it. Some implementations allow
programmers to assign integer values to the enumeration values, or even treat them as type-
equivalent to integers.
• Alphanumeric character. A letter of the alphabet, digit, blank space, punctuation mark, etc.
• Alphanumeric strings, a sequence of characters. They are typically used to represent words
and text.
Character and string types can store sequences of characters from a character set such as ASCII.
Since most character sets include the digits, it is possible to have a numeric string, such as
"1234".
However, many languages would still treat these as belonging to a different type to the numeric
value 1234. Character and string types can have different subtypes according to the required
character "width". The original 7-bit wide ASCII was found to be limited and superseded by 8
Any type that does not specify an implementation is an abstract data type. For instance, a stack
36 | P a g e
containing multiple values), or as a linked list (a set of non-contiguous memory blocks linked
by pointers). Abstract types can be handled by code that does not know or "care" what
underlying types are contained in them. Arrays and records can also contain underlying types,
but are considered concrete because they specify how their contents or elements are laid out in
memory.
In computer science, an abstract data type (ADT) is a mathematical model for a certain class
of data structures that have similar behavior; or for certain data types of one or more
programming languages that have similar semantics. An abstract data type is defined indirectly,
only by the operations that may be performed on it and by mathematical constraints on the
effects (and possibly cost) of those operations. For example, an abstract stack could be defined
by three operations:
• Pop, that extracts an item from it (with the constraint that each pop always returns the most
recently pushed item that has not been popped yet), and
• Peek, that allows data on top of the structure to be examined without removal.
Abstract data types are purely theoretical entities, used (among other things) to simplify the
description of abstract algorithms, to classify and evaluate data structures, and to formally
describe the type systems of programming languages. Some common ADTs, which have
proved useful in a great variety of programming applications, are – Container, Deque, List,
Map, Multimap, Multiset Priority queue, Queue, Set, Stack, Tree, and Graph.
37 | P a g e
For convenience, high-level languages may supply ready-made "real world" data types, for
instance times, dates and monetary values and memory, even where the language allows them
A data structure is a collection of data type ‘values’ which are stored and organized in such a
way that it allows for efficient access and modification. In some cases, a data structure can
Data structures perform some special operations like insertion, deletion and traversal. For
example, you have to store data for many employees where each employee has his name,
employee id and a mobile number. So this kind of data requires complex data management,
which means it requires data structure comprised of multiple primitive data types. So data
structures are one of the most important aspects when implementing coding concepts in real-
world applications. Data structures can be grouped into four forms: Linear, tree, hash, graphs
6.2.1 Array
An array is a finite group of data, which is allocated contiguous (i.e. sharing a common border)
memory locations, and each element within the array is accessed via an index key (typically
numerical, and zero based). The name assigned to an array is typically a pointer to the first item
in the array. Meaning that given an array identifier of arr which was assigned the value ["a",
"b", "c"], in order to access the "b" element you would use the index 1 to lookup the value:
arr[1].
Arrays are traditionally ‘finite’ in size, meaning you define their length/size (i.e. memory
capacity) up front, but there is a concept known as ‘dynamic arrays’ (and of which you’re likely
38 | P a g e
more familiar with when dealing with certain high-level programming languages) which
supports the growing (or resizing) of an array to allow for more elements to be added to it.
In order to resize an array you first need to allocate a new slot of memory (in order to copy the
original array element values over to), and because this type of operation is quite ‘expensive’
(in terms of computation and performance) you need to be sure you increase the memory
capacity just the right amount (typically double the original size) to allow for more elements to
be added at a later time without causing the CPU to have to resize the array over and over again
unnecessarily.
One consideration that needs to be given is that you don’t want the resized memory space to
When dealing with modifying arrays you also need to be careful because this requires
significant overhead due to the way arrays are allocated memory slots. If you imagine you have
an array and you want to remove an element from the middle of the array, try to think about
that in terms of memory allocation: an array needs its indexes to be contiguous, and so we have
to re-allocate a new chunk of memory and copy over the elements that were placed around the
deleted element.
These types of operations, when done at scale, are the foundation behind reasons to have a
good understanding of how data structures are implemented. The reason being, when you’re
writing an algorithm you will hopefully be able to recognize when you’re about to do
something (let’s say modify an array many times within a loop construct) that could ultimately
6.2.2 Tree
The concept of a ‘tree’ in its simplest terms is to represent a hierarchical tree structure, with a
root value and subtrees of children (with a parent node), represented as a set of linked nodes.
39 | P a g e
A tree contains “nodes” (a node has a value associated with it) and each node is connected by
a line called an “edge”. These lines represent the relationship between the nodes. The top level
node is known as the “root” and a node with no children is a “leaf”. If a node is connected to
other nodes, then the proceeding node is referred to as the “parent”, and nodes following it are
“child” nodes. There are various incarnations of the basic tree structure, each with their own
unique characteristics and performance considerations: Binary Tree, Binary Search Tree, Red-
Black Tree, B-tree, Weight-balanced Tree, Heap, and Abstract Syntax Tree.
A hash table is a data structure which is capable of maping ‘keys’ to ‘values’, and you’ll
typically find this is abstracted and enhanced with additional behaviours by many high-level
programming languages such that they behave like an ‘associative array’ abstract data type. In
Python it’s called a ‘dictionary’ and has the following structure (on top of which are functions
such as del, get and pop etc that can manipulate the underlying data): table = {'name': 'foobar',
'number': 123}
The keys for the hash table are determined by way of a hash function but implementors need
to be mindful of hash ‘collisions’ which can occur if the hash function isn’t able to create a
distinct or unique key for the table. The better the hash generation, the more distributed the
keys will be, and thus less likely to collide. Also the size of the underlying array data structure
needs to accommodate the type of hash function used for the key generation.
For example, if using modular arithmetic you might find the array needs to be sized to a prime
number.
40 | P a g e
6.2.4 Graph
A graph is an abstract data type intended to guide the implementation of a data structure
following the principles of graph theory. The data structure itself is non-linear and it consists
of:
The figure 22 demonstrates a ‘directed’ graph (notice the edges have arrows indicating the
Note: an ‘undirected’ graph simply has no arrow heads, so the flow between nodes can go in
either direction.
Some graphs are ‘weighted’ which means each ‘edge’ has a numerical attribute assigned to
them.
These weights can indicate a stronger preference for a particular flow of direction. Graphs are
used for representing networks (both real and electronic), such as streets on a map or friends
on Facebook.
Data Type is the kind or form of a variable which is being used throughout the program. It
defines that the particular variable will assign the values of the given data type only
Data Structure is the collection of different kinds of data. That entire data can be represented
41 | P a g e
Can hold values and not data, so it is data less
Can hold different kind and types of data within one single object
The data is assigned to the data structure object using some set of algorithms and operations
Time complexity comes into play when working with data structures
Conclusion
This unit discussed the data types and data structure. Data types of a language was described
as a large part of what determines that language’s style and usefulness. Along with control
structures, they form the heart of a language. While data structures determine the way in which
information can be stored in computer and used. The unit highlighted how data type is different
from data structure. Data structure can be grouped into the following forms which are Array,
Linked List, Tree, Hash Table, Graph, Stack and Queue. This unit also, presented a comparison
Summary
The unit discussed extensively on different data types such as primitive data types, composite
data types, enumerated data types, abstract data types and utility data types. Also, justice was
done in describing different types of data structure such as array, linked list, tree, hash table,
graph, stack and queue. The unit presented the differences between data type and data structure.
42 | P a g e
7.0 LANGUAGE PROCESSING
7.1 Introduction
Machine languages are designed on the basis of speed of execution, cost of realization, and
flexibility in building new software layers upon them. On the other hand, programming
languages often are designed on the basis of the ease and reliability of programming. A basic
problem, then, is how a higher level language eventually can be executed on a computer whose
machine language is very different and at a much lower level. Thus, this unit focus on
7.2 Translation
In this solution, programs written in a high-level language are translated into an equivalent
machine-language version before being executed. This translation is often performed in several
steps. Program modules might first be separately translated into relocatable machine code;
modules of relocatable code are linked together into a single relocatable unit; finally, the entire
program is loaded into the computer’s memory as executable machine code. The translators
used in each of these steps have specialized names: compiler, linker (or linkage editor), and
loader, respectively.
In some cases, the machine on which the translation is performed (the host machine) is different
from the machine that is to run the translated code (the target machine). This kind of translation
is called cross-translation. Cross translators offer the only viable solution when the target
machine is a special purpose processor rather than a general-purpose one that can support a
translator.
43 | P a g e
7.3 Concept of Interpretative Language
Pure interpretation and pure translation are two ends of a continuous spectrum. In practice,
many languages are implemented by a combination of the two techniques. A program may be
translated into an intermediate code that is then interpreted. The intermediate code might be
simply a formatted representation of the original program, with irrelevant information (e.g.,
comments and spaces) removed and the components of each statement stored in a fixed format
to simplify the subsequent decoding of instructions. In this case, the solution is basically
interpretive.
Alternatively, the intermediate code might be the (low-level) machine code for a virtual
machine that is to be later interpreted by software. This solution, which relies more heavily on
translation, can be adopted for generating portable code, that is, code that is more easily,
transferable to different machines than machine language code. For example, for portability
purposes, one of the best known initial implementations of a Pascal compiler was written in
Pascal and generated an intermediate code, called Pcode. The availability of a portable
implementation of the language contributed to the rapid diffusion of Pascal in many educational
environments. More recently, with the widespread use of Internet, code portability became a
primary concern for network application developers. A number of language efforts have
recently been undertaken with the goal of supporting code mobility over a network. Language
Java is perhaps the best known and most promising example. Java is first translated to an
intermediate code, called Java bytecode, which is interpreted in the client machine.
decoding process to determine the operations to be executed and their operands. In most cases,
this process is identical each time the statement is encountered. Consequently, if the statement
appears in a frequently-executed part of a program (e.g., an inner loop), the speed of execution
44 | P a g e
is strongly affected by this decoding process. On the other hand, pure translation generates
machine code for each high-level statement. In so doing, the translator decodes each high-level
Frequently-used parts are then decoded many times in their machine language representation;
because this is done efficiently by hardware, pure translation can save processing time over
pure interpretation. On the other hand, pure interpretation may save storage. In pure translation,
each high-level language statement may expand into tens or hundreds of machine instructions.
In a purely interpretive solution, high-level statements are left in the original form and the
instructions necessary to execute them are stored in a subprogram of the interpreter. The storage
saving is evident if the program is large and uses most of the language's statements. On the
other hand, if all of the interpreter's subprograms are kept in main memory during execution,
the interpreter may waste space for small programs that use only a few of the language's
statements.
Compilers and interpreters differ in the way they can report on run-time errors. Typically, with
compilation, any reference to the source code is lost in the generated object code. If an error is
generated at run-time, it may be impossible to relate it to the source language construct being
executed. This is why run-time error messages are often obscure and almost meaningless to the
programmer. On the opposite, the interpreter processes source statements, and can relate a
runtime error to the source statement being executed. For these reasons, certain programming
environments contain both an interpreter and a compiler for a given programming language.
The interpreter is used while the program is being developed, due to its improved diagnostic
facilities.
The compiler is then used to generate efficient code, after the program has been fully validated.
45 | P a g e
Macro processing is a special kind of translation that may occur as the first step in the
translation of a program. A macro is a named source text fragment, called the macro body.
Through macro processing, macro names in a text are replaced by the corresponding bodies. In
C, one can write macros, handled by a preprocessor, which generates source C code through
macro expansion. For example, one can use a macro to provide a symbolic name for a constant
value, as in this fragment: #define upper_limit 100 . . . sum = 0; for (index = 0; index <
Programs deal with entities, such as variables, routines, statements, and so on. Program entities
have certain properties called attributes. For example, a variable has a name, a type, a storage
area where its value is stored; a routine has a name, formal parameters of a certain type, certain
specified before an entity is elaborated. Specifying the exact nature of an attribute is known as
binding. For each entity, attribute information is contained in a repository called a descriptor.
Programming languages differ in the number of entities with which they can deal, in the number
of attributes to be bound to entities, in the time at which such bindings occur (binding time),
and in the stability of the binding (i.e., whether an established binding is fixed or modifiable).
A binding that cannot be modified is called static. A modifiable binding is called dynamic.
Bindings can take place at language design time, language implementation time, compile time,
load time, link time, or run time. Some attributes may be bound at language definition time,
others at program translation time (or compile time), and others at program execution time (or
• Language definition time binding. In most languages (including FORTRAN, Ada, C, and
46 | P a g e
C++) the type "integer" is bound at language definition time to its well-known mathematical
counterpart, i.e., to a set of algebraic operations that produce and manipulate integers;
and C++) a set of values is bound to the integer type at language implementation time. That is,
the language definition states that type "integer" must be supported and the language
• Compile time (or translation time) binding. Pascal provides a predefined definition of type
integer, but allows the programmer to redefine it. Thus type integer is bound a representation
at language implementation time, but the binding can be modified at translation time.
• Execution time (or run time) binding. In most programming languages variables are bound to
a value at execution time, and the binding can be modified repeatedly during execution.
• In the first two examples, the binding is established before run time and cannot be changed
thereafter. This kind of binding regime is often called static. The term static denotes both the
binding time (which occurs before the program is executed) and the stability (the binding is
fixed). Conversely, a binding established at run time is usually modifiable during execution.
The fourth example illustrates this case. This kind of binding regime is often called dynamic.
There are cases, however, where the binding is established at run time, and cannot be changed
after being established. An example is a language providing (read only) constant variables that
In the first two examples, the binding is established before run time and cannot be changed
thereafter. This kind of binding regime is often called static. The term static denotes both the
47 | P a g e
binding time (which occurs before the program is executed) and the stability (the binding is
fixed).
Conversely, a binding established at run time is usually modifiable during execution. The
fourth example illustrates this case. This kind of binding regime is often called dynamic. There
are cases, however, where the binding is established at run time, and cannot be changed after
being established. An example is a language providing (read only) constant variables that are
Conclusion
In this unit, you have been introduced to the how language processing can be implemented
through interpretation and translation. Also, binding was described as the association of
attributes with program entities. Knowledge of the binding times of attributes to entities is
dynamic.
Declarations, either explicit or implicit, provide a means of specifying the static binding of
variables to types. In general, dynamic binding allows greater flexibility but at the expense of
Summary
translation.
For a programming language to be meaningful there is need or a translator which accepts other
languages and execute them directly or transform them into form that is suitable for execution.
A translation involves two processes which are interpretation and compilation. Interpreter is a
translator that execute program directly while compiler is a translator that produces an
48 | P a g e
equivalent program in a form suitable for execution. Also the unit explain the concept of
variable and its type or value, or between an operation and a symbol. The time at which a
binding takes place is called binding time. It worth to know that complete understanding of the
binding times for the attributes of program entities is a prerequisite for understanding the
49 | P a g e
REFERENCES/FURTHER READING
2. https://www.geeksforgeeks.org/the-evolution-of-programming-
languages
3. https://deepsource.io/glossary/structured-programming
4. https://searchsoftwarequality.techtarget.com/definition/structur
ed-programming-modular programming
ISBN:0521780985
Programming Languages
50 | P a g e
10. Ghezzi & Jazayeri (1996.) Programming language concepts—
Programming Languages
12. https://www.integralist.co.uk/posts/data-types-and-data-
structures/https://www.geeksforgeeks.org/
13. https://www.sctevtservices.nic.in/docs/website/pdf/140338.pdf
14. https://www.scribd.com/document/70893872
15. http://www.tutorialsspace.com/Programming-Languages
16. https://www.geeksforgeeks.org/the-evolution-of-programming-
languages
17. https://blog.stackpath.com/runtime/
18. http://net-informations.com/python/iq/checking.htm
51 | P a g e