0% found this document useful (0 votes)
84 views33 pages

It 101 - Lecture 1

The document provides an introduction to principles of programming including defining a program and programming, different generations of programming languages from machine language to visual programming languages, and approaches to programming such as structured and object-oriented programming.

Uploaded by

Amoasi D' Oxygen
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
84 views33 pages

It 101 - Lecture 1

The document provides an introduction to principles of programming including defining a program and programming, different generations of programming languages from machine language to visual programming languages, and approaches to programming such as structured and object-oriented programming.

Uploaded by

Amoasi D' Oxygen
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 33

PRINCIPLES OF PROGRAMMING

Course code: IT 101 Credit Hours: 3

INSTRUCTOR
Abiew Nuku Atta Kordzo
Abiew Nuku Atta Kordzo (Systems Analysis: 2016) - GTUC
LECTURE ONE
INTRODUCTION TO
PROGRAMMING

Abiew Nuku Atta Kordzo (Systems Analysis: 2016) - GTUC


PROGRAM AND PROGRAMMING
• PROGRAM
A computer program is a series of organised instructions that directs a computer
to perform tasks. Without programs, computers are useless.
A program is like a recipe. It contains a list of variables (called ingredients) and a
list of statements (called directions) that tell the computer what to do with the
variables.
• PROGRAMMING
Programming is a creation of a set of commands or instructions which directs a
computer in carrying out a task.
• PROGRAMMING LANGUAGE
A programming language is a set of words, symbols and codes that enables
humans to communicate with computers.
PROGRAM AND PROGRAMMING
EXAMPLES PROGRAMMING LANGUAGE
• Examples of programming languages are:
 BASIC (Beginner’s All Purpose Symbolic Instruction Code)
 Pascal
C
 Smalltalk.
Java
C++
C Sharp
Cobol
Python
GENERATION OF PROGRAMMING
LANGUAGES

A low-level programming language is a programming language that


provides little or no abstraction from computer’s microprocessor.

A high-level programming language is a programming language that


is more abstract, easier to use, and more portable across platforms.
GENERATION OF PROGRAMMING LANGUAGES
FIRST GENERATION OF PROGRAMMING LANGUAGE
The first generation of programming language, or 1GL, is machine language.
Machine language is a set of instructions and data that a computer's central
processing unit can execute directly. Machine language statements are written
in binary code, and each statement corresponds to one machine action.

ADVANTAGES
• It is the fastest in terms of program execution
• Requires no translators to translate program instruction

DISADVANTAGES
• They are machine dependent
• Programs written in machine languages are most difficult to read and understand
• Machine language programs are most difficult to debug
GENERATION OF PROGRAMMING LANGUAGES
Machine Language Codes.
• Consider the following program statements

LOAD Cost
ADD Profit
STORE Price

The machine language equivalent of the above code is as follows:


0010 0000 0000 0100
0100 0000 0000 0101
0011 0000 0000 0110
GENERATION OF PROGRAMMING LANGUAGES
SECOND GENERATION PROGRAMMING LANGUAGE
The second generation programming language, or 2GL, is assembly language.
Assembly language is the human-readable notation for the machine language
used to control specific computer operations. An assembly language
programmer writes instructions using symbolic instruction codes that are
meaningful abbreviations or mnemonics. An assembler is a program that
translates assembly language into machine language. The following instruction :
TakeHomePay=GrossPay + Allowances - TotalTax
Can be written in an assembly language as follows:
LDA GrossPay
ADD Allowances
SUB TotalTax
STA TakedHomePay
GENERATION OF PROGRAMMING LANGUAGES

ASSEMBLY LANGUAGE –ADVANTAGES


• Program execute faster than those written in high level languages
• Assembly programs are easier to write, read and understand as compare to machine
languages
• Can be used to solve all practical problems
• Assembly programs are easier to debug than those written in machine language

DISADVANTAGES
• Assembly programs require an assembler to translate programs to machine language
• Program execution is slow as compared to programs written in machine language
since instructions have to be translated
• Assembly programs are difficult to read and understand as compared to high level
languages
• Assembly programs are machine dependent. That is, program written on one
computer would not run on another kind of computer
GENERATION OF PROGRAMMING LANGUAGES
THIRD GENERATION PROGRAMMING LANGUAGE
The third generation of programming language, 3GL, or procedural language
uses a series of English-like words, that are closer to human language, to write
instructions.

