SlideShare a Scribd company logo
1 of 42
Chapter 6
Programming
Languages
© 2007 Pearson Addison-Wesley.
All rights reserved
© 2007 Pearson Addison-Wesley. All
rights reserved 0-2
Chapter 6: Programming
Languages
• 6.1 Historical Perspective
• 6.2 Traditional Programming Concepts
• 6.3 Procedural Units
• 6.4 Language Implementation
• 6.5 Object Oriented Programming
• 6.6 Programming Concurrent Activities
• 6.7 Declarative Programming
© 2007 Pearson Addison-Wesley. All
rights reserved 0-3
Figure 6.1 Generations of
programming languages
© 2007 Pearson Addison-Wesley. All
rights reserved 0-4
Second-generation:
Assembly language
• A mnemonic system for representing machine
instructions
– Mnemonic names for op-codes
– Identifiers: Descriptive names for memory
locations, chosen by the programmer
© 2007 Pearson Addison-Wesley. All
rights reserved 0-5
Assembly Language
Characteristics
• One-to-one correspondence between machine
instructions and assembly instructions
– Programmer must think like the machine
• Inherently machine-dependent
• Converted to machine language by a program
called an assembler
© 2007 Pearson Addison-Wesley. All
rights reserved 0-6
Program Example
Machine language
156C
166D
5056
30CE
C000
Assembly language
LD R5, Price
LD R6, ShippingCharge
ADDI R0, R5 R6
ST R0, TotalCost
HLT
© 2007 Pearson Addison-Wesley. All
rights reserved 0-7
Third Generation Language
• Uses high-level primitives
– Similar to our pseudocode in Chapter 5
• Machine independent (mostly)
• Examples: FORTRAN, COBOL
• Each primitive corresponds to a sequence of
machine language instructions
• Converted to machine language by a program
called a compiler
© 2007 Pearson Addison-Wesley. All
rights reserved 0-8
Figure 6.2 The evolution of
programming paradigms
© 2007 Pearson Addison-Wesley. All
rights reserved 0-9
Figure 6.3 A function for checkbook
balancing constructed from simpler
functions
© 2007 Pearson Addison-Wesley. All
rights reserved 0-10
Figure 6.4 The composition of a
typical imperative program or
program unit
© 2007 Pearson Addison-Wesley. All
rights reserved 0-11
Data Types
• Integer: Whole numbers
• Real (float): Numbers with fractions
• Character: Symbols
• Boolean: True/false
© 2007 Pearson Addison-Wesley. All
rights reserved 0-12
Variable Declarations
float Length, Width;
int Price, Total, Tax;
char Symbol;
© 2007 Pearson Addison-Wesley. All
rights reserved 0-13
Figure 6.5 A two-dimensional
array with two rows and nine
columns
© 2007 Pearson Addison-Wesley. All
rights reserved 0-14
Figure 6.6 The conceptual structure
of the heterogeneous array Employee
Figure 6.7
Control
structures
and their
representations
in C, C++, C#,
and Java
© 2007 Pearson Addison-Wesley. All
rights reserved 0-16
Figure 6.8 The for loop structure
and its representation in C++, C#,
and Java
© 2007 Pearson Addison-Wesley. All
rights reserved 0-17
Procedural Units
• Local versus Global Variables
• Formal versus Actual Parameters
• Passing parameters by value versus reference
• Procedures versus Functions
© 2007 Pearson Addison-Wesley. All
rights reserved 0-18
Figure 6.9 The flow of control
involving a procedure
© 2007 Pearson Addison-Wesley. All
rights reserved 0-19
Figure 6.10 The procedure
ProjectPopulation written in the
programming language C
Figure 6.11
Executing the
procedure Demo
and passing
parameters by
value
Figure 6.12
Executing the
procedure Demo
and passing
parameters by
reference
© 2007 Pearson Addison-Wesley. All
rights reserved 0-22
Figure 6.13 The function
CylinderVolume written in the
programming language C
© 2007 Pearson Addison-Wesley. All
rights reserved 0-23
Figure 6.14 The translation
process
© 2007 Pearson Addison-Wesley. All
rights reserved 0-24
Figure 6.15 A syntax diagram
of our if-then-else pseudocode
statement
© 2007 Pearson Addison-Wesley. All
rights reserved 0-25
Figure 6.16 Syntax diagrams
describing the structure of a simple
algebraic expression
© 2007 Pearson Addison-Wesley. All
rights reserved 0-26
Figure 6.17 The parse tree for
the string x + y x z based on the
syntax diagrams in Figure 6.17
Figure 6.18
Two distinct
parse trees for
the statement
if B1 then if B2
then S1 else S2
© 2007 Pearson Addison-Wesley. All
rights reserved 0-28
Figure 6.19 An object-oriented
approach to the translation
process
© 2007 Pearson Addison-Wesley. All
rights reserved 0-29
Objects and Classes
• Object: Active program unit containing both
data and procedures
• Class: A template from which objects are
constructed
An object is called an instance of the class.
© 2007 Pearson Addison-Wesley. All
rights reserved 0-30
Figure 6.20 The structure of a
class describing a laser weapon in
a computer game
© 2007 Pearson Addison-Wesley. All
rights reserved 0-31
Components of an Object
• Instance Variable: Variable within an object
– Holds information within the object
• Method: Procedure within an object
– Describes the actions that the object can perform
• Constructor: Special method used to initialize
a new object when it is first constructed
© 2007 Pearson Addison-Wesley. All
rights reserved 0-32
Figure 6.21 A class with a
constructor
© 2007 Pearson Addison-Wesley. All
rights reserved 0-33
Object Integrity
• Encapsulation: A way of restricting access to
the internal components of an object
– Private versus public
© 2007 Pearson Addison-Wesley. All
rights reserved 0-34
Figure 6.22 Our LaserClass definition
using encapsulation
© 2007 Pearson Addison-Wesley. All
rights reserved 0-35
Additional Object-oriented
Concepts
• Inheritance: Allows new classes to be defined
in terms of previously defined classes
• Polymorphism: Allows method calls to be
interpreted by the object that receives the call
© 2007 Pearson Addison-Wesley. All
rights reserved 0-36
Programming Concurrent Activities
• Parallel (or concurrent) processing:
simultaneous execution of multiple processes
– True concurrent processing requires multiple CPUs
– Can be simulated using time-sharing with a single
CPU
© 2007 Pearson Addison-Wesley. All
rights reserved 0-37
Figure 6.23 Spawning threads
© 2007 Pearson Addison-Wesley. All
rights reserved 0-38
Controlling Access to Data
• Mutual Exclusion: A method for ensuring that
data can be accessed by only one process at a
time
• Monitor: A data item augmented with the
ability to control access to itself
© 2007 Pearson Addison-Wesley. All
rights reserved 0-39
Declarative Programming
• Resolution: Combining two or more statements to
produce a new statement (that is a logical consequence
of the originals).
– Example: (P OR Q) AND (R OR ¬Q)
resolves to (P OR R)
– Resolvent: A new statement deduced by resolution
– Clause form: A statement whose elementary components
are connected by the Boolean operation OR
• Unification: Assigning a value to a variable so that
two statements become “compatible.”
© 2007 Pearson Addison-Wesley. All
rights reserved 0-40
Figure 6.24 Resolving the statements
(P OR Q) and (R OR ¬Q) to produce
(P OR R)
© 2007 Pearson Addison-Wesley. All
rights reserved 0-41
Figure 6.25 Resolving the
statements (P OR Q), (R OR ¬Q),
¬R, and ¬P
© 2007 Pearson Addison-Wesley. All
rights reserved 0-42
Prolog
• Fact: A Prolog statement establishing a fact
– Consists of a single predicate
– Form: predicateName(arguments).
• Example: parent(bill, mary).
• Rule: A Prolog statement establishing a general rule
– Form: conclusion :- premise.
• :- means “if”
– Example: wise(X) :- old(X).
– Example: faster(X,Z) :- faster(X,Y), faster(Y,Z).

