0% found this document useful (0 votes)
9 views40 pages

Chapter 11 Intro To Programming - 241209 - 154644

Uploaded by

jenkehej
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)
9 views40 pages

Chapter 11 Intro To Programming - 241209 - 154644

Uploaded by

jenkehej
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
You are on page 1/ 40

PROGRAMMING

Introduction to programming
What will you learn?
Introduction to
programming

Differentiate paradigmsof Differentiate typesof


Define programming language: language translator
programming
language,
programming
paradigm Object
and Procedural Logic Compiler Interpreter Assembler
Oriented
language
translator
Learning Outcome
❑ Define programming language, programming
paradigm and language translator
❑ Differentiate paradigms of programming Language
❑ Differentiate types of language translator
Definition of program
What is computer
program?
🞑 A series of
instructions that
direct a computer
to perform task
(Discovering computer)
Definition of program
What is program?

🞑 A sequence of instruction that specifies how to


perform a computation
◼ Mathematical problem (solving a system of equations)
◼ Symbolic computation (searching & replacing text in a
document)
Definition of program
Who does write programs?

🞑 A Programmer writes programs using a


programming language
Definition of programming language
 Set of words, abbreviations, and symbols that
enables a programmer to communicates instruction
to a computer.
History of Programming languages
Types of programming language
Types of programming language
 High level language  Low level language is
is a programming a programming
language that is language that is
designed to be easy designed to be easy
for human to read for computer to run
and write
Types of programming language
Low Level language High Level Language
 Machine dependent / not  Machine independent /
portable
portable
 Each instruction usually
equates to a single machine  Each instruction typically
instruction equates to multiple machine
 Example: Machine language,
instruction.
Assembly language
 Example: Java, C++,
COBOL, Basic
Low Level Language

Machine Language
• 1st generation of programming language
• Directly recognize by the computer
• does not need to be translated
• Instructions usesa seriesof binary digits
• The coding is tediousand time consuming
• Ready for immediate execution or run
Machine Language
 Advantages  Disadvantages
🞑 ready for immediate ❑ their instructions are
execution extremely cryptic
🞑 consists of instructions and difficult to learn
that are readily ❑ programs are lengthy
understood by the ❑ machine-dependent
computer ❑ not portable
Low Level Language

Assembly Language
• 2nd generation of programming language
• Symbolic instruction codes
• Meaningful abbreviation such as A for Addition
• Usesymbolic address, meaningful name that identifies a
storage location. E.gRATErefer to storage location contains
pay rate.
• Can be difficult to be learn
• Must be converted into machine language before can execute
or run
• Translated using a translator program called assemble
Low Level Language

Assembly Language
• consists of English-like abbreviations
• Some of the instructions can be understood by
human.
• Code needs to be translated to machine language
before the computer processes it.
• Example of code
• ADD 1001010,1011010
Assembly Language
🞑 Unique to particular computer.
🞑 Easier to understand
🞑 Use mnemonics symbols. E.g. “MUL” –Multiply
Low level language: Assembly Language
 Examples :
🞑 Using assembly language, instructions
wages = rates * hours
can be written as:
LOA rate
D hour
MULT wages
STOR
Low level language: Assembly Language
 Advantages.  Disadvantages
🞑 programs are lengthy
🞑 Programs are easier to because each assembly
learn compared to language instruction
corresponds to one machine
machine language. language instruction.
❑ machine-dependent
❑ not portable
❑ Incomprehensible to
computersuntil translated
to machine language
Low level language: Assembly Language
Writing Assembly Language
High Level Language

• Instructions are written using a series of English-


like words
•Shorter program - a single instruction corresponds
to many operations at the machine level
• Easier to learn than machine or assembly language
High Level Language

