0% found this document useful (0 votes)
3 views18 pages

Chapter 1 - Introduction To Computer Programming

This document serves as an introduction to computer programming, explaining its definition, importance, and the various types of programming languages including machine, assembly, and high-level languages. It also outlines different programming paradigms such as imperative, functional, logical, and object-oriented, detailing their characteristics and applications. The content is aimed at providing foundational knowledge for students in computer science.

Uploaded by

gatmachruey87
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)
3 views18 pages

Chapter 1 - Introduction To Computer Programming

This document serves as an introduction to computer programming, explaining its definition, importance, and the various types of programming languages including machine, assembly, and high-level languages. It also outlines different programming paradigms such as imperative, functional, logical, and object-oriented, detailing their characteristics and applications. The content is aimed at providing foundational knowledge for students in computer science.

Uploaded by

gatmachruey87
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

Chapter 1

Introduction to Computer Programming


• What is computer programming

• Reasons to study programming

• Types and usage of computer languages

• Programming paradigms

Faculty of Computational Science Department of Computer Science Instructor Dech R


1.1. What is Computer Programming:

• A vocabulary and set of grammatical rules (syntax) for instructing a computer to


perform specific tasks.
• Programming languages can be used to create computer programs.
• The term programming language usually refers to high-level languages, such as
BASIC, C, C++, COBOL, FORTRAN, Ada, and Pascal.

• A programmer is someone who writes computer program.


• Computer programmers write, test, and maintain programs or software that tell
the computer what to do.
Faculty of Computational Science Department of Computer Science Instructor Dech R
Con’t

• A program is a set of instructions following the rules of the chosen language.


• Without programs, computers are useless.
• It contains a list of ingredients called variables and a list of directions called
statements that tell the computer what to do with the variables.

• You eventually need to convert your program into machine language so that the
computer can understand it.

Faculty of Computational Science Department of Computer Science Instructor Dech R


• There are two ways to do this:
– Compile the program
– Interpret the program

• Compile is to transform a program written in a highlevel programming language from source code into object code.

• This can be done by using a tool called compiler.


• A compiler reads the whole source code and translates it into a complete machine code program to perform the
required tasks which is output as a new file.

• Interpreter is a program that executes instructions written in a high-level language.


• An interpreter reads the source code one instruction or line at a time, converts this line into machine code and
executes it.

Faculty of Computational Science Department of Computer Science Instructor Dech R


1.2. Reasons for Studying Concepts of Programming Languages:

I. Increase ability to express ideas.

II. Improve background for choosing appropriate languages

III. Greater ability to learn new languages

IV. Understand significance of implementation

V. Ability to design new languages

VI. Overall advancement of computing

Faculty of Computational Science Department of Computer Science Instructor Dech R


1.3. Types and Usage of Programming Language:
There are three types of programming language:
 Machine language (Low-level language)

 Assembly language (Low-level language)

 High-level language

• Machine Language

Machine language is a collection of binary digits or bits that the computer reads and
interprets.
Machine languages are the only languages understood by computers.
While easily understood by computers, machine languages are almost impossible for
humans to use because they consist entirely of numbers.
Faculty of Computational Science Department of Computer Science Instructor Dech R
• Assembly Language

A program written in assembly language consists of a series of instructions that correspond


to a stream of executable instructions.

Assembly languages use keywords and symbols like English, to form a programming
language

Computer doesn't understand the assembly code.

These codes are translated into machine language by a program called an assembler.

Faculty of Computational Science Department of Computer Science Instructor Dech R


Con’t
• High Level Language

Allow us to write computer code using instructions resembling everyday spoken


language (for example: print, if, while).

Programs written in a high-level language need to be translated into machine language


before they can be executed.
Some programming languages use a compiler to perform this translation and others
use an interpreter.
Faculty of Computational Science Department of Computer Science Instructor Dech R
1.4. Programming Paradigm:
·A pattern that serves as a school of thoughts for programming of computers.