More Related Content

Viewers also liked

booting steps of a computer
booting steps of a computerbooting steps of a computer
booting steps of a computerAnusha Babooa
 
What Makes Great Infographics
What Makes Great InfographicsWhat Makes Great Infographics
What Makes Great InfographicsSlideShare
 
STOP! VIEW THIS! 10-Step Checklist When Uploading to Slideshare
STOP! VIEW THIS! 10-Step Checklist When Uploading to SlideshareSTOP! VIEW THIS! 10-Step Checklist When Uploading to Slideshare
STOP! VIEW THIS! 10-Step Checklist When Uploading to SlideshareEmpowered Presentations
 
How To Get More From SlideShare - Super-Simple Tips For Content Marketing
How To Get More From SlideShare - Super-Simple Tips For Content MarketingHow To Get More From SlideShare - Super-Simple Tips For Content Marketing
How To Get More From SlideShare - Super-Simple Tips For Content MarketingContent Marketing Institute
 
Masters of SlideShare
Masters of SlideShareMasters of SlideShare
Masters of SlideShareKapost
 
10 Ways to Win at SlideShare SEO & Presentation Optimization
10 Ways to Win at SlideShare SEO & Presentation Optimization10 Ways to Win at SlideShare SEO & Presentation Optimization
10 Ways to Win at SlideShare SEO & Presentation OptimizationOneupweb
 