High-Level Languages
Have to be converted to machine-language before
they can be executed
Machine independent – can run on different types of
computers and operating systems
Instruction are coded
Programmers use this languages to write programs
High Level Language
High-Level Languages
🞑 Have to be converted to machine-language before
they can be executed
🞑 Machine independent – can run on different types of
computers and operating systems
🞑 Instruction are coded
🞑 Programmers use this languages to write programs
High Level Language
◼ Examples : FORTRAN, COBOL, BASIC, Pascal, Ada, C and C++
High Level Language
Low level vs High level language
Low Level Language High Level Language
Machine dependent / not portable Machine Independent / portable
which means each language is which means there are mostly
impossible to run on the other used to write software which
can run on multiple platforms.
Nearer to machine language Nearer to human language
Codes are difficult to Easier to learn because it
understand and learn because nearer to human language.
it nearer to machine
language.
Low level vs High level language
Low Level Language High Level Language
Appropriate for developing new Appropriate to solve the scientific problem.
operating systems or writing firmware
codes for micro- controllers
Fast to process and return the output as it nearer Slower to process because they have lot
to machine code of abstraction and layers of code before they
can reach the hardware itself
LLis challenging and requires a great deal of High level is where all the creative things
experience and knowledge take place & can be debugged in much
easier manner than in low level
Much easier to program (shorter, easier to read) Much easier to program (shorter, easier to read)

Portable Portable
Program 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.
Paradigm of Programming Language
Procedural

Simple & straight forward code writing

Routines and subroutines

Top down, step by step instruction


Paradigm of Programming Language
Object-Oriented Program (OOP)

Approach to problem solving where all computations are carried


out using objects

Object iscomponent of a program that knowshow to perform


certain actions & how to interact with other elements of the
program

Object isBen (people), Ben can walk (method)


Paradigm of Programming Language
 Procedural  Object Oriented (OOP)
🞑 Relies on procedures, also known 🞑 Relies on object, a component of
as routines or subroutines a program that knows how to
🞑 contains a series of perform certain actions and how
computational steps to be carried to interact with other elements of
out the program
🞑 list of instructions to tell the 🞑 organize your code by creating
computer what to do step-by- objects, and then you can give
step those objects properties and you
can make them do certain things
🞑 known as top-down languages
🞑 objects also makes it possible to
🞑 Fortran, COBOL and C reuse code
Program language paradigm: Object Oriented

 Problem solving based on object (single unit).


 Based on objects and their relationship.
 Data can only changed through an object’s defined
methods. Uses concepts such as information hiding
and message passing.
 Suitable for building complex system or developing
large systems.
Comparison between language paradigm
Paradigm Advantages disadvantages
Procedural • Direct interaction between facts • Difficult to understand
• Well organized • Difficult to change
• Well structured • Sequential
Object oriented • Good structure and modularity • Not appropriate for
• Inheritance complex
• Communication between processes algorithmic
problems
Logic • Availability of inference rules • Difficult to represent
• Simple notation procedural knowledge
• Good to understand • Not well organized
• Every facts represented only once
Translator
Definition.
 a program that translates from one programming
language into another.
🞑 Interpreter
🞑 Compiler
🞑 Assemble
Translator
Interpreter readsa HL program and executes it

It processes (translates) the program a little at a time,


alternately reading lines and performing computations
Translator
Compiler reads the entire program (HLL) and translates it
completely before the program starts running

HLL program is called source code, the


translated program is called executable

Once compiled, it can execute


repeatedly without further translation
Translator: Assembler

❑ A translator that converts programs


written in assembly language to
machine code so that they can be
executed
Translator
Assembler Interpreter Compiler

• Converts • Translatesone • Translate entire


programswritten high-level source program
in assembly program into object
language to instruction at a program and
machine code so time (line by line) saves the object
that it can be into machine code program in a file
executed and immediately which is ready for
execute that code execution
Translator: Interpreter
 A translator that translates one
high-level program instruction at
a time ( line by line) into
machine code and immediately
executes that code

 JAVA, Visual Basic programming


purpose,

 required additional software (virtual


machine) to run the program
Translator: Compiler
 A translator that translates all of the
source program into object
program, and saves the object
program in a file
 (for C++ programming, will create
*.exe file)
Reflection
• Define programming language
• Differentiate between Low-level and High-level
language
• State paradigms of programming language
• Identify the functions of translators

You might also like