8.0 PROGRAMMING 8.1 Introduction To Programming 8.1.1 8.1.2 8.1.3 8.1.4 • • • • Definition Types Of Programming Languages Programming Language Paradigm Translator Learning outcomes • Define programming language 8.1.1 • Differentiate between Low-level and High8.1.2 level language. • Identify.

Download Report

Transcript 8.0 PROGRAMMING 8.1 Introduction To Programming 8.1.1 8.1.2 8.1.3 8.1.4 • • • • Definition Types Of Programming Languages Programming Language Paradigm Translator Learning outcomes • Define programming language 8.1.1 • Differentiate between Low-level and High8.1.2 level language. • Identify.

8.0
PROGRAMMING
8.1 Introduction To Programming
8.1.1
8.1.2
8.1.3
8.1.4
•
•
•
•
Definition
Types Of Programming Languages
Programming Language Paradigm
Translator
Learning outcomes
• Define programming language
8.1.1
• Differentiate between Low-level and High8.1.2
level language.
• Identify the functions of translators.
8.1.4
• State paradigms of programming languages.
8.1.3
8.1.1
Programming Languages
• a set of conventions (words, abbreviations
and symbols) in which instructions for the
machine are written. That tell the computer to
perform task.
– Just as human beings communicate with each
other through the use of languages such as
English, Spanish, Hindi, and Chinese, programmers
use a variety of programming languages to
communicate with the computer
8.1.2
Types of
Programming Languages
High-level Language
Example :
FORTRAN, COBOL,
C, C++, C#
Low-level Language
Example Codes :
Assembly Language ;
MOV, MUL, LOAD, ADD
Machine Language ;
0110 1100 1011
Programming Languages
• Low-level Language
– consist of a :• Machine language , and
• Assembly language.
• High-level Language
Low-level Prog. Languages
: Machine Language
 Machine
Language
• Sometimes also referred to machine code or an
•
•
•
•
object code.
Instructions is in the form of a machine code (0s
or 1s) , example : 0010 0101 0110
That is the only language the computer directly
recognizes.
Representing the only way to directly
communicate with the computer.
Hard to understand (tedious) and it is error-prone
language, thus require highly trained
programmers.
Low-level Prog. Languages
: Assembly Language
 Assembly
Language
• Using mnemonics in place of 0s and 1s in the
program.
 Mnemonics /symbolic instruction codes– alphabetic
abbreviations for instructions
 Example : LOAD, MOVE, ADD, MUL
• It is still hard to write (tedious) and it also requires
highly trained programmers.
Low-level Prog. Language
Machine Language and Assembly Language
Programming Languages
• Low-level Language
– consist of a :• Machine language , and
• Assembly language.
• High-level Language
– Using an instructions that more closely resemble
the English language.
• examples of High-level programming languages ;
FORTRAN, COBOL, C, C++, C#
High-level Prog. Languages
 High-level
programming language
• Vast improvement over low-level language
(machine and assembly language)
• allow the programmer to use instructions that more
closely resemble the English language.
• machine independent compared to machine and
assembly languages
* programs written in a high-level language can
be used on many different types of computers.
8.1.2
Differences of
Low-level vs High-level Language
Low-level Language
(Machine and Assembly Language)
High-level Language
Machine-dependent – runs only on one
type of a computer
Often machine-independent – can run on
many different types of computers and
operating systems.
Hard to write and to understand, thus
requires highly trained programmers.
Allow programmers to write an
instructions that more closely resembles
the English language.
Using an assembler (a translator) – to
translate an assembly language to a
machine code.
Using a compiler or an interpreter (a
translator) – to translate high-level
language into a machine code.
8.1.4
The Translator
• Translator – is a computer program that ;
– translates a computer program written in a given
programming language into a functionally
equivalent program in a different computer
languages.
The Translator, cont’
Translator for Machine Language ?
• Case #1 : Do a translator need to translate a
code written in machine language into a
machine language ?
• Answer : NO translation needed.
Translator for Assembly Language ?
• Case #2 : Do a translator need to translate a
code written in assembly language into a
machine language ?
• Answer : YES, translator use an Assembler
Translator for High-level Language ?
• Case #3 : Do a translator need to translate a
code written in high-level language into a
machine language ?
• Answer : YES, translator use a Compiler or an Interpreter
Machine
Language to
Machine
Language
No translator
needed
(because
similar
language)
Assembly Language to
Machine Code
High-level Language to
Machine Code
need a translator called
need a translator called
Compiler1 or
Assembler
Assembler - a program that
translates a program written
in assembly language into an
equivalent program in
machine language.
Interpreter2
1Compiler
- a program that
translates entire instructions
written in a high-level
language into the equivalent
machine language
2Interpreter
– a program that
translates the instructions line
by line as the program is
running.
8.1.3
Programming Language Paradigm
• Computer languages are categorized
according to the approach they use to solve a
problem.
• A paradigm, therefore, is a way in which
computer language looks at the problem to be
solved.
8.1.3
Programming Language Paradigm
Structured
Object-oriented
Top-down approach
Bottom-up approach
Program is represent as a logical structure
Program is written as a collection of
objects which communicate with each
other.
Flow of execution of the programming is
dependent on the structure of the
program
The basic entity is object. Each
computation is performed using object
only.
Can handle up to moderately complete
program
Can handle very complex programs.
Less data security, less code reusability
More data security, more reusability
Abstraction is less.
Abstraction is more.
references
• D. Zak (2011)
An Introduction to Programming 6th Ed. Cengage Learning.
• DS. Malik (2011)
C++ Programming 5th Ed. Cengage Learning.