How to Make Awesome SlideShares: Tips & Tricks
How to Make Awesome SlideShares: Tips & TricksHow to Make Awesome SlideShares: Tips & Tricks
How to Make Awesome SlideShares: Tips & TricksSlideShare
 

Viewers also liked (8)

booting steps of a computer
booting steps of a computerbooting steps of a computer
booting steps of a computer
 
What Makes Great Infographics
What Makes Great InfographicsWhat Makes Great Infographics
What Makes Great Infographics
 
You Suck At PowerPoint!
You Suck At PowerPoint!You Suck At PowerPoint!
You Suck At PowerPoint!
 
STOP! VIEW THIS! 10-Step Checklist When Uploading to Slideshare
STOP! VIEW THIS! 10-Step Checklist When Uploading to SlideshareSTOP! VIEW THIS! 10-Step Checklist When Uploading to Slideshare
STOP! VIEW THIS! 10-Step Checklist When Uploading to Slideshare
 
How To Get More From SlideShare - Super-Simple Tips For Content Marketing
How To Get More From SlideShare - Super-Simple Tips For Content MarketingHow To Get More From SlideShare - Super-Simple Tips For Content Marketing
How To Get More From SlideShare - Super-Simple Tips For Content Marketing
 
Masters of SlideShare
Masters of SlideShareMasters of SlideShare
Masters of SlideShare
 
10 Ways to Win at SlideShare SEO & Presentation Optimization
10 Ways to Win at SlideShare SEO & Presentation Optimization10 Ways to Win at SlideShare SEO & Presentation Optimization
10 Ways to Win at SlideShare SEO & Presentation Optimization
 
How to Make Awesome SlideShares: Tips & Tricks
How to Make Awesome SlideShares: Tips & TricksHow to Make Awesome SlideShares: Tips & Tricks
How to Make Awesome SlideShares: Tips & Tricks
 

Similar to Programming Languages Chapter

Cs ch00
Cs ch00Cs ch00
Cs ch00-
 
Systems Biology Software Infrastructure overview
Systems Biology Software Infrastructure overviewSystems Biology Software Infrastructure overview
Systems Biology Software Infrastructure overviewRichard Adams
 
NoSQL and Spatial Database Capabilities using PostgreSQL
NoSQL and Spatial Database Capabilities using PostgreSQLNoSQL and Spatial Database Capabilities using PostgreSQL
NoSQL and Spatial Database Capabilities using PostgreSQLEDB
 
Oracle DV V4 new features overview
Oracle DV V4 new features overviewOracle DV V4 new features overview
Oracle DV V4 new features overviewPhilippe Lions
 
Cost-based query optimization in Apache Hive 0.14
Cost-based query optimization in Apache Hive 0.14Cost-based query optimization in Apache Hive 0.14
Cost-based query optimization in Apache Hive 0.14Julian Hyde
 
Cso gaddis java_chapter6
Cso gaddis java_chapter6Cso gaddis java_chapter6
Cso gaddis java_chapter6RhettB
 
Power BI with Essbase in the Oracle Cloud
Power BI with Essbase in the Oracle CloudPower BI with Essbase in the Oracle Cloud
Power BI with Essbase in the Oracle CloudKellyn Pot'Vin-Gorman
 
BI Portfolio
BI PortfolioBI Portfolio
BI Portfoliosprigge
 
SAP BI/DW Training with BO Integration
SAP BI/DW Training with BO IntegrationSAP BI/DW Training with BO Integration
SAP BI/DW Training with BO Integrationmishra4927
 
Business Intelligence Portfolio
Business Intelligence PortfolioBusiness Intelligence Portfolio
Business Intelligence Portfoliopleeloy
 