• The sum of a main paradigm, programming styles, and certain programming techniques.

• Types programming paradigms


The imperative paradigm
The functional paradigm
The logical paradigm
The object-oriented paradigm

Faculty of Computational Science Department of Computer Science Instructor Dech R


I) imperative paradigm

• Involves writing programs as sequences of commands.

• The programmer specifies exact steps the computer must take.

• Uses statements like variable assignments, loops, and conditional logic.

• Controls the flow of the program and manipulates data.

Characteristics:
1. Sequential execution:

Instructions are executed one after another in a defined order, making the sequence of statements important.

2. State manipulation:

Programs actively change the state of variables throughout execution, allowing for direct data modification.

Faculty of Computational Science Department of Computer Science Instructor Dech R


Con’t
3. Explicit control flow:

Uses constructs like loops, conditional statements ("if" statements), and jumps to control the program flow based on conditions.

4. Variable assignment:

Variables can be assigned new values throughout the program, altering the data stored within them.

5. Side effects:

Operations can have direct effects on the program state, potentially impacting other parts of the code.

6. Less abstraction:

Often focuses on the specific steps to solve a problem in order to reduce complexity and increase efficiency.

Faculty of Computational Science Department of Computer Science Instructor Dech R


II) Functional paradigm
A simpler and more clean programming paradigm than the imperative one. The reason is that the
paradigm originates from a purely mathematical discipline: the theory of functions.

Characteristics:
1. Pure functions:

Functions that always return the same output for a given input, with no side effects, making them easier
to reason about and test.

2. Immutability:

Data cannot be changed once created, leading to more predictable behavior and easier debugging.

Faculty of Computational Science Department of Computer Science Instructor Dech R


Con’t
3. First-class functions:

Functions can be treated like any other data type, allowing them to be passed around and manipulated within the
program.

4. Higher-order functions:

Functions that can take other functions as input or return functions as output, enabling powerful abstraction and
code reuse.

5. Recursion:

A function calling itself to solve a problem by breaking it down into smaller, similar sub-problems.

6. Referential transparency:

An expression is replaced with its calculated value without affecting the program's outcome.
Faculty of Computational Science Department of Computer Science Instructor Dech R
III) Logic paradigm
It is a widely used language for artificial intelligence and expert systems.
In logic programming, you specify what you want to achieve, rather than how to achieve
it.
Applies in problem domains that deal with the extraction of knowledge from basic facts
and relations.
Characteristics:
1. Declarative nature:
Programs express the desired outcome without specifying the exact steps to reach it.
2. Logical rules:
Programs are built using logical rules (clauses) that define relationships between data
elements.

Faculty of Computational Science Department of Computer Science Instructor Dech R


Con’t
3. Backtracking search:

To find solutions by exploring different possibilities based on the given rules.


4. Unification:

The process of matching variables in logical expressions to find consistent solutions


5. Horn clauses:

A logical expression with a single conclusion and multiple premises


6. Inference engine:

To reason through the logical rules and derive conclusions based on the given facts.
Faculty of Computational Science Department of Computer Science Instructor Dech R
1.5. Object-oriented paradigm:
Supports the encapsulation and the logical grouping of program aspects. These properties are very
important when programs become larger and larger.

Characteristics:
1. Encapsulation:

Hides internal details of an object by binding data and its related functions together within a class and
exposing only necessary functionalities to interact with it.

2. Inheritance:

Enables a new class (subclass) to inherit properties and behaviors from an existing class (superclass).

Faculty of Computational Science Department of Computer Science Instructor Dech R


3. Polymorphism:

Allows objects of different classes to respond to the same method call in different
ways, depending on their specific implementation.

4. Abstraction:

Hides unnecessary implementation details.

Simplifies complex systems by modeling only relevant properties and behaviors.

Faculty of Computational Science Department of Computer Science Instructor Dech R


The End

Faculty of Computational Science Department of Computer


Science Instructor Dech R

You might also like