High-level programming languages make complex programming simpler


and easier to read, write and maintain. Programs written in a high-level
programming language must be translated into machine language by a
compiler or interpreter.

PASCAL, FORTRAN, BASIC, COBOL, C and C++ are examples of third


generation programming languages.
GENERATION OF PROGRAMMING LANGUAGES
FOURTH GENERATION PROGRAMMING LANGUAGE
The fourth generation programming language or non-procedural language,
often abbreviated as 4GL, enables users to access data in a database.

A very high-level programming language is often referred to as goal-


oriented programming language because it is usually limited to a very
specific application and it might use syntax that is never used in other
programming languages.

SQL, NOMAD and FOCUS are examples of fourth generation programming


languages.
GENERATION OF PROGRAMMING LANGUAGES
FIFTH GENERATION PROGRAMMING LANGUAGE
The fifth generation programming language or visual programming language, is
also known as natural language. Provides a visual or graphical interface, called
a visual programming environment, for creating source codes. Fifth generation
programming allows people to interact with computers without needing any
specialised knowledge. People can talk to computers and the voice recognition
systems can convert spoken sounds into written words.

Prolog and Mercury are the best known fifth-generation


languages.
GENERATION OF PROGRAMMING LANGUAGES
EXT : OPEN PROGRAMMING LANGUAGE
The Open Programming Language (OPL) is an embedded programming
language found in portable devices that run the Symbian Operating System. For
example mobile telephones and PDAs. OPL is an interpreted language that is
analogous to BASIC.
PROGRAMING APPROACHES
• STRUCTURED PROGRAMMING
• OBJECT-ORIENTED PROGRAMMING
STRUCTURED PROGRAMMING
Structured programming often uses a top-down design model where
developers map out the overall program structure into separate
subsections from top to bottom.
In the top-down design model, programs are drawn as rectangles. A top-down
design means that the whole program is broken down into smaller sections that
are known as modules. A program may have a module or several modules.
Structured programming is beneficial for organising and coding computer
programs which employ a hierarchy of modules.

This means that control is passed downwards only through the hierarchy.

Examples of structured programming languages include Ada, Pascal and Fortran.


STRUCTURED PROGRAMMING
OBJECT-ORIENTED PROGRAMMING
The object-oriented approach refers to a special type of programming
approach that combines data with functions to create objects.

In an object-oriented program, the object have relationships with one


another.

One of the earliest OOP languages is Smalltalk. Java, Visual Basic and
C++ are examples of popular OOP languages.
STRUCTURED VRS OBJECT-ORIENTE
PROGRAMMING

• Structured programming often uses a top-down design model.


• The object-oriented programming approach uses objects.
LANGUAGE TRANSLATORS
• All software packages or programs are written in high-level languages,
for example, C++, Visual Basic and Java. The translation of high level
languages to machine language is performed by a translator.
• A translator may be defined as any computer package capable of
translating as source program written in either a high level language
or an assembly language into a machine language.
• There are three types of language translators, namely:
• Compilers
• Interpreters
• Assembler
INTERPRETER
• The interpreter will read each codes converts it to machine code and
executes it line by line until the end of the program.
• Every program instruction is translated or interpreted on each occasion the
program is run. If any statement does not conform to the syntax of the
language, an error message is displayed on the screen.
• Until this error is corrected, the program execution cannot proceed and
this has the disadvantage of slowing down the running of the program.
• It requires the presence of the interpreter on the machine before program
can be executed.
• Examples of interpreter-based language are BASIC, Logo and Smalltalk.
ASSEMBLER
• An assembler is a computer program for translating assembly language —
essentially, a mnemonic representation of machine language — into
machine language.
• It translate the symbolic functions codes into the equivalent machine code;
symbolic addresses are allocated actual internal memory location.
After assembling the object program is retained on magnetic disk in machine code.
Errors are diagnose during the assembly process and is done once. It does not have
to be performed each time the program is run.
Programs tend to run faster because assembly language is a low level language and
nearer to machine language.
• For example in intel 80836, the assembly language for the ’no operation’
command is NOP and its machine code representation is 10010000.
COMPILERS
• The source code (in text format) will be converted into machine code
which is a file consisting of binary machine code that can be executed
on a computer. If the compiler encounters any errors, it records them
in the program-listing file.
When a user wants to run the program, the object program is
loaded into the memory of the computer and the program
instructions begin executing.