Generalized framework for using NoSQL Databases
Generalized framework for using NoSQL DatabasesGeneralized framework for using NoSQL Databases
Generalized framework for using NoSQL DatabasesKIRAN V
 
Building N Tier Applications With Entity Framework Services 2010
Building N Tier Applications With Entity Framework Services 2010Building N Tier Applications With Entity Framework Services 2010
Building N Tier Applications With Entity Framework Services 2010David McCarter
 
Team2 final project_presentation
Team2 final project_presentationTeam2 final project_presentation
Team2 final project_presentationNishtha Adroja
 
SHACL-based data life cycle management
SHACL-based data life cycle managementSHACL-based data life cycle management
SHACL-based data life cycle managementConnected Data World
 
Hadoop Big Data Resume
Hadoop Big Data ResumeHadoop Big Data Resume
Hadoop Big Data Resumearbind_jha
 

Similar to Programming Languages Chapter (20)

Brookshear 06
Brookshear 06Brookshear 06
Brookshear 06
 
Cs ch00
Cs ch00Cs ch00
Cs ch00
 
Systems Biology Software Infrastructure overview
Systems Biology Software Infrastructure overviewSystems Biology Software Infrastructure overview
Systems Biology Software Infrastructure overview
 
NoSQL and Spatial Database Capabilities using PostgreSQL
NoSQL and Spatial Database Capabilities using PostgreSQLNoSQL and Spatial Database Capabilities using PostgreSQL
NoSQL and Spatial Database Capabilities using PostgreSQL
 
Oracle DV V4 new features overview
Oracle DV V4 new features overviewOracle DV V4 new features overview
Oracle DV V4 new features overview
 
Cost-based query optimization in Apache Hive 0.14
Cost-based query optimization in Apache Hive 0.14Cost-based query optimization in Apache Hive 0.14
Cost-based query optimization in Apache Hive 0.14
 
Cso gaddis java_chapter6
Cso gaddis java_chapter6Cso gaddis java_chapter6
Cso gaddis java_chapter6
 
AUTODESK 2017
AUTODESK 2017 AUTODESK 2017
AUTODESK 2017
 
Power BI with Essbase in the Oracle Cloud
Power BI with Essbase in the Oracle CloudPower BI with Essbase in the Oracle Cloud
Power BI with Essbase in the Oracle Cloud
 
BI Portfolio
BI PortfolioBI Portfolio
BI Portfolio
 
BI Portfolio
BI PortfolioBI Portfolio
BI Portfolio
 
SAP BI/DW Training with BO Integration
SAP BI/DW Training with BO IntegrationSAP BI/DW Training with BO Integration
SAP BI/DW Training with BO Integration
 
Resume
ResumeResume
Resume
 
Business Intelligence Portfolio
Business Intelligence PortfolioBusiness Intelligence Portfolio
Business Intelligence Portfolio
 
Resume_eng
Resume_engResume_eng
Resume_eng
 
Generalized framework for using NoSQL Databases
Generalized framework for using NoSQL DatabasesGeneralized framework for using NoSQL Databases
Generalized framework for using NoSQL Databases
 
Building N Tier Applications With Entity Framework Services 2010
Building N Tier Applications With Entity Framework Services 2010Building N Tier Applications With Entity Framework Services 2010
Building N Tier Applications With Entity Framework Services 2010
 
Team2 final project_presentation
Team2 final project_presentationTeam2 final project_presentation
Team2 final project_presentation
 
SHACL-based data life cycle management
SHACL-based data life cycle managementSHACL-based data life cycle management
SHACL-based data life cycle management
 
Hadoop Big Data Resume
Hadoop Big Data ResumeHadoop Big Data Resume
Hadoop Big Data Resume
 

More from -

Introduction to computer (shaheen)
Introduction to computer (shaheen)Introduction to computer (shaheen)
Introduction to computer (shaheen)-
 
Introduction to computer (boys scout)
Introduction to computer (boys scout)Introduction to computer (boys scout)
Introduction to computer (boys scout)-
 
Hci with emotional intelligence
Hci with emotional intelligenceHci with emotional intelligence
Hci with emotional intelligence-
 
Surf smart
Surf smartSurf smart
Surf smart-
 
Planning presentation
Planning presentationPlanning presentation
Planning presentation-
 
Cultural enviroment
Cultural enviromentCultural enviroment
Cultural enviroment-
 
