Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
0% found this document useful (0 votes)
14 views

ICT316_SWE316_Introduction to Programming LectNotes Nov2024

Lecture Notes in programming

Uploaded by

Eugene Mbah Tebo
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
14 views

ICT316_SWE316_Introduction to Programming LectNotes Nov2024

Lecture Notes in programming

Uploaded by

Eugene Mbah Tebo
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 19

ICT316/SWE316 : Introduction to Programming , Lecture Notes Part 1

Concept of Programming Language

Programming languages are tools used in developing software thus the concept of
programming language. This discussion on the concept of programming language is used
to refresh and prepare the us towards the main topics.
The fundamental of programing language which is the foundation is discussed , also with
the categories of programming language as well as the attribute of good programming
language.

Programming languages have been in active over 40 years ago thus, all languages have
their link to the earlier versions developed.

A language that is acceptable to a computer system is called a computer language or


programming language and the process of creating a sequence of instructions in such a
language is called programming or coding.

A programming language is a language designed to communicate instructions to a


computer.
They are used to create programs that control the behavior of a machine.

A programming language is a notation for writing programs, which are specifications of a


computation or 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 commands, strings or characters readable by programmers but easily
translatable to machine code.

It has syntax, grammar, and semantics.

• Syntax is a set of rules that define how the commands have to be arranged to make
sense and to be correctly translatable to the machine code.

• 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
to properly translate the program to machine code.

A program is a set of instructions, written to perform a specific task by the computer. A set of
large programs is called software. To develop software, one must have knowledge of a
programming language.

Before moving on to any programming language, it is important to know about the various
types of languages used by the computer.

Let us first know what the basic requirements of the programmers are & what difficulties they
faced while programming in that language.

Copyright @ Eugene Tebo November 2024


1
ICT316/SWE316 : Introduction to Programming , Lecture Notes Part 1

COMPUTER LANGUAGES

Languages are a means of communication. Normally people interact with each other
through a language. On the same pattern, communication with computers is carried out
through a language. This language is understood both by the user and the machine. Just as
every language like English, Hindi has its own grammatical rules; every computer language
is also bounded by rules known as syntax of that language. The user is bound by that syntax
while communicating with the computer system.

Computer languages are broadly classified as:

➢ Low Level Language: The term low level highlights the fact that it is closer to a language
which the machine understands.

The low level languages are classified as:

• Machine Language: This is the language (in the form of 0’s and 1’s,
called binary numbers) understood directly by the computer. It is
machine dependent. It is difficult to learn and even more difficult to
write programs.

• Assembly Language: This is the language where the machine codes


comprising of 0’sand 1’s are substituted by symbolic codes (called
mnemonics) to improve their understanding. It is the first step to improve
programming structure. Assembly language programming is simpler
and less time consuming than machine level programming, it is easier
to locate and correct errors in assembly language than in machine
language programs. It is also machine dependent. Programmers must
have knowledge of the machine on which the program will run.

➢ High Level Language: Low level language requires extensive knowledge of the hardware
since it is machine dependent. To overcome this limitation, high level language has been
evolved which uses normal English, which is easy to understand to solve any problem.

High level languages are computer independent and programming becomes quite easy and simple.

Various high level languages are given below:

o BASIC (Beginners All Purpose Symbolic Instruction Code): It is widely used, easy to learn
general purpose language. Mainly used in microcomputers in earlier days.
o COBOL (Common Business Oriented language): A standardized language used for
commercial applications.
o FORTRAN (Formula Translation): Developed for solving mathematical and scientific problems.
One of the most popular languages among scientific community.
o C: Structured Programming Language used for all purpose such as scientific application,
commercial application, developing games etc.
o C++: Popular object oriented programming language, used for general purpose.
Copyright @ Eugene Tebo November 2024
2
ICT316/SWE316 : Introduction to Programming , Lecture Notes Part 1

PROGRAMMING LANGUAGE TRANSLATORS

As you know that high level language is machine independent and assembly language
though it is machine dependent yet mnemonics that are being used to represent
instructions are not directly understandable by the machine. Hence to make the machine
understand the instructions provided by both the languages, programming language
instructors are used. They transform the instruction prepared by programmers into a form
which can be interpreted & executed by the computer. Flowing are the various tools to
achieve this purpose:

➢ Compiler: The software that reads a program written in high level language and translates it
into an equivalent program in machine language is called as compiler. The program written
by the programmer in high level language is called source program and the program
generated by the compiler after translation is called as object program.