A compiled code generally runs faster than programs based


on interpreted language. Several programming languages like
C++, Pascal and COBOL used compilers as their translators.
GENERAL GUIDELINE FOR WRITING A
COMPUTER PROGAM
• To write a good computer program, on has to follow a certain
procedure. Some stages involves may be skipped if the program does
not require their use. Below are the major stages:
• Identification of the problem
• Definition of the problem
• Mathematical description(if any)
• Algorithm development or Flowcharting
• Computer Programming
• Testing and debugging
IDENTIFICATION OF THE PROBLEM
• This involves a thorough detailed understanding of the problem at
stake. This is a very crucial stage since the inability of one to identify
the problem correctly may lead to a program that might not give the
required output or solve the problem at hand

• For example; identifying a problem as a quadratic instead of


regression analysis will result in the program writing down instruction
for solving quadratic equations rather than regression analysis.
PROBLEM DEFINITION
• Once the programmer has identify the problem at hand, he or she
should be able to come out with series of instruction need by the
computer to solve the problem.
• This stage actually involve the following:
• Identification of input data(data that the computer has to be fed with to be
able to solve the problem or produce expected output).
• Identification of expected output
• Identifying formulas to be used.
Note: Garbage In Garbage Out (GIGO)
MATHEMATICAL DESCRIPTION(IF ANY)
• This involves reducing the problem to its mathematical equivalents
where possible.
• Writing a problem in mathematical equivalent form makes it easier
for analysis and design to be carried out.
• Care must be taken here in order not to write a wrong expression
since a wrong expression will eventually lead to a wrong output
ALGORITHM AND FLOWCHART
DEVELOPMENT
• An algorithm involves the writing up of the various instructions
required to solve the problem in a logical manner whereas a
flowchart is a pictorial representation of the algorithm.
• For those who are good in programming, this step may be skipped
but it is highly recommended for beginners.
• Algorithms and flowcharts will be discussed in more details in
subsequent lectures.
COMPUTER PROGRAMMING
• This involves the coding of the algorithm and or the flowchart into a
form that is understood by the machine with respect to the
programming language one uses.
• This is the stage where high skills in programming languages such as
Java, C++, Visual Basic, C#, Python, JSP, PHP is required.
TESTING AND DEBUGGING
• This is the final stage.
• This stage involves identifying, locating and correcting errors in the
program.
• In testing a program, use inputs that the output is known or can be
calculated manually for comparisons.
• If there is any disparity between the output from your program and that of
the manual process, and the output of the manual process have been
accepted as being true, then there is a bug in the program. Such a bug is likely
to be a logical one or incorrect mathematical expression
REASONS FOR STUDYING CONCEPTS OF
PROGRAMMING LANGUAGES
• Increased capacity to express ideas
• Improved background for choosing appropriate languages.
• Increased ability to learn new languages.
• Better understanding of the significance of implementation.
• Better use of languages that are already known.
• Overall advancement of computing.
PROGRAMMING DOMAINS
• Computers have been applied to a myriad of different areas, from
controlling nuclear power plants to providing video games in mobile
phones. Because of this great diversity in computer use, programming
languages with very different goals have been developed. In this
section, we briefly discuss a few of the areas of computer applications
and their associated languages
• Scientific Application
• Business application
• Artificial Intelligence
• System Planning
• Web Software
LANGUAGE EVALUATION CRITERIA
CRITERIA
Characteristics READABILITY WRITABILITY RELIABILITY
Simplicity
Orthogonally
Data types
Syntax design
Support for abstraction
Expressivity
Type checking
Exception handling
Restricted aliasing

Assignment: Find out the meaning of all the characteristic in respect to the three
language evaluation criteria
END OF LECTURE
ONE

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy