0% found this document useful (0 votes)
22 views

CSC 4405 Survey of Programming Languages Lecture 2

Uploaded by

Nuhu Adamu
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
22 views

CSC 4405 Survey of Programming Languages Lecture 2

Uploaded by

Nuhu Adamu
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 6

YOBE STATE UNIVERSITY, DAMATURU

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.

Overview of the most important programming paradigms

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?

Imperative programming: The classic programming paradigm


Among programming paradigms for software development, imperative programming is the classic
variant. The first programming languages – and correspondingly, the first computer programs –
were based entirely on this classic approach, which provides a controlled sequence of specific
commands (the name comes from the Latin imperare meaning “command”) or instructions. For
example, this programming paradigm is the basis for early classics like Pascal and C, as well as all
assembly languages. Imperative programming focuses in part on working as closely as possible with
the system. The resulting program code is therefore easy to understand but also very extensive.

Within the imperative programming paradigm, there are three important subordinate methods for
writing and structuring software code: structured, procedural, Object Oriented and modular
programming.

The key concepts of imperative programming languages are


i. Variables
ii. Commands
iii. Procedures
iv. Data abstraction.

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

Modular programming is categorized as a subordinate form of the imperative programming


paradigm. It is essentially very similar to the procedural method and applies this programming style
to the requirements and demands of larger and more comprehensive software projects. It involves
selectively breaking down the source code into logical, independent sub-blocks to ensure greater
clarity and to simplify the debugging process. The sub-blocks, known as modules, can be tested
individually before they are subsequently linked together to create a collective application.

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.

Declarative programming: paradigm of the recent past

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.

Comparison of programming paradigms: imperative and declarative programming

Imperative programming paradigm Declarative programming paradigm


“How?” “What?”
Classic New trend
A program based on this paradigm is A program based on this paradigm is made up of
made up of a series of instructions that instructions for how the program should deal
tell the computer what it should with an input. Calculations are performed by
calculate/do and in what order. manipulation of values, with the procedure
controlled by the process of recursion.
The name comes from “imperare”, the The name comes from “declarare”, the Latin
Latin word for “command”. word for “describe”.
The desired solution path is specified The desired result is specified.
Typical programming languages Typical programming languages include Lisp,
include C, Pascal, Fortran, ALGOL, and ML, Haskell, F#, Prolog, and Oz
all assembly languages.

Some authors refer to scripting languages as a separate category of programming languages.


However, languages in this category are bound together more by their implementation method,
partial or full interpretation, than by a common language design. The languages that are typically

5
called scripting languages, among them Perl, JavaScript (Flanagan, 2011), and Ruby, are imperative
languages in every sense.

However, we do not consider languages that support object-oriented programming to form a


separate category of languages. We have described how the most popular languages that support

object-oriented programming grew out of imperative languages. Although the object-oriented


software development paradigm differs significantly from the procedure-oriented paradigm usually
used with imperative languages, the extensions to an imperative language required to support
object-oriented programming are not intensive. For example, the expressions, assignment
statements, and control statements of C and Java are nearly identical. (On the other hand, the
arrays, subprograms, and semantics of Java are very different from those of C.) Similar statements
can be made for functional languages that support object-oriented programming.

Assignment No.1

Discuss on the on the history of programming language evolution from 1960s till date.

Assignment N0.2

Describe six types of programming paradigms stating the following clearly:

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.

You might also like