➢ Interpreter: it also executes instructions written in a high-level language. Both complier &
interpreter have the same goal i.e. to convert high level language into binary instructions,
but their method of execution is different. The complier converts the entire source code into
machine level program, while the interpreter takes 1 statement, translates it, executes it &
then again takes the next statement.

➢ Assembler: The software that reads a program written in assembly language and translates
it into an equivalent program in machine language is called as assembler.

➢ Linker: A linker or link editor is a computer program that takes one or more object files
generated by a compiler and combines them into a single executable file, library file, or
another object file.

Types of Programming Languages

➢ Machine Level language

➢ Assembly language

➢ Procedural language (High Level Language)

o Machine Language:
Every computer has its own language called machine language. It depends on the
specific Hardware of the computer. A machine language is also known as low level
language also called machine understandable language. Computer understands &
executes the program only in machine level language. This low-level language is in the form
of (1‘s and 0‘s) binary code Low Level Language requires memorizing or looking up
numerical codes for every instruction that is used. These are machine dependent
languages. These are used for simulation languages, and LISP, artificial intelligence
applications.

Copyright @ Eugene Tebo November 2024


3
ICT316/SWE316 : Introduction to Programming , Lecture Notes Part 1

o Assembly Language:
Assembly language is the mnemonic language written in some specific symbolic codes,
such as ADD, SUB etc. An assembly language program is first translated into machine
language instruction by system program called assembler, before it can be executed.
These are languages understandable by CPU & ALU section of Computer Assembly
languages are called low level languages.

o High Level Language:


A High-level language is a simple English like language. A High-level program also needs to
be transferred into machine language instructions before it can be executed because
computer understands only machine level language. Rules for programming in a particular
high-level language are much the same for all computers, so that a program written for
one computer can generally be run on many different computers with little or no alteration.

This translation, called compilation is done by a systems program called a compiler. The
original program written in High level language is called source program and its translation.,
machine code is called object program. Some popular High Level languages are Basic,
Fortran, Cobol, Pascal, C & C++.High-level language offers three significant advantages
over machine language: simplicity, uniformity and portability (i.e., machine
independence).

Compilers and Interpreters program written in a high level language must be translated into
machine language before it can be executed. This is known as compilation or
interpretation, depending on how it is carried out.

Compilers translate the entire program into machine language before executing any of the
instructions. Interpreters, on the other hand, proceed through a program by translating and
then executing single instructions, or small groups of instructions. A compiler or interpreter is
itself a computer program that accepts a high-level program (e.g. a C program) as input
data, and generates a corresponding machine – language program as output. The original
high-level program is called the source program, and the resulting machine-language
program is called the object program. Every high-level language must have its own
compiler or interpreter for a particular platform. It is generally more convenient to develop
a new program using an interpreter rather than a compiler. Once an error-free program
has been developed, a compiled version will normally be executed much faster than an
interpreted version.

Difference between compiler and interpreter

Sr.No Compiler Interpreter


1 Compiler translates entire Interpreter translates and interprets line
program into by line
machine language at a time machine language.
2 It takes a large amount of time to It takes less amount of time to analyze the
analyze the source code but the sourc code but the overall execution
overall execution ti time is slower.
is comparatively faster

Copyright @ Eugene Tebo November 2024


4
ICT316/SWE316 : Introduction to Programming , Lecture Notes Part 1

3 Generates intermediate object No intermediate object code is


code which generated, hence memory efficient.
further requires linking, hence
requires mor memory
4 It generates the error message Continues translating the program until
only after scanning the whole the first error is met, in which case it stops.
program. Hence debug is Hence debugging is easy.
comparatively hard.
5 Errors are displayed after entire Errors are displayed for every instruction
program is checked and interpreted (if any) No Intermediate
Intermediate Object Code is Object Code Generated
Generated
6 Programming language like C, Programming language like Python, Ruby
C++ use compilers. use interpreters.

Attribute of good Programming Language


There are various factors why the programmers prefer one language over the another.
Some of very good characteristics of a good programming language are,
➢ Clarity, Simplicity and Unity:
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 to write because only few exceptions and special cases to be
remembered.
➢ Support for Abstraction:
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 operations built into a language.
➢ Programming Environment:
An appropriate programming environment (reliable documentation and testing packages)
adds an extra utility and make language implementation easier.
➢ Ease of program verification/Reusability:
The reusability of program written in a language is always a central concern. A program is
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 syntactic structure is a primary aspect that tends to simplify
program verification.
➢ Portability of programs:

