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

1 Introduction to Programming

This document provides an introduction to programming, covering definitions and types of programming languages, including low-level and high-level languages, as well as programming paradigms such as procedural, object-oriented, and logic-oriented programming. It also explains the role of language translators, including compilers, interpreters, and assemblers, and their advantages and disadvantages. The learning outcomes aim to equip students with the ability to define key concepts and differentiate between various programming paradigms and language translators.

Uploaded by

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

1 Introduction to Programming

This document provides an introduction to programming, covering definitions and types of programming languages, including low-level and high-level languages, as well as programming paradigms such as procedural, object-oriented, and logic-oriented programming. It also explains the role of language translators, including compilers, interpreters, and assemblers, and their advantages and disadvantages. The learning outcomes aim to equip students with the ability to define key concepts and differentiate between various programming paradigms and language translators.

Uploaded by

9gtb6ghbft
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 8

Topic 1

1.0 INTRODUCTION TO PROGRAMMING


PROGRAMMING

Learning Outcome

At the end of this topic, students should be able to:


a. Define Programming Language, Programming Paradigm, Language Translators
b. Differentiate Paradigm of Programming Language (Procedural, Object Oriented & Logic)
c. Differentiate types of language translator (Compiler, Interpreter, Assembler)

What is a Computer Program/Software/Apps?

A computer program/software/apps is a series of instructions written


for a computer or mobile device, such as an operating system program
or an application program.
• Created by a programmer using a programming language.
• Programmer, also called developer, is the person who
writes and modifies computer programs.
• To write a computer program, you need an appropriate
software program for the programming language you will
be using.

What is programming language?

▪ A programming language is a set of words, abbreviations, and symbols that enables


a programmer to create instructions for a program /software/apps.
Discovering Computers 2023

1
Topic 1
1.0 INTRODUCTION TO PROGRAMMING
PROGRAMMING

Types of programming language

Programming
Language

Low level High level


Language Language

Machine Assembly
Language Language

Concept Check:

Criteria Type of programming language


1. A machine-dependent language, run on only one
computer
2. A machine-independent language can run on many
different types of computers and operating systems
3. These programs are easily portable to other types of
computers.
4. These programs are not easily portable to other types of
computers.
5. Machine language, assembly language
6. C++, Basic, C
Criteria Type of translator
7. A language translator that converts an entire program
into machine language before executing it.
8. A language translator that converts program statements
line by line into machine language, immediately executing
each one.
9. A language that translates a program written in assembly
language into an equivalent program in machine
language.

2
Topic 1
1.0 INTRODUCTION TO PROGRAMMING
PROGRAMMING

A programming language is a set of words, abbreviations, and symbols that enables a programmer to create
instructions for a program /software/apps.

Type of Programming Language: Low Level Language


Definition:
▪ A low-level is a programming language that is machine dependent that runs on only one type of computer
and programs are not easily portable to other types of computers.

Types of Low-Level Language: Machine Language Types of Low-Level Language: Assembly Language
Definition: Definition:
▪ Machine language is the first generation of programming ▪ Assembly language is the second generation of
languages where instructions are written using series of programming languages where instructions are written
binary digits (1s and 0s). using symbolic instruction codes which are meaningful
abbreviations.

A sample machine A sample assembly


language program, language program.

Example: To calculate wages = rates * hours Example: To calculate wages = rates * hours
100100 010001 //Load rates
100110 010010 //Multiply hours
100010 010011 //Store wages

▪ Programmers must translate an assembly language


program into machine language before the computer can
execute, or run, the program.
▪ Examples of assembly language: ASM
Advantages Disadvantages Advantages Disadvantages
▪ Instructions are readily ▪ Instructions are extremely ▪ Instructions are easier to ▪ Not readily understood
understood by the difficult to learn because learn compared to by computer, thus need
computer because instructions are written machine language to be translated to
instructions are written using series of binary because instructions are machine language.
using series of binary digits (1s and 0s). written using symbolic
digits (1s and 0s); the ▪ Machine-dependent; runs instruction codes which ▪ Machine-dependent; runs
only language the on only one type of are meaningful on only one type of
computer directly computer. abbreviations. computer.
understands.

▪ Ready for immediate ▪ Programs are not easily ▪ Programs are not easily
execution. portable to other types of portable to other types
computers. of computers.

3
Topic 1
1.0 INTRODUCTION TO PROGRAMMING
PROGRAMMING

A programming language is a set of words, abbreviations, and symbols that enables a programmer to create
instructions for a program /software/apps.

Type of Programming Language: High Level Language


Definition:
▪ A high-level language is a programming language that is machine independent that can run on many different
types of computers and operating systems where instructions are written using series of English-like words.
• These programs are easily portable to other types of computers.

