Uploaded by Mekuannint Demeke

Chapter - 1 - Introdiction to Programming

advertisement
Introduction to Programming
By :
Selam Girma (MSc.)
August, 2019
Chapter One
Introduction
to
Programming
• Introduction to Programming
• Hierarchy of Computer Language
• Characteristics of Computer Language
• Language Translators
1.1 Introduction to Computer Programming Languages
• A computer is a computational device which is used to process the
data under the control of a computer program.
• Program is an organized sequence of instruction along with data that,
when executed, it perform any operation, and do the job it is also
known as Code
• A program is like a recipe. It contains a list of variables and a list of
directions (Statements) that tell the computer what to do, when and
how to do it.
✓ The term Instruction is often used to describe the programming
Commands
4
Cont . . . Introduction to Computer Programming Lanuage
1.1 Introduction to Computer Programming Languages
• These Computer Programs are written in a Programming Language
• Programming Languages are an Artificial Language designed to work
for different application in different environment.
• Programming languages can be used to create programs that controls
the behavior of a computer and serve any purpose.
• Computer languages have some form of written specification of their :✓ Syntax (Special Rules for organizing program instruction) and
✓ Semantics (Unique set of Keywords, Phrases & Sentences)
5
1.2 Hierarchy of Computer Language
• Human Languages are known as natural languages, Unfortunately,
computers can not understand natural languages, as a result we must
communicate with computers using computer languages.
• These languages are :✓ High Level Language
✓ Assembly Language
✓ Machine Language
6
Cont . . . Hierarchy of Computer Language
1.1 Hierarchy of Computer Language
Higher Level Languages
Lower Level Languages
7
1.2.1 Machine Language
• It is the native language of the computer, and it consists of Bits or
Binary Digits (1s and 0s) that computer interprets.
• Sometimes referred to as Machine Code or Object Code.
• It is a system of instructions and data executed by the computer’s CPU.
• It is the only language the computer understand without translator.
• Machine language instructions typically use some bits to represent
operations.
• It is difficult to read and write, since it does not resemble conventional
mathematical notation or human language, and its codes vary from
computer to com
8
1.2.2 Assembly Language
• It uses short mnemonic codes (short forms) for instructions & allows
programmers to introduce names for blocks of memory to hold data.
• It is designed to be easily translated into machine language.
• Assembly language programs needed to be “assembled” for execution
by the computer.
• Each assembly language instruction is translated into one machine
language instruction
• It requires detailed knowledge of particular internal computer
architecture
• An assembler is needed to translate the assembly code into machine
9
code.
1.2.3 High Level Language
• High Level languages are much closer to human language that enables
to write programs which is understandable to programmer (Human).
• High level languages are machine independent.
• It don’t require programmers to know about internal structure of
computer on which High Level Language programs will be executed.
• It enables the programmers to write instructions using English words
and familiar mathematical symbols and expressions.
10
Advantages of High Level Language over Low Level Language
• They are easier to read, write and maintain.
• High level languages make complex programming simpler.
• High level programming techniques are applicable everywhere
computational resources are limited.
• Error ratio is less in high level languages and debugging (locate and
correct errors in program code) is easier.
• Length of the program is also small compared with low level.
• Many real time problems can be easily solved with high level language.
11
High Level Vs Low Level Languages
12
1.3 Characteristics of a programming Language
• A programming language must be simple, easy to learn and use, have
good readability and human recognizable.
• Abstraction is a must-have Characteristics for a programming language
in which ability to define the complex structure and then its degree of
usability comes.
• A portable programming language is always preferred.
• Programming language’s efficiency must be high so that it can be easily
converted into a machine code and executed consumes little space in
memory
13
Cont . . . Characteristics of a Programming Language
• A programming language should be well structured and documented
so that it is suitable for application development.
• Necessary tools for development, debugging, testing, maintenance of
a program must be provided by a programming language.
• A programming language should provide single environment known as
Integrated Development Environment(IDE).
• A programming language must be consistent in terms of syntax and
semantics
14
1.4 Language Translators
• Language Translators Convert Programming source code into language
that the computer processor understands.
• Programming language has many structures but the computer
understands only machine language.
• Language Translators are of three types:✓ Assembler
✓ Compiler
✓ Interpreter
15
1.4.1 Assembler
• Software that translate assembly language program into it equivalent
machine language program of computer is called assembler.
• It is a Program that takes basic computer instructions & converts them
into a pattern of bits (0 & 1) that the computer runs to produce result
• The output of the assembler program is called the object code, which
is usually a machine code.
16
1.4.2 Compiler
• A Compiler is a program that translates a program written in High Level
Language into machine language.
• Compiler identify the variables used in the instructions and allocate
memory.
• It also generate error messages, if there are errors in the program.
• After every thing is clear, it then compile the program into machine
code.
• Compiler simply translates the entire source code into executable
instructions that a computer can understand, it compiles code and it
produce in exe format before it run and is not involved in its execution.
17
Cont . . . Compiler
1.4.2 Compiler
• There are two stages of compiler :• Intermediate Compilation
✓ Intermediate level compiles code in the form of Byte Code and save
for later execution without the need to re – read the source file.
• Machine code compilation.
✓ Machine code compiles source code directly into machine code
using Virtual Machines that execute code directly into machine
code.
18
Cont . . . Compiler
19
1.4.3 Interpreter
• Interpreter is closely related to a compiler, but it can’t create
executable file like compiler.
• It can convert a source code line – by – line directly into machine code.
• It is slower than compiler which translate the entire program into
executable machine code.
• Every time when the program runs, the interpreter must be present to
interpret the source code into machine code..
• Compiler simply translates the entire source program into an object
program and is not involved in its execution.
20
Cont . . . Interpreter
21
Thank You!
22
Download