Copyright @ Eugene Tebo November 2024


5
ICT316/SWE316 : Introduction to Programming , Lecture Notes Part 1

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, FORTRAN, C, C++, Java.

Program performance and features of programming languages


A programming language’s features include orthogonality or simplicity, available control
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. Table A shows the influence of a language’s features on the performance
of a program written in that language.
Table A indicates that simplicity, control structures, data types, and data structures have
significant impact on all aspects of performance. Syntax design and the support for
abstraction are important for readability, reusability, writability, and reliability. However,
they do not have a significant impact on the efficiency of the program. Expressiveness
supports writability, but it may have a negative impact on the reliability of the program.
Strong type checking and restricted aliasing reduce the expressiveness of writing programs,
but are generally considered to produce more reliable programs. Exception handling
prevents the program from crashing due to unexpected circumstances and semantic errors
in the program.

Table A: Impact of Language Features on the Performance of the Programs

Self-Assessment Exercises
• List and explain the three categories of programming language
• Discuss the attribute of a good programming language
• State any five features of a computer program
• List five program performances

Program Development Life Cycle

Copyright @ Eugene Tebo November 2024


6
ICT316/SWE316 : Introduction to Programming , Lecture Notes Part 1

Programmer for developing the program can not directly start any program or project.
Programmer has to understand whole program or project, has to analyze the sequence
and flow of the program

1. Understand the problem.


2. Plan the logic.
3. Code the program.
4. Use software (a compiler or interpreter) to translate the program into machine language.
5. Test the program.
6. Put the program into production.
7. Maintain the program.

1. Understanding the Problem

Professional computer programmers write programs to accomplish the requirements of users


or end users.

Examples of end users include payroll management system, they needs a printed list of all
employees, a Billing department that wants a list of clients who are 30 or more days
overdue on their payments, they need their deduction information. Since programmers are
providing a service to these users, programmers must first understand what the users want.
When a program runs, you usually think of the logic as a cycle of input processing-output
operations, but when you plan a program, you think of the output first. After you
understand what the desired result is, you can plan the input and processing steps to
achieve it.

Suppose the manager needs a list of all employees who have been here over five years,
because we want to invite them to a special thank-you dinner.

On the surface, this seems like a simple request. An experienced programmer, however, will
know that the request is incomplete. For example, you might not know the answers to the
following questions about which employees to include: Does the manager want a list of full-
time employees only, or a list of full and part-time employees together?

Copyright @ Eugene Tebo November 2024


7
ICT316/SWE316 : Introduction to Programming , Lecture Notes Part 1

Does she want to include people who have worked for the company on a month-to month
contractual basis over the past five years, or only regular, permanent employees?

Do the listed employees need to have worked for the organization for five years as of
today, as of the date of the dinner, or as of some other cutoff date?
What about an employee who worked three years, took a two-year leave of absence, and
has been back for three years?

The programmer cannot make any of these decisions; the user must address these
questions to manager.

For example, no one knew they wanted to play Angry Birds or leave messages on
Facebook before those applications were developed. Mobile app developers also must
consider a wider variety of user skills than programmers who develop applications that are
used internally in a corporation. Mobile app developers must make sure their programs
work with a range of screen sizes and hardware specifications because software
competition is intense and the hardware changes quickly.

2. Planning the Logic


The main important part of the program is planning the program‘s logic. During this phase
of the process, the programmer plans the steps of the program, deciding what steps to
include. You can plan the solution to a problem in many ways. The two most common
planning tools used are flowcharts and pseudocode. You may hear programmers refer to
planning a program as ―developing an algorithm.‖ An algorithm is the sequence of steps
or rules you follow to solve a problem.

The programmer shouldn‘t worry about the syntax of any particular language during the
planning stage, but should focus on figuring out what sequence of events will lead from the
available input to the desired output.

Planning the logic includes thinking carefully about all the possible data values a program
might encounter and how you want the program to handle each scenario. The process of
walking through a program‘s logic on paper before you actually write the program is
called desk checking.

3. Coding the Program


After the logic is developed, only then can the programmer write the source code for a
Program in a respective programming language. The logic developed to solve a
programming problem can be executed using any number of languages. Only after
choosing a language must the programmer be concerned with correct syntax.

4. Using Software to Translate the Program into Machine Language