Quantitative approach
Quantitative approachQuantitative approach
Quantitative approach-
 
Project vlm (al halal meat factory)
Project vlm (al halal meat factory)Project vlm (al halal meat factory)
Project vlm (al halal meat factory)-
 
Cs ch04
Cs ch04Cs ch04
Cs ch04-
 
Cs ch02
Cs ch02Cs ch02
Cs ch02-
 

More from - (10)

Introduction to computer (shaheen)
Introduction to computer (shaheen)Introduction to computer (shaheen)
Introduction to computer (shaheen)
 
Introduction to computer (boys scout)
Introduction to computer (boys scout)Introduction to computer (boys scout)
Introduction to computer (boys scout)
 
Hci with emotional intelligence
Hci with emotional intelligenceHci with emotional intelligence
Hci with emotional intelligence
 
Surf smart
Surf smartSurf smart
Surf smart
 
Planning presentation
Planning presentationPlanning presentation
Planning presentation
 
Cultural enviroment
Cultural enviromentCultural enviroment
Cultural enviroment
 
Quantitative approach
Quantitative approachQuantitative approach
Quantitative approach
 
Project vlm (al halal meat factory)
Project vlm (al halal meat factory)Project vlm (al halal meat factory)
Project vlm (al halal meat factory)
 
Cs ch04
Cs ch04Cs ch04
Cs ch04
 
Cs ch02
Cs ch02Cs ch02
Cs ch02
 

Recently uploaded

FULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | Delhi
FULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | DelhiFULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | Delhi
FULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | Delhisoniya singh
 
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024BookNet Canada
 
Swan(sea) Song – personal research during my six years at Swansea ... and bey...
Swan(sea) Song – personal research during my six years at Swansea ... and bey...Swan(sea) Song – personal research during my six years at Swansea ... and bey...
Swan(sea) Song – personal research during my six years at Swansea ... and bey...Alan Dix
 
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptxHampshireHUG
 
Data Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonData Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonAnna Loughnan Colquhoun
 
Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...
Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...
Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...gurkirankumar98700
 
08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking MenDelhi Call girls
 
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...shyamraj55
 
Enhancing Worker Digital Experience: A Hands-on Workshop for Partners
Enhancing Worker Digital Experience: A Hands-on Workshop for PartnersEnhancing Worker Digital Experience: A Hands-on Workshop for Partners
Enhancing Worker Digital Experience: A Hands-on Workshop for PartnersThousandEyes
 
SQL Database Design For Developers at php[tek] 2024
SQL Database Design For Developers at php[tek] 2024SQL Database Design For Developers at php[tek] 2024
SQL Database Design For Developers at php[tek] 2024Scott Keck-Warren
 
Salesforce Community Group Quito, Salesforce 101
Salesforce Community Group Quito, Salesforce 101Salesforce Community Group Quito, Salesforce 101
Salesforce Community Group Quito, Salesforce 101Paola De la Torre
 
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdfThe Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdfEnterprise Knowledge
 
My Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 PresentationMy Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 PresentationRidwan Fadjar
 
The Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptxThe Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptxMalak Abu Hammad
 
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...Igalia
 
[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdfhans926745
 
GenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationGenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationMichael W. Hawkins
 
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking MenDelhi Call girls
 
Understanding the Laravel MVC Architecture
Understanding the Laravel MVC ArchitectureUnderstanding the Laravel MVC Architecture
Understanding the Laravel MVC ArchitecturePixlogix Infotech
 
A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)Gabriella Davis
 

Recently uploaded (20)

FULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | Delhi
FULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | DelhiFULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | Delhi
FULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | Delhi
 
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
 
Swan(sea) Song – personal research during my six years at Swansea ... and bey...
Swan(sea) Song – personal research during my six years at Swansea ... and bey...Swan(sea) Song – personal research during my six years at Swansea ... and bey...
Swan(sea) Song – personal research during my six years at Swansea ... and bey...
 
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
 
Data Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonData Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt Robison
 
Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...
Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...
Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...
 
08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men
 
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
 
Enhancing Worker Digital Experience: A Hands-on Workshop for Partners
Enhancing Worker Digital Experience: A Hands-on Workshop for PartnersEnhancing Worker Digital Experience: A Hands-on Workshop for Partners
Enhancing Worker Digital Experience: A Hands-on Workshop for Partners
 
