You are on page 1of 17

INTRODUCTION TO COMPUTER PROGRAMMING

INTRODUCTION
• Definition of terms
• Programming languages
• Programming paradigms
• Generations of programming languages
• Compilers and Interpreters

2/26/21 CS102
Definition of terms

A Computer Program
• a set of instructions written using a programming
language that a computer must follow step by step to
execute a particular task.
• a set of instructions written in logical sequence for a
computer to perform a certain task.
• These instructions enable a computer to carry out a
specific task.

2/26/21 CS102
Definition of terms

Computer Programming
• Computer programming is defined as the science of making
computer programs.
• The art of designing and coding or writing computer programs.
• A computer program when fully developed becomes a software.
• Software is created through a process known as software
development.
Computer programmer
• A programmer is the person who writes programs that can be
executed by the computer.

2/26/21 CS102
Programming languages
• Programs are writing in some specific languages
known as the programming languages.
• Programming languages evolved much earlier in
time than we may think of .
• From the history and evolution of computers,
find out when programming was introduced?
• Find the history of programming languages and
give an account?

2/26/21 CS102
Programming languages
• English is a natural language. It has words,
symbols and grammatical rules.
• A programming language also has words,
symbols and rules of grammar.
• The grammatical rules are called syntax.
• Each programming language has a different
set of syntax rules.

2/26/21 CS102
Programming Paradigms
• A programming paradigm is pattern that serves as a
school of thoughts for programming of computers.
• a fundamental style of computer programming.
There several programming paradigms, here we are
going to look at the following four paradigms:
1. Procedural programming Paradigm.
2. Object Oriented Programming Paradigm.
3. Event Driven Programming Paradigm.
4. Declarative Programming Paradigm.
2/26/21 CS102
Procedural programming
• This can sometimes be used as a synonym for imperative programming, but
can also refer to a programming paradigm based upon the concept of the
procedure call.
• Procedures, also known as routines, subroutines, methods, or functions
simply contain a series of computational steps to be carried out.
• Any given procedure might be called at any point during a program's
execution, including by other procedures or itself.
• A procedural programming language provides a programmer a means to
define precisely each step in the performance of a task.
• The programmer knows what is to be accomplished and provides through
the language step-by-step instructions on how the task is to be done.
• The languages that follow this includes :
– Pascal, C, fortran etc

2/26/21 CS102
Object Oriented Programming
• In object-oriented programming, programmers can think of a program as
a collection of interacting objects.
• It uses "objects" i.e. data structures consisting of data fields and methods
together with their interactions to design applications and computer
programs.
• In these languages data, and methods of manipulating the data, are kept
as a single unit called an object.
• The only way that a user can access the data is via the object's 'methods'
(subroutines)/functions.
• The programming technique includes features such as data abstraction,
encapsulation, modularity, polymorphism, and inheritance.
• Examples include Object Pascal, C++, C#, Visual Basic, Common Lisp,
Scheme, Perl, Python, Ruby, Java, VB.Net etc.

2/26/21 CS102
Event Driven Programming
• This is a programming paradigm in which the
flow of the program is determined by events
i.e., sensor outputs or user actions (mouse
clicks, key presses) or messages from other
programs or threads.
• Languages that follow this paradigm includes:
– SQL (Structured Query Language)
– VB (Visual Basic)
– JAVA
2/26/21 CS102
Declarative Programming
• In these languages the computer is told what the problem is, not
how to solve the problem .
• The program is structured as a collection of properties to find in
the expected result, not as a procedure to follow.
• Given a database or a set of rules, the computer tries to find a
solution matching all the desired properties.
• The typical example of a declarative language is the fourth
generation language SQL, as well as the family of functional
languages and logic programming.
• The most common examples of declarative languages are logic
programming languages such as Prolog and functional languages
like Haskell.
2/26/21 CS102
Generations Programming Languages

There are the following generations:-


• First Generation
• Second Generation
• Third Generation (3GL)
• Fourth Generation
• Fifth generation

2/26/21 CS102
First Generation

• First Generation is based on Example


Machine language.
– this consist entirely of numbers. 000100100100010
000100100100010
100100100111011
100100100111011
– It is the lowest-level 0010101101001..
0010101101001..
..
programming language.
– Machine language is the only
language understood by
computers.
– Very efficient code but very
difficult to write.
2/26/21 CS102
Second Generation
• Second Generation is based on Assembly language.
• An assembly language is a low-level language for Example
programming computers.
• The word "low" does not imply that the language is inferior
to high-level programming languages but rather refers to the LOAD
LOAD r1,b
r1,b
small or nonexistent amount of abstraction between the LOAD
language and machine language. LOAD r2,h
r2,h
MUL
MUL r1,r2
r1,r2
• Because of this, low-level languages are sometimes
described as being "close to the hardware.” DIV
DIV r1,#2
r1,#2
• It implements a symbolic representation (mnemonic) of the RET
RET
numeric machine codes and other constants needed to
program a particular CPU architecture.
• A utility program called an assembler, is used to translate
assembly language statements into the target computer's
machine code.
• Assembly language representation is easier to remember
(more mnemonic)

2/26/21 CS102
Third Generation

• Third Generation is made up of “High-level” languages


such as Pascal, C, COBOL, Fortran. Example
• High-level languages are relatively easy to learn because class
the instructions bear a close resemblance to everyday class Triangle
Triangle
{{
language, and because the programmer does not require
...
...
a detailed knowledge of the internal workings of the
computer. float
float Area()
Area()
• Each instruction in a high-level language is equivalent to several return
return b*h/2;
b*h/2;
machine-code instructions, therefore it is more compact than }}
equivalent low-level programs.
• This more Closer to English but included simple mathematical notation.
–Programs are written in source code which must be translated into
machine language programs called object code.
–The translation of source code to object code is accomplished by a
machine language system program called a compiler.
• High-level languages are used to solve problems and are often
described as problem-oriented languages

2/26/21 CS102
Fourth Generation

• Fourth Generation languages (4GL) are also high level languages.


• However 4GLs requires fewer instructions to accomplish a task
than a third generation languages.
• Examples includes Scripting languages such as SQL, Apple script,
VBScript.
• Used with databases in:-
– Query languages
– Report generators
– Forms designers
– Application generators

2/26/21 CS102
Fifth Generation

• Fifth Generation programming languages consist of


• Natural languages?
• Automatic code generation?
• Object-oriented languages?
• Declarative languages
• Functional(?): Lisp, Scheme, SML
– Also called applicative
– Everything is a function
• Logic: Prolog
– Based on mathematical logic
– Rule- or Constraint-based
2/26/21 CS102
Compilers and Interpreters
• Since computers understand machine language,
Translating from High-level Languages to Binary is
necessary.
• High-level languages can be translated in the following
ways:-
– Interpreted: each statement translated as it is executed--slow
but easy to use.
– Compiled: entire program is converted to binary--executes
faster, but more difficult to use (.exe files are compiled
programs)
• Compilers and interpreters do the translation.

2/26/21 CS102

You might also like