CSC 4405 Survey of Programming Languages Lecture 2
CSC 4405 Survey of Programming Languages Lecture 2
FACULTY OF SCIENCE
DEPARTEMNT OF COMPUTER SCIENCE
PART TWO
Overview of programming Paradigms:
CSC4405:
SURVEY OF PLs
Programming paradigms are the fundamental principles used when developing software. They are
best described as fundamentally different programming styles, which in turn result in differently
structured software code.
When programs are developed to solve real-life problems like inventory management, payroll
processing, student admissions, examination result processing, etc. they tend to be huge and
complex. The approach to analyzing such complex problems, planning for software development
and controlling the development process is called programming methodology. New software
development methodologies (e.g. object Oriented Software Development) led to new paradigms in
programming and by extension, to new programming languages. A programming paradigm is a
pattern of problem-solving thought that underlies a particular genre of programs and languages.
Also a programming paradigm is the concept by which the methodology of a programming language
adheres to.
The classic concept is imperative programming, where the source code clearly defines which steps
a program has to complete and in what order. Sub-types include procedural and object-oriented
programming. On the other hand, the declarative programming principle involves describing only
what software should do (i.e. only the result and not the individual steps). Sub-types include
functional programming and logic programming. How do the two programming paradigms differ
from one another?
Within the imperative programming paradigm, there are three important subordinate methods for
writing and structuring software code: structured, procedural, Object Oriented and modular
programming.
1. Structured programming
The structured programming method is a simplified form of imperative programming. The crucial
difference from the basic principle is that instead of absolute jump commands (instructions that
lead to processing continuing at another point instead of the next command), this software
programming paradigm makes use of control loops and structures. An example is the use of
“do…while”, which executes an instruction automatically for as long as a particular condition is true
(at least once).
2. Procedural programming
The procedural programming paradigm extends the imperative approach with the possibility of
dividing algorithms into more manageable sections. Depending on the programming language,
2
these are referred to as sub-programs, routines, or functions. The purpose of this division is to make
the programming code clearer and to prevent unnecessary code repetitions. Because of the
abstraction of algorithms, the procedural software paradigm represents a crucial step from simple
assembly languages towards more complex high-level languages.
3. Modular programming
4. Object Oriented
In object-oriented programming, OOP, a program code is organized into objects that contain state
that is only modified by the code that is part of the object. Most object-oriented languages are also
imperative languages to some extent. Examples of these languages include: Java, C++, Python,
Smalltalk, C# and a host of others. The key concepts of OOP are
i. Objects
ii. Classes
iii. Subclasses
iv. Inheritance
v. Inclusion polymorphism.
In parallel to the continuous ongoing development of hardware and software, the declarative
method developed as an alternative paradigm for code programming. The fundamental principle of
declarative programming is that it describes the desired end result. Thus, it is primarily about the
3
“what” – the result – rather than the “how” – the steps towards the solution – as is the case with
imperative programming. As a consequence, because of the high level of abstraction, the code
generated by declarative programming is much more difficult to understand. At the same time, it is
short and precise.
There are much bigger differences between subordinate forms of the declarative programming
paradigm than there are between those of the imperative approach. In addition, they are not always
so precisely defined or categorized. The two most important methods in the declarative
programming paradigm are functional and logic programming.
5. Functional programming
Functions exist in every higher-level programming language. However, the functional approach in
software development deals with functions in a very particular way.
A functionally programmed program is made up of a string of function calls, where each program
section can be understood as a function. In functional programming, the functions can take on
different forms. For example, they can be linked to one another like data or be used in the form of
parameters. In addition, they can subsequently be used as function results. Conversely, the
paradigm leads to there being no independent assignment of values.
This subsidiary form of declarative programming is very important for computer science in general
– and at the same time can be used for a wide range of specific purposes. The special handling of
functions enables programmers using the functional method to create and use extensive calculation
rules made up of functions.
6. Logic programming
The logic programming method, also known as predicate programming, is based on mathematical
logic. Instead of a sequence of instructions, software programmed using this method contains a set
of principles, which can be understood as a collection of facts and assumptions. All inquiries to the
program are processed, with the interpreter applying these principles and previously defined rules
to them in order to obtain the desired result.
4
The key concepts of logic programming are therefore:
i. Assertions
ii. Horn clauses
iii. Relations
Prolog is an example of a programming language that follows the Logic paradigm. PROLOG's
primitive values are numbers and atoms. Atoms can be compared with one another, but have no
other properties. They are used to represent real-world objects that are primitive.
5
called scripting languages, among them Perl, JavaScript (Flanagan, 2011), and Ruby, are imperative
languages in every sense.
Assignment No.1
Discuss on the on the history of programming language evolution from 1960s till date.
Assignment N0.2
a. Key concepts
b. Advantages
c. Disadvantages
d. Examples of at least 2 programming languages in each paradigm
e. State whether Scripting Languages are categories of programming paradigms or they are just
part of other paradigms. Support your answer with proof.