330 CSS-3 Programming Paradigm
Lecture 01
330 CSS-3 PROGRAMMING PARADIGMS
OBJECTIVE:
•To understand the basic building blocks of programming
Languages.
•To Learn and understand various programming paradigms.
Spring 2006/PRL 1-2
Outline
INTRODUCTION
Introducton to Computer Programming
Programming Languages
Programming Paradigms
Reasons for Studying Concepts of Programming Languages
Programming Domains
Language Evaluaton Criteria
Infuences on Language Design
1-3
Computer Programming
The functons of a computer system are controlled by computer programs
A computer program is a clear, step-by-step, fnite set of instructons
A computer program must be clear so that only one meaning can be derived
from it,
A computer program is writen in a computer language called a programming
language
programming languages are human-engineered languages developed to
convey instructons to machines
Spring 2006/PRL 1-4
Programming Languages
There are three categories of programming languages:
1. Machine languages.
2. Assembly languages.
3. High-level languages.
Machine languages and assembly languages are also called low-
level languages
Spring 2006/PRL 1-5
Programming languages
classifcations
Spring 2006/PRL 1-6
Programming Languages (cont’d)
A Machine language program consists of a sequence of
zeros and ones.
Each kind of CPU has its own machine language.
Advantages
Fast and efcient
Machine oriented
No translaton required
Disadvantages
Not portable
Not programmer friendly
Spring 2006/PRL 1-7
High-Level Programming Languages
A high-level language (HLL) has two primary
components
(1) a set of built-in language primitves and grammatcal
rules
(2) a translator
A HLL language program consists of English-like
statements that are governed by a strict syntax.
Advantages
Portable or machine independent
Programmer-friendly
Spring 2006/PRL 1-8
High-Level Programming Languages-cont
Disadvantages
Not as efcient as low-level languages
Need to be translated
Examples : C, C++, Java, FORTRAN, Visual Basic, and Delphi.
Spring 2006/PRL 1-9
Programming Paradigms
Why are there hundreds of programming languages in use today?
Some programming languages are specifcally designed for use in certain
applicatons.
Diferent programming languages follow diferent approaches to solving
programming problems
A programming paradigm is an approach to solving programming problems.
A programming paradigm may consist of many programming languages.
Common programming paradigms:
Imperatve or Procedural Programming
Object-Oriented Programming
Functonal Programming
Logic Programming
Spring 2006/PRL 1-10
Reasons for Studying Concepts of
Programming Languages
• Increased ability to express ideas
• Improved background for choosing appropriate languages
• Increased ability to learn new languages
• Beter understanding of signifcance of implementaton
• Overall advancement of computng
1-11
Programming Domains
• Scientfc applicatons
• Large number of foatng point computatons
• Fortran
• Business applicatons
• Produce reports, use decimal numbers and characters
• COBOL
• Artfcial intelligence
• Symbols rather than numbers manipulated
• LISP
• Systems programming
• Need efciency because of contnuous use
• C
• Web Sofware
• Eclectc collecton of languages: markup (e.g., XHTML), scriptng (e.g., PHP),
general-purpose (e.g., Java)
1-12
Language Evaluation Criteria
• Readability: the ease with which programs can be read and
understood
• Writability: the ease with which a language can be used to create
programs
• Reliability: conformance to specifcatons (i.e., performs to its
specifcatons)
• Cost: the ultmate total cost
1-13
Evaluation Criteria: Readability
• Overall simplicity
• A manageable set of features and constructs
• Few feature multplicity (means of doing the same operaton)
• Minimal operator overloading
• Orthogonality
• A relatvely small set of primitve constructs can be combined in a relatvely
small number of ways
• Every possible combinaton is legal
• ) Control statements
• The presence of well-known control structures (e.g., while statement
• Data types and structures
• The presence of adequate facilites for defning data structures
• Syntax consideratons
• Identfer forms: fexible compositon
• Special words and methods of forming compound statements
• Form and meaning: self-descriptve constructs, meaningful keywords
1-14
Evaluation Criteria: Writability
• Simplicity and orthogonality
• Few constructs, a small number of primitves, a small set of rules for combining
them
• Support for abstracton
• The ability to defne and use complex structures or operatons in ways that allow
details to be ignored
• Expressivity
• A set of relatvely convenient ways of specifying operatons
• Example: the inclusion of for statement in many modern languages
1-15
Evaluation Criteria: Reliability
• Type checking
• Testng for type errors
• Excepton handling
• Intercept run-tme errors and take correctve measures
• Aliasing
• Presence of two or more distnct referencing methods for the same
memory locaton
• Readability and writability
• A language that does not support “natural” ways of expressing an
algorithm will necessarily use “unnatural” approaches, and hence
reduced reliability
• Readability afects reliability in both the writng and maintenance phases
of the life cycle.
1-16
Evaluation Criteria: Cost
• Training programmers to use language
• Writng programs (closeness to partcular applicatons)
• Compiling programs
• Executng programs
• Language implementaton system: availability of free compilers
• Reliability: poor reliability leads to high costs
• Maintaining programs
1-17
Evaluation Criteria: Others
• Portability
• The ease with which programs can be moved from one implementaton to
another
• Generality
• The applicability to a wide range of applicatons
• Well-defnedness
• The completeness and precision of the language’s ofcial defniton
1-18
Why learn more than one PL?
• So you can choose the right language for a given
problem
– If all you have is a hammer, every problem looks like a
nail.
• So you can learn a new language more easily later
– As your job changes, you may need to used diferent
languages
– As our understanding of programming improves, new
languages are created
• To learn new ways of thinking about problems
– Diferent languages encourage you to think about
problems in diferent ways “Paradigms”
Spring 2006/PRL 1-19
Paradigms of Programming?
• There are several ways to think about
computaton:
– a set of instructons to be executed
– a set of expressions to be evaluated
– a set of rules to be applied
– a set of objects to be arranged
– a set of messages to be sent and received
Spring 2006/PRL 1-20
Influences on Language Design
• Computer Architecture
• Languages are developed around the prevalent computer architecture,
known as the von Neumann architecture
• Programming Methodologies
• New sofware development methodologies (e.g., object-oriented sofware
development) led to new programming paradigms and by extension, new
programming languages
1-21