Even though there are many programming languages, each computer knows only one
language— its machine language, which consists of 1s and 0s. Computers understand
machine language because they are made up of thousands of tiny electrical switches,
each of which can be set in either the on or off state, which is represented by a 1 or 0,
respectively

Copyright @ Eugene Tebo November 2024


8
ICT316/SWE316 : Introduction to Programming , Lecture Notes Part 1

Languages like Java or Visual Basic are available for programmers because someone has
written a translator program (a compiler or interpreter) that changes the programmer‘s
English-like high-level programming language into the low-level machine language that the
computer understands.

When you learn the syntax of a programming language, the commands work on any
machine on which the language software has been installed. However, your commands
then are translated to machine language, which differs in various computer makes and
models.

Diagram referred from programming logic and design by Joyce Farrell.


If you write a programming statement incorrectly the translator program doesn‘t know how
to proceed and issues an error message identifying a syntax error.
Typically, a programmer develops logic, writes the code, and compiles the program,
receiving a list of syntax errors. The programmer then corrects the syntax errors and
compiles the program again.Correcting the first set of errors frequently reveals new errors
that originally were not apparent to thecompiler.

5. Testing the Program


A program that is free of syntax errors is not necessarily free of logical errors. A logical error
results when you use a syntactically correct statement but use the wrong one for the
current context.

Input myNumber
setmyAnswer = myNumber * 2
outputmyAnswer

If you execute the program, provide the value 2 as input to the program, and the answer 4
is displayed, you have executed one successful test run of the program. Testing of logical
errors, syntactically errors are done.

6. Putting the Program into Production

Copyright @ Eugene Tebo November 2024


9
ICT316/SWE316 : Introduction to Programming , Lecture Notes Part 1

Once the program is thoroughly tested and debugged, it is ready for the organization to
use. Putting the program into production might mean simply running the program once, if it
was written to satisfy a user‘s request for a special list then we can finalize the program.

7.Maintaining the Program


After programs is completed making necessary changes is called maintenance.
Maintenance can be required for many reasons: for example, because new tax rates are
legislated, the format of an input file is altered, or the end user requires additional
information not included in the original output specifications. you make changes to existing
programs; you repeat the development cycle. That is, you must understand the changes,
then plan, code, translate, and test them before putting them into production.

Using Pseudocode Statements and Flowchart Symbols


When programmers plan the logic for a solution to a programming problem, they often use
one of two tools: pseudocode (pronounced―sue-doe-code‖) or flowcharts.

Pseudocode is an English-like representation of the logical steps it takes to solve a problem.


A flowchart is a pictorial representation of the same thing. Pseudo is a prefix that means
―false,‖ and to code a program means to put it in a programming language; therefore,
pseudocode simply means ―false code,‖ or sentences that appear to have been written in
a computer programming language but do not necessarily follow all the syntax rules of any
specific language.

Writing Pseudocode
You have already seen examples of statements that represent pseudo code earlier in this
chapter, and there is nothing mysterious about them. The following five statements
constitute a pseudocode representation of a number-doubling problem:

start
inputmyNumber
setmyAnswer = myNumber * 2
outputmyAnswer
stop

Using pseudocode involves writing down all the steps you will use in a program. Usually,
programmers preface their pseudocode with a beginning statement like start and end it
with a terminating statement like stop. The statements between start and stop look like
English and are indented slightly so that start and stop stand out. Most programmers do not
bother with punctuation such as period sat the end of pseudocode statements, although it
would not be wrong to use them if you prefer that style. Similarly, there is no need to
capitalize the first word in a sentence, although you
might choose to do so. This book follows the conventions of using lowercase letters for verbs
that begin pseudocode statements and omitting periods at the end of statements.
Pseudocode is fairly flexible because it is a planning tool, and not the final product.

Therefore, for example, you might prefer any of the following:

Copyright @ Eugene Tebo November 2024


10
ICT316/SWE316 : Introduction to Programming , Lecture Notes Part 1

• Instead of start and stop, some pseudocode developers would use the terms begin and
end.
• Instead of writing input myNumber, some developers would write getmyNumber or read
myNumber.
• Instead of writing set myAnswer = myNumber * 2, some developers would write calculate
myAnswer = myNumber times 2 or computemyAnswer as myNumber doubled.
• Instead of writing output myAnswer, many pseudocode developers would write display
myAnswer, print myAnswer, or write myAnswer.

The point is, the pseudocode statements are instructions to retrieve an original number from
an input device and store it in memory where it can be used in a calculation, and then to
get the calculated answer from memory and send it to an output device so a person can
see it. When you eventually convert your pseudocode to a specific programming
language, you do not have such flexibility because specific syntax will be required.