SQL Database Design For Developers at php[tek] 2024
SQL Database Design For Developers at php[tek] 2024SQL Database Design For Developers at php[tek] 2024
SQL Database Design For Developers at php[tek] 2024
 
Salesforce Community Group Quito, Salesforce 101
Salesforce Community Group Quito, Salesforce 101Salesforce Community Group Quito, Salesforce 101
Salesforce Community Group Quito, Salesforce 101
 
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdfThe Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
 
My Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 PresentationMy Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 Presentation
 
The Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptxThe Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptx
 
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
 
[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf
 
GenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationGenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day Presentation
 
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
 
Understanding the Laravel MVC Architecture
Understanding the Laravel MVC ArchitectureUnderstanding the Laravel MVC Architecture
Understanding the Laravel MVC Architecture
 
A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)
 

Programming Languages Chapter

  • 1. Chapter 6 Programming Languages © 2007 Pearson Addison-Wesley. All rights reserved
  • 2. © 2007 Pearson Addison-Wesley. All rights reserved 0-2 Chapter 6: Programming Languages • 6.1 Historical Perspective • 6.2 Traditional Programming Concepts • 6.3 Procedural Units • 6.4 Language Implementation • 6.5 Object Oriented Programming • 6.6 Programming Concurrent Activities • 6.7 Declarative Programming
  • 3. © 2007 Pearson Addison-Wesley. All rights reserved 0-3 Figure 6.1 Generations of programming languages
  • 4. © 2007 Pearson Addison-Wesley. All rights reserved 0-4 Second-generation: Assembly language • A mnemonic system for representing machine instructions – Mnemonic names for op-codes – Identifiers: Descriptive names for memory locations, chosen by the programmer
  • 5. © 2007 Pearson Addison-Wesley. All rights reserved 0-5 Assembly Language Characteristics • One-to-one correspondence between machine instructions and assembly instructions – Programmer must think like the machine • Inherently machine-dependent • Converted to machine language by a program called an assembler
  • 6. © 2007 Pearson Addison-Wesley. All rights reserved 0-6 Program Example Machine language 156C 166D 5056 30CE C000 Assembly language LD R5, Price LD R6, ShippingCharge ADDI R0, R5 R6 ST R0, TotalCost HLT
  • 7. © 2007 Pearson Addison-Wesley. All rights reserved 0-7 Third Generation Language • Uses high-level primitives – Similar to our pseudocode in Chapter 5 • Machine independent (mostly) • Examples: FORTRAN, COBOL • Each primitive corresponds to a sequence of machine language instructions • Converted to machine language by a program called a compiler
  • 8. © 2007 Pearson Addison-Wesley. All rights reserved 0-8 Figure 6.2 The evolution of programming paradigms
  • 9. © 2007 Pearson Addison-Wesley. All rights reserved 0-9 Figure 6.3 A function for checkbook balancing constructed from simpler functions
  • 10. © 2007 Pearson Addison-Wesley. All rights reserved 0-10 Figure 6.4 The composition of a typical imperative program or program unit
  • 11. © 2007 Pearson Addison-Wesley. All rights reserved 0-11 Data Types • Integer: Whole numbers • Real (float): Numbers with fractions • Character: Symbols • Boolean: True/false
  • 12. © 2007 Pearson Addison-Wesley. All rights reserved 0-12 Variable Declarations float Length, Width; int Price, Total, Tax; char Symbol;
  • 13. © 2007 Pearson Addison-Wesley. All rights reserved 0-13 Figure 6.5 A two-dimensional array with two rows and nine columns
  • 14. © 2007 Pearson Addison-Wesley. All rights reserved 0-14 Figure 6.6 The conceptual structure of the heterogeneous array Employee
  • 16. © 2007 Pearson Addison-Wesley. All rights reserved 0-16 Figure 6.8 The for loop structure and its representation in C++, C#, and Java
  • 17. © 2007 Pearson Addison-Wesley. All rights reserved 0-17 Procedural Units • Local versus Global Variables • Formal versus Actual Parameters • Passing parameters by value versus reference • Procedures versus Functions
  • 18. © 2007 Pearson Addison-Wesley. All rights reserved 0-18 Figure 6.9 The flow of control involving a procedure
  • 19. © 2007 Pearson Addison-Wesley. All rights reserved 0-19 Figure 6.10 The procedure ProjectPopulation written in the programming language C
  • 20. Figure 6.11 Executing the procedure Demo and passing parameters by value
  • 21. Figure 6.12 Executing the procedure Demo and passing parameters by reference
  • 22. © 2007 Pearson Addison-Wesley. All rights reserved 0-22 Figure 6.13 The function CylinderVolume written in the programming language C
  • 23. © 2007 Pearson Addison-Wesley. All rights reserved 0-23 Figure 6.14 The translation process
  • 24. © 2007 Pearson Addison-Wesley. All rights reserved 0-24 Figure 6.15 A syntax diagram of our if-then-else pseudocode statement
  • 25. © 2007 Pearson Addison-Wesley. All rights reserved 0-25 Figure 6.16 Syntax diagrams describing the structure of a simple algebraic expression
  • 26. © 2007 Pearson Addison-Wesley. All rights reserved 0-26 Figure 6.17 The parse tree for the string x + y x z based on the syntax diagrams in Figure 6.17
  • 27. Figure 6.18 Two distinct parse trees for the statement if B1 then if B2 then S1 else S2
  • 28. © 2007 Pearson Addison-Wesley. All rights reserved 0-28 Figure 6.19 An object-oriented approach to the translation process
  • 29. © 2007 Pearson Addison-Wesley. All rights reserved 0-29 Objects and Classes • Object: Active program unit containing both data and procedures • Class: A template from which objects are constructed An object is called an instance of the class.
  • 30. © 2007 Pearson Addison-Wesley. All rights reserved 0-30 Figure 6.20 The structure of a class describing a laser weapon in a computer game
  • 31. © 2007 Pearson Addison-Wesley. All rights reserved 0-31 Components of an Object • Instance Variable: Variable within an object – Holds information within the object • Method: Procedure within an object – Describes the actions that the object can perform • Constructor: Special method used to initialize a new object when it is first constructed
  • 32. © 2007 Pearson Addison-Wesley. All rights reserved 0-32 Figure 6.21 A class with a constructor
  • 33. © 2007 Pearson Addison-Wesley. All rights reserved 0-33 Object Integrity • Encapsulation: A way of restricting access to the internal components of an object – Private versus public
  • 34. © 2007 Pearson Addison-Wesley. All rights reserved 0-34 Figure 6.22 Our LaserClass definition using encapsulation
  • 35. © 2007 Pearson Addison-Wesley. All rights reserved 0-35 Additional Object-oriented Concepts • Inheritance: Allows new classes to be defined in terms of previously defined classes • Polymorphism: Allows method calls to be interpreted by the object that receives the call
  • 36. © 2007 Pearson Addison-Wesley. All rights reserved 0-36 Programming Concurrent Activities • Parallel (or concurrent) processing: simultaneous execution of multiple processes – True concurrent processing requires multiple CPUs – Can be simulated using time-sharing with a single CPU
  • 37. © 2007 Pearson Addison-Wesley. All rights reserved 0-37 Figure 6.23 Spawning threads
  • 38. © 2007 Pearson Addison-Wesley. All rights reserved 0-38 Controlling Access to Data • Mutual Exclusion: A method for ensuring that data can be accessed by only one process at a time • Monitor: A data item augmented with the ability to control access to itself
  • 39. © 2007 Pearson Addison-Wesley. All rights reserved 0-39 Declarative Programming • Resolution: Combining two or more statements to produce a new statement (that is a logical consequence of the originals). – Example: (P OR Q) AND (R OR ¬Q) resolves to (P OR R) – Resolvent: A new statement deduced by resolution – Clause form: A statement whose elementary components are connected by the Boolean operation OR • Unification: Assigning a value to a variable so that two statements become “compatible.”
  • 40. © 2007 Pearson Addison-Wesley. All rights reserved 0-40 Figure 6.24 Resolving the statements (P OR Q) and (R OR ¬Q) to produce (P OR R)
  • 41. © 2007 Pearson Addison-Wesley. All rights reserved 0-41 Figure 6.25 Resolving the statements (P OR Q), (R OR ¬Q), ¬R, and ¬P
  • 42. © 2007 Pearson Addison-Wesley. All rights reserved 0-42 Prolog • Fact: A Prolog statement establishing a fact – Consists of a single predicate – Form: predicateName(arguments). • Example: parent(bill, mary). • Rule: A Prolog statement establishing a general rule – Form: conclusion :- premise. • :- means “if” – Example: wise(X) :- old(X). – Example: faster(X,Z) :- faster(X,Y), faster(Y,Z).