▪ Programmers must translate a high-level language program (source program) into machine language before the
computer can execute, or run, the program.
Example: To calculate wages = rates * hours in Java

▪ Examples of high-level language: Basic, FORTRAN, COBOL, Pascal, C, C++, C#, and Java.

Advantages Disadvantages
▪ Instructions are easier to learn compared to low-level ▪ Not readily understood by computer, thus need to be
languages because instructions are written using series of translated to machine language.
English-like words.
▪ Machine-independent language can run on many different
types of computers and operating systems.

▪ These programs are easily portable to other types of


computers.

Differences between High Level Language and Low-Level Language


High Level Language Low Level Language
Machine-independent; can run on many different Machine-dependent; runs on only one type of
types of computers and operating systems and the computer and the programs are not easily
programs are easily portable to other types of portable to other types of computers.
computers.
High-level languages are easy to learn because Low-level languages are difficult to learn because
instructions are written using series of English-like instructions are written using series of binary
words. digits and symbolic instruction codes.
High-level languages are nearer to human languages- Low-level languages are nearer to machine
series of English-like words. languages- series of binary digits and symbolic
instruction codes.

4
Topic 1
1.0 INTRODUCTION TO PROGRAMMING
PROGRAMMING

What is Programming Paradigm?

▪ A programming paradigm is a fundamental style or “way” of computer programming, that can be


categorized according to the approach used to solve a problem.

OR
▪ A programming paradigm is an approach to programming a computer based on a mathematical
theory or a coherent set of principles.

Procedural Programming ▪ Programs are divided into a collection of procedures (functions


or methods) and data.
Programs = Procedures + Data
▪ Program starts with a problem and then breaks that problem
main() down into smaller sub-problems or sub-procedures. (it divides a
{ program code into a collection of procedures and data)
int radius;
▪ Example of Procedural Language: C, BASIC, FORTRAN, PASCAL,
cout << “Area of circle is “ <<
BASIC, ALGOL
getArea(4);

double getArea(int r) {
double area;
area = 3.142 * r * r;
return area;
}
Logic-Oriented ▪ The logic programming paradigm uses automated reasoning to
Programming compute over a set of facts and rules.

▪ Program code is written using logic notation. Programs are


Programs = Facts + Rules
executed by applying inference rules over these facts until an
answer to the problem is found. There are no explicit algorithms.
The program is to find whether 3 is
a whole number. ▪ Example of Logic Oriented Programming: Prolog (programming
All integers are whole numbers. - logic), Strawberry Prolog, Toon Talk
(rules)
3 is an integer. (fact)
Answer : Yes

5
Topic 1
1.0 INTRODUCTION TO PROGRAMMING
PROGRAMMING

Object-oriented ▪ Object-oriented programming divides a programming task into


Programming (OOP) objects with each object encapsulating its own data and
methods.
Programs = Objects + Methods
▪ Programming paradigm that uses classes and objects to create
models based on the real world environment.
class Circle {
private int radius;
▪ Example of Object Oriented Programming (OOP): C++, Visual
Basic, Java, Smalltalk, Ruby, Python
public void setRadius(int r) {
radius = r; }

public double getArea() {


double area;
area = 3.142 * radius *
radius;
return area; }
}
class FindCircle {
public static void main() {
Circle circle1;
circle1.setRadius(4);
System.out.print(“Area of
circle is”);

circle1.getArea(); }

6
Topic 1
1.0 INTRODUCTION TO PROGRAMMING
PROGRAMMING

What is Language Translator?

Language Translator: is defined as a computer program that translates instructions (source program)
written in one programming language to be translated to machine language.

Translator Assembler Interpreter Compiler


Description Converts programs Converts high-level language Converts an entire
written in assembly program statements line by high-level language
language to machine line into machine language, program into
language immediately executing each machine language
one before executing it
Programming Low Level Language High Level Language High Level Language
Language
Advantages ▪ When it finds errors, it ▪ Runs faster
displays feedback
immediately so the
programmer can correct
any errors before the
interpreter translates the
next line
Disadvantages ▪ Does not run fast ; ▪ Cannot change the
due to the per-line program without
translation method going back to the
original source code

Examples ▪ GAS ▪ JavaScript ▪ GCC (GNU Compiler


▪ FAP ▪ JRuby Collection
▪ COMPASS ▪ PyPy ▪ Clang
▪ Javac
▪ Microsoft Visual
Studio C++ Compiler

Examples of ASM BASIC, PHP, Python COBOL, COBRA, C++, C,


languages Java

7
Topic 1
1.0 INTRODUCTION TO PROGRAMMING
PROGRAMMING

You might also like