For example, if you use the C# programming language and write the statement to output
the answer, you will code the following:

Console. Write (myAnswer);

The exact use of words, capitalization, and punctuation are important in the C# statement,
but not in the pseudocode statement.

Algorithms and Flowchart Algorithms


1. A sequential solution of any program that written in human language, called algorithm.

2. Algorithm is first step of the solution process, after the analysis of problem, programmer
write the algorithm of that problem.

3. Example of Algorithms:

Q. Write am algorithm to find out number is odd or even?

Ans.
step 1 : start
step 2 : input number
step 3 : rem=number mod 2
step 4 : if rem=0 then
print "number even"
else
print "number odd"
endif
step 5 : stop

Flowchart
Defination : - Graphical representation of any program is called flowchart.

Copyright @ Eugene Tebo November 2024


11
ICT316/SWE316 : Introduction to Programming , Lecture Notes Part 1

Flowchart is a diagrammatic representation of sequence of logical steps of a program.


Flowcharts use simple geometric shapes to depict processes and arrows to show
relationships and process/data flow.

Flowchart Symbols
Here is a chart for some of the common symbols used in drawing flowcharts.
Symbol Symbol Name Purpose

Used at the beginning and end of the algorithm to


Start/Stop show start and end of the program.

Indicates processes like mathematical operations.


Process

Used for denoting program inputs and outputs.


Input/ Output

Stands for decision statements in a program, where


answer is usually Yes or No.
Decision

Shows relationships between different shapes.

Arrow

Connects two or more parts of a flowchart, which


are on the same page.
On-page
Connector

Guidelines for Developing Flowcharts


These are some points to keep in mind while developing a flowchart -
• Flowchart can have only one start and one stop symbol
• On-page connectors are referenced using numbers
• Off-page connectors are referenced using alphabets
• General flow of processes is top to bottom or left to right
• Arrows should not cross each other

Example Flowcharts

Copyright @ Eugene Tebo November 2024


12
ICT316/SWE316 : Introduction to Programming , Lecture Notes Part 1

Here is the flowchart for going to the market to purchase a pen.

Here is a flowchart to calculate the average of two numbers.

Programming Language Evolution and Paradigms

Programming Language Evolution

1883: The Beginning …!!


Copyright @ Eugene Tebo November 2024
13
ICT316/SWE316 : Introduction to Programming , Lecture Notes Part 1

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 devices was judged.

1949: Assembly Language


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) systems. It is also used to create computer viruses.

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 started and “end” means you have ended your code.

ALGOL(ALGOrithmic Language) was a first "Block Structured Language released in 1960. 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, FOR, WHILE loops

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 1959 by the ShortRange committee of the US department of
DOD.

Copyright @ Eugene Tebo November 2024


14
ICT316/SWE316 : Introduction to Programming , Lecture Notes Part 1

