Professional Documents
Culture Documents
1 - Introduction To Programming
1 - Introduction To Programming
1 - Introduction To Programming
2 Introduction to Programming
A computer by itself will not do anything particularly useful.
A programming language signifies the syntax that can be used to write a program
Programming languages are specifically designed for giving commands to a computer
1 22/03/2024
1.2 Introduction to Programming
Machine Language
Machine language is a type of programming language
Machine language can be understood directly by a particular computer
Simple instructions that can be executed directly by the CPU of a
computer
These instructions represent the fundamental operations that the computer
can perform
2 22/03/2024
1.2 Introduction to Programming
Machine Language
Machine language is represented by a series of 1’s and 0’s that cause
the computer to perform a particular action.
E.g., 1010101011010
This is called a binary encoding
The set of fundamental operations that a computer can perform and their
binary encodings is called the machine’s instruction set
Different types of computers use different machine languages
E.g., Intel Pentium processor vs. IBM PowerPC processor
A program written in machine language is easy for a computer to
understand but very difficult for a human to understand just by
looking at it.
3 22/03/2024
1.2 Introduction to Programming
Assembly Language
We would like to have a language that was more natural for a human
to understand -> Assembly Language created
Devise a set of abbreviations corresponding to the ML statements
Developed a program to translate these abbreviations into ML
We are still writing programs at a low-level when using assembly
Instead of having to program in binary we can use a more natural language
An assembly language instruction will typically have a corresponding
binary encoding
NOTE: When using assembly language we still need to know the details of the
machine being programmed, e.g., is it an Intel Pentium machine or an IBM
PowerPC machine.
4 22/03/2024
1.2 Introduction to Programming
High Level Language (HLL)
Instructions are represented using a set of statements which are similar
to human language (if, else, while etc.)
Much faster to write program code in a HLL than Assembly or
Machine Language
A compiler / interpreter is used to translate the HLL statements into
ML
NOTE: When using a high-level language we do not need to know the details of
the machine being programmed.
5 22/03/2024
1.2 Introduction to Programming
Compilers & Interpreters
Contextual Analogy
Imagine you wish to be able to access the content of a book that is written
in a language with which you are unfamiliar.
How could you get the book translated into a language that you do
understand?
6 22/03/2024
1.2 Introduction to Programming
Syntax and Semantics
The syntax rules of a language define how we can put symbols, reserved words,
and identifiers together to make a valid program. It is similar to the grammar of a
language.
The semantics of a program statement define what that statement means (its
purpose or role in a program).
A program will always do what we tell it to do, not what we meant to tell it to do
7 22/03/2024
1.3 Algorithms & Problem Solving
Algorithms
8 22/03/2024