1964: BASIC
BASIC (Beginner's All-purpose Symbolic Instruction Code). It was designed as a 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
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 quickly
developed as a general purpose language. It was Programs compiled to a platform-
independent intermediate pcode. The compiler for Pascal was written in Pascal.

1972: C
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
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, Perl, PHP, Python, and Unix’s C shell.

Other Programming Languages


The table B below listed some popular programming languages among the programmers.

Table B: Other Programming Languages

Copyright @ Eugene Tebo November 2024


15
ICT316/SWE316 : Introduction to Programming , Lecture Notes Part 1

Programming Language Paradigm

A programming paradigm is an approach to programming a computer based on a


coherent 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 invented, and several
thousands of them are actually in use. Compared to natural languages that developed
and evolved independently, programming languages are far more similar to each other
because:
• different programming languages share the same mathematical foundation (e.g.,
Boolean, algebra, logic);
• 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
and efficient for hardware to execute;
• designers of programming languages share their design experiences.

Copyright @ Eugene Tebo November 2024


16
ICT316/SWE316 : Introduction to Programming , Lecture Notes Part 1

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
nonfunctional features. Scheme can be considered a subset of Lisp with fewer
nonfunctional features. Prolog’s arithmetic operations are based on the imperative
paradigm.

Categories of Programming Paradigm


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, programming languages can be divided into different classes namely;

➢ Imperative paradigm
➢ Functional paradigm,
➢ Logic paradigm
➢ Object-Oriented paradigm
➢ Visual paradigm
➢ Parallel/concurrent paradigms,
➢ Constraint based paradigm
➢ Dynamic paradigms.

Overview of Main Programming Paradigm


There are four main programming paradigms which are imperative paradigm functional
paradigm, logical paradigm and object-oriented paradigm.

✓ Imperative Paradigm
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, Algol, Ada, Pascal, and C.

✓ Object-Oriented Paradigm
The object-oriented programming paradigm is basically the same as the imperative
paradigm, except that related variables and operations on variables are organized into
classes of objects. The access privileges of variables and methods (operations) in objects

Copyright @ Eugene Tebo November 2024


17
ICT316/SWE316 : Introduction to Programming , Lecture Notes Part 1

can be defined to reduce (simplify) the interaction among objects. Objects are considered
the main building blocks of programs, which support language features like inheritance,
class hierarchy, and polymorphism. Typical object-oriented programming languages
include Smalltalk, C++, Python, Java, and C#.

✓ Functional (Application) Paradigm


The functional, also called the applicative, programming paradigm expresses computation
in terms of mathematical functions. Since we express computation in mathematical
functions in many of the mathematics courses, functional programming is supposed to be
easy to understand 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 immediately as the parameter value of another
function.
Functional programming is about 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 that will be discussed in Chapter 4.
Typical functional programming Languages include ML, SML, and Lisp/Scheme. Python and
C# support direct applications of lambda calculus and many functional programming
features.
✓ Logic Paradigm
The logic, also called the declarative, programming paradigm expresses computation in
terms of logic predicates. A logic program is a set of facts, rules, and questions. The
execution process of a logic program is to compare a question to each fact and rule in the
given fact and rulebase.

If the question finds a match, we receive a yes answer to the question. Otherwise, we
receive a no answer to the question. Logic programming is about finding facts, defining
rules based on the facts, and writing questions to express the problems we wish to solve.
Prolog is the only significant logic programming language.

Self-Assessment Exercises
• Explain the evolution of programming language.
• What is programming language paradigm?
• List all categories of programming language paradigm.
• Compare and contrast the four programming paradigms: imperative, object-oriented,
functional, and logic
• Explain in details the four common programming language paradigm.

Copyright @ Eugene Tebo November 2024


18
ICT316/SWE316 : Introduction to Programming , Lecture Notes Part 1

Conclusion
Paradigm is a set of basic principles, concepts, and methods for how a computation or
algorithm is expressed. We have several programming paradigms nowadays. Although
there is similarity between some of these programming languages. The above topic
emphasizes the need to know which paradigm the programming language in use belong
to.

EXERCISE:
1. What is Imperative Programming ? What are its Types ?
2. Write a Difference between Compiler and Interpreter.

Desirable Program Characteristics


These characteristics apply to programs that are written in any programming language :-
1. Integrity: This refers to the accuracy of the calculations. Integrity is needed to perform
correct calculations if any enhancement is done otherwise there will be no use of
enhancement and all enhancement will be meaningless Thus, the integrity of the
calculations is an absolute necessity in any computer program.

2. Clarity: refers to the overall readability of the program, with specific logic. If a program
should not be complicated it should be clearly written, it should be possible for another
programmer to follow the program logic without much effort. It should also be possible for
the original author to follow his or her own program after being away from the program for
an extended period of time. One of the objectives in the design of C is the development of
clear, readable and disciplined approach to programming

3. Simplicity: The clarity readability of the program and accuracy of a program are usually
enhanced by keeping things as simple as possible, uniqueness and consistency should be
included with the overall program objectives. In fact, it may be desirable to sacrifice a
certain amount of computational efficiency in order to maintain a relatively simple,
straightforward program structure.

4. Efficiency: is concerned with execution speed and efficient memory utilization. Many
complex programs require a tradeoff between these characteristics. hence experience
and common sense are key factors are used to increase efficiency of the program.

5. Modularity: Many programs can be broken down into a series of identifiable subtasks. It is
good programming practice to implement each of these subtasks as a separate program
module. In C programming language, such modules are written as functions. The use of a
modular programming structure enhances the accuracy and clarity of a program, and it
facilitates future program alterations.

6. Generality: Program to be as general as possible, within reasonable limits. For example,


we may design a program to read in the values of certain key parameters rather than
placing fixed values into the program. As a rule, a considerable amount of generality can
be obtained with very little additional programming effort. All programs should be written in
a generalized manner

Copyright @ Eugene Tebo November 2024


19

You might also like