meljun cortes -programming criteria

22
Language Evaluation Criteria of C++ Programming Language 1. Readability – easily understood? 2. Writability – easy to write? 3. Simplicity, orthogonality 4. High expressive power, flexibility 5. Reliability 6. Safety 7. Cost (influenced by above) – Creation – Execution – Maintenance

Upload: meljun-cortes

Post on 22-May-2015

190 views

Category:

Documents


0 download

DESCRIPTION

MELJUN CORTES -Programming Criteria

TRANSCRIPT

Page 1: MELJUN CORTES -Programming Criteria

Language Evaluation Criteria of C++ Programming Language

1 Readability ndash easily understood2 Writability ndash easy to write3 Simplicity orthogonality4 High expressive power flexibility5 Reliability6 Safety7 Cost (influenced by above)

ndash Creationndash Executionndash Maintenance

Cost of Software

bull Total cost - due to many language factorsndash Training programmers (time)ndash Developing software and environment (ease of use time)ndash Compiling programs (time space)ndash Executing programs (time space)ndash Language implementation system (interpreter compiler)ndash Reliability (failures per time unit)ndash Maintenance (time to fix bugs keep current with new

hardwaresoftware)ndash Extensibilityneed for modification (ease time)

Costs over the Software Lifecycle(Generic model)

1 Requirements2 Specifications3 Design4 Module coding5 Module testing6 Module Integration7 Maintenance8 Retirement

Relative Cost of 25Each Phase of Software Development

bull Maintenance constitutes 67 of total cost From Software Engineering

Specification(analysis)

5Requirements

2

Desine6

Modulecoding 5

ModuleTesting

7

Integration8

Maintenance67

Cost to Fix a Fault vs Development Phase

Readability of C++

bull Code easyfast - to read and understandbull Language factors that affect readability

1 Overall language simplicity 2 Orthogonality3 Control statements built-in4 Data types amp structures built-in5 Syntax considerations ndash closeness to natural

language andor mathematics

Writability of C++ndash Ease of Writing Programs

bull Easespeed - to create programs solving problems in a specific problem domain

bull Language factors that affect writability1 Simplicity and orthogonality2 Support for abstraction3 Expressive power4 DevelopmentComputer Aided Software

Engineering (CASE) environmentsbull Cryptic vs wordy syntax

Simplicity Improves ReadWritability

bull A large language takes more time to learnndash Programmers might learn only a subset

bull Feature multiplicity (having more than one way to perform a particular operation) is often confusingndash For example in C++ or Java you can decrement a variable in

four different ways x = x ndash 1 x -= 1 x-- --xbull Operator overloading (a single operator symbol has more

than one meaning) can lead to confusionbull Some languages (eg assembly languages) can be too

simple ndash too low level 2 3 4 5 or more statements needed to have the effect of 1 statement in a high-level language

Orthogonality

bull In geometry orthogonal means involving right angles

bull In general use it means being independent non-redundant non-overlapping or not related

bull In computer languages it means a construct can be used without consideration as to how its use will affect something else

bull A programming language is considered orthogonal if its features can be used without thinking about how their use will affect other features eg objects and arrays

Orthogonality Improves ReadWritability

bull Having fewer constructs and having few exceptions increases readability and writability

bull Orthogonal languages are easier to learnbull Examples

ndash Pointers should be able to point to any type of variable or data structurebull Exceptions (eg in C) are due to a lack of orthogonality

ndash ADD op1 op2 1048774 op1 vsndash ADDR Reg1 Reg2 1048774 Reg1 andndash ADDRM Reg1 MemA 1048774 Reg1ndash A different ADD operation depending on operand location in memory

bull However if a language is too orthogonal an inexperienced programmer might assume they can do something that makes no sensendash eg add two pointers together

Structured Control Improves ReadWritability

bull goto statements were replaced by structured programming in the 1970s

bull Can be read from top to bottomndash Most languages now contain sufficient control

statements making gotorsquos unnecessarybull The following are equivalent

if (x lt y) x++ if (x lt y) goto L1 else y++ y++ goto L2 L1 x++ L2

Concise Data StructuresTypesImprove ReadWritability

bull Adequate data types and data structures also aid readability

bull A language with Boolean types is easier to read than one withoutndash indicatorFlag = 0

is more difficult to read thanndash indicatorFlag = false

Syntax and ReadWrite-ability

bull Syntax - the way linguistic elements (eg words) are put together to form phrases or clausessentences

bull Identifier formsndash If too short reduces readability

bull Special word usendash Ada has end if and end loop while Java uses for

bothndash In Fortran 95 Do and End can also be variable names

bull Form and meaningndash In C static changes meaning depending on position

Abstraction

bull The ability to define and then use complex structures or operationsndash Allows details to be ignoredndash Allows code to be re-used instead of repeatedndash Example A binary tree in Fortran 77 required arrays while

in OO languages nodes with pointers may be used1 Abstract data typesndash implementation details are separated from the interface

allowing them to be changed without re-writing all code2 Objects3 Subprograms

Abstraction Increases Expressivity

bull Expressive language - has powerful built-in primitives for high-level abstractions

bull For example in Lispndash Pointer manipulation is implicit ndash avoid mistakesndash Mapcar ndash apply a function to every element of a list (and

return the corresponding results in a list)bull No need to write the iteration yourself ndash you would need to write

a different function for each different type of databull Infinite precision integers and rational numbersndash No need to develop functions yourselfndash Completely avoid round-off errors at will

bull Eg 23 + 13 = 1 not 999999

Reliability

bull A reliable program performs to its specifications under all conditions

bull Factors that affect reliability1 Type checking2 Exception handling3 Aliasing4 Readability and writability5 Environmental factors ndash real-time or safety-

critical application

Type Checking and Exception HandlingImprove Reliability

bull Type checkingndash Testing for type errors in a given programbull For example if a function is expecting an integer

receives a float instead

bull Exception handlingndash Used in Ada C++ Lisp and Java but not in C and

Fortranbull Eg the try and catch blocks of C++ can catch runtime

errors fix the problem and then continue the program without an ldquoabnormal endrdquo

Aliasing Reduces Readabilityand Reliability

bull Aliasingndash Referencing the same memory cell with more than

one namebull Eg in C both x and y can be used to refer to the same

memory cellint x = 5int y = ampx

ndash Leads to errorsbull Reliability increases with better readwritabilityndash If a program is difficult to read or write its easier to

make mistakes and more difficult to find them

Language Design Trade-offs

bull Reliability and cost ndash costs more to ensure greater reliabilityndash Example ndash type checkingbull In C the index ranges of arrays are not checkedbull So executes fast but it not so reliablebull On the other hand Java checks all references to array

elementsbull Java executes slower but is more reliable

Lecture Questions

bull What are 5 criteria used to evaluate languages

12345

Lecture Questions (cont)

bull How do think each of these affect software costndash Readabilityndash Writabilityndash Reliabilityndash Expressive Power

Form and Meaning of Code

bull Syntax of a language defines the legal statements that can be written ndash how it looks

bull Semantics of a language defines how the statements are executed ndash the results that are produced when the program runs

  • Language Evaluation Criteria of C++ Programming Language
  • Cost of Software
  • Costs over the Software Lifecycle (Generic model)
  • Relative Cost of 25 Each Phase of Software Development
  • Cost to Fix a Fault vs Development Phase
  • Readability of C++
  • Writability of C++ ndash Ease of Writing Programs
  • Simplicity Improves ReadWritability
  • Orthogonality
  • Orthogonality Improves ReadWritability
  • Structured Control Improves ReadWritability
  • Concise Data StructuresTypes Improve ReadWritability
  • Syntax and ReadWrite-ability
  • Abstraction
  • Abstraction Increases Expressivity
  • Reliability
  • Type Checking and Exception Handling Improve Reliability
  • Aliasing Reduces Readability and Reliability
  • Language Design Trade-offs
  • Lecture Questions
  • Lecture Questions (cont)
  • Form and Meaning of Code
Page 2: MELJUN CORTES -Programming Criteria

Cost of Software

bull Total cost - due to many language factorsndash Training programmers (time)ndash Developing software and environment (ease of use time)ndash Compiling programs (time space)ndash Executing programs (time space)ndash Language implementation system (interpreter compiler)ndash Reliability (failures per time unit)ndash Maintenance (time to fix bugs keep current with new

hardwaresoftware)ndash Extensibilityneed for modification (ease time)

Costs over the Software Lifecycle(Generic model)

1 Requirements2 Specifications3 Design4 Module coding5 Module testing6 Module Integration7 Maintenance8 Retirement

Relative Cost of 25Each Phase of Software Development

bull Maintenance constitutes 67 of total cost From Software Engineering

Specification(analysis)

5Requirements

2

Desine6

Modulecoding 5

ModuleTesting

7

Integration8

Maintenance67

Cost to Fix a Fault vs Development Phase

Readability of C++

bull Code easyfast - to read and understandbull Language factors that affect readability

1 Overall language simplicity 2 Orthogonality3 Control statements built-in4 Data types amp structures built-in5 Syntax considerations ndash closeness to natural

language andor mathematics

Writability of C++ndash Ease of Writing Programs

bull Easespeed - to create programs solving problems in a specific problem domain

bull Language factors that affect writability1 Simplicity and orthogonality2 Support for abstraction3 Expressive power4 DevelopmentComputer Aided Software

Engineering (CASE) environmentsbull Cryptic vs wordy syntax

Simplicity Improves ReadWritability

bull A large language takes more time to learnndash Programmers might learn only a subset

bull Feature multiplicity (having more than one way to perform a particular operation) is often confusingndash For example in C++ or Java you can decrement a variable in

four different ways x = x ndash 1 x -= 1 x-- --xbull Operator overloading (a single operator symbol has more

than one meaning) can lead to confusionbull Some languages (eg assembly languages) can be too

simple ndash too low level 2 3 4 5 or more statements needed to have the effect of 1 statement in a high-level language

Orthogonality

bull In geometry orthogonal means involving right angles

bull In general use it means being independent non-redundant non-overlapping or not related

bull In computer languages it means a construct can be used without consideration as to how its use will affect something else

bull A programming language is considered orthogonal if its features can be used without thinking about how their use will affect other features eg objects and arrays

Orthogonality Improves ReadWritability

bull Having fewer constructs and having few exceptions increases readability and writability

bull Orthogonal languages are easier to learnbull Examples

ndash Pointers should be able to point to any type of variable or data structurebull Exceptions (eg in C) are due to a lack of orthogonality

ndash ADD op1 op2 1048774 op1 vsndash ADDR Reg1 Reg2 1048774 Reg1 andndash ADDRM Reg1 MemA 1048774 Reg1ndash A different ADD operation depending on operand location in memory

bull However if a language is too orthogonal an inexperienced programmer might assume they can do something that makes no sensendash eg add two pointers together

Structured Control Improves ReadWritability

bull goto statements were replaced by structured programming in the 1970s

bull Can be read from top to bottomndash Most languages now contain sufficient control

statements making gotorsquos unnecessarybull The following are equivalent

if (x lt y) x++ if (x lt y) goto L1 else y++ y++ goto L2 L1 x++ L2

Concise Data StructuresTypesImprove ReadWritability

bull Adequate data types and data structures also aid readability

bull A language with Boolean types is easier to read than one withoutndash indicatorFlag = 0

is more difficult to read thanndash indicatorFlag = false

Syntax and ReadWrite-ability

bull Syntax - the way linguistic elements (eg words) are put together to form phrases or clausessentences

bull Identifier formsndash If too short reduces readability

bull Special word usendash Ada has end if and end loop while Java uses for

bothndash In Fortran 95 Do and End can also be variable names

bull Form and meaningndash In C static changes meaning depending on position

Abstraction

bull The ability to define and then use complex structures or operationsndash Allows details to be ignoredndash Allows code to be re-used instead of repeatedndash Example A binary tree in Fortran 77 required arrays while

in OO languages nodes with pointers may be used1 Abstract data typesndash implementation details are separated from the interface

allowing them to be changed without re-writing all code2 Objects3 Subprograms

Abstraction Increases Expressivity

bull Expressive language - has powerful built-in primitives for high-level abstractions

bull For example in Lispndash Pointer manipulation is implicit ndash avoid mistakesndash Mapcar ndash apply a function to every element of a list (and

return the corresponding results in a list)bull No need to write the iteration yourself ndash you would need to write

a different function for each different type of databull Infinite precision integers and rational numbersndash No need to develop functions yourselfndash Completely avoid round-off errors at will

bull Eg 23 + 13 = 1 not 999999

Reliability

bull A reliable program performs to its specifications under all conditions

bull Factors that affect reliability1 Type checking2 Exception handling3 Aliasing4 Readability and writability5 Environmental factors ndash real-time or safety-

critical application

Type Checking and Exception HandlingImprove Reliability

bull Type checkingndash Testing for type errors in a given programbull For example if a function is expecting an integer

receives a float instead

bull Exception handlingndash Used in Ada C++ Lisp and Java but not in C and

Fortranbull Eg the try and catch blocks of C++ can catch runtime

errors fix the problem and then continue the program without an ldquoabnormal endrdquo

Aliasing Reduces Readabilityand Reliability

bull Aliasingndash Referencing the same memory cell with more than

one namebull Eg in C both x and y can be used to refer to the same

memory cellint x = 5int y = ampx

ndash Leads to errorsbull Reliability increases with better readwritabilityndash If a program is difficult to read or write its easier to

make mistakes and more difficult to find them

Language Design Trade-offs

bull Reliability and cost ndash costs more to ensure greater reliabilityndash Example ndash type checkingbull In C the index ranges of arrays are not checkedbull So executes fast but it not so reliablebull On the other hand Java checks all references to array

elementsbull Java executes slower but is more reliable

Lecture Questions

bull What are 5 criteria used to evaluate languages

12345

Lecture Questions (cont)

bull How do think each of these affect software costndash Readabilityndash Writabilityndash Reliabilityndash Expressive Power

Form and Meaning of Code

bull Syntax of a language defines the legal statements that can be written ndash how it looks

bull Semantics of a language defines how the statements are executed ndash the results that are produced when the program runs

  • Language Evaluation Criteria of C++ Programming Language
  • Cost of Software
  • Costs over the Software Lifecycle (Generic model)
  • Relative Cost of 25 Each Phase of Software Development
  • Cost to Fix a Fault vs Development Phase
  • Readability of C++
  • Writability of C++ ndash Ease of Writing Programs
  • Simplicity Improves ReadWritability
  • Orthogonality
  • Orthogonality Improves ReadWritability
  • Structured Control Improves ReadWritability
  • Concise Data StructuresTypes Improve ReadWritability
  • Syntax and ReadWrite-ability
  • Abstraction
  • Abstraction Increases Expressivity
  • Reliability
  • Type Checking and Exception Handling Improve Reliability
  • Aliasing Reduces Readability and Reliability
  • Language Design Trade-offs
  • Lecture Questions
  • Lecture Questions (cont)
  • Form and Meaning of Code
Page 3: MELJUN CORTES -Programming Criteria

Costs over the Software Lifecycle(Generic model)

1 Requirements2 Specifications3 Design4 Module coding5 Module testing6 Module Integration7 Maintenance8 Retirement

Relative Cost of 25Each Phase of Software Development

bull Maintenance constitutes 67 of total cost From Software Engineering

Specification(analysis)

5Requirements

2

Desine6

Modulecoding 5

ModuleTesting

7

Integration8

Maintenance67

Cost to Fix a Fault vs Development Phase

Readability of C++

bull Code easyfast - to read and understandbull Language factors that affect readability

1 Overall language simplicity 2 Orthogonality3 Control statements built-in4 Data types amp structures built-in5 Syntax considerations ndash closeness to natural

language andor mathematics

Writability of C++ndash Ease of Writing Programs

bull Easespeed - to create programs solving problems in a specific problem domain

bull Language factors that affect writability1 Simplicity and orthogonality2 Support for abstraction3 Expressive power4 DevelopmentComputer Aided Software

Engineering (CASE) environmentsbull Cryptic vs wordy syntax

Simplicity Improves ReadWritability

bull A large language takes more time to learnndash Programmers might learn only a subset

bull Feature multiplicity (having more than one way to perform a particular operation) is often confusingndash For example in C++ or Java you can decrement a variable in

four different ways x = x ndash 1 x -= 1 x-- --xbull Operator overloading (a single operator symbol has more

than one meaning) can lead to confusionbull Some languages (eg assembly languages) can be too

simple ndash too low level 2 3 4 5 or more statements needed to have the effect of 1 statement in a high-level language

Orthogonality

bull In geometry orthogonal means involving right angles

bull In general use it means being independent non-redundant non-overlapping or not related

bull In computer languages it means a construct can be used without consideration as to how its use will affect something else

bull A programming language is considered orthogonal if its features can be used without thinking about how their use will affect other features eg objects and arrays

Orthogonality Improves ReadWritability

bull Having fewer constructs and having few exceptions increases readability and writability

bull Orthogonal languages are easier to learnbull Examples

ndash Pointers should be able to point to any type of variable or data structurebull Exceptions (eg in C) are due to a lack of orthogonality

ndash ADD op1 op2 1048774 op1 vsndash ADDR Reg1 Reg2 1048774 Reg1 andndash ADDRM Reg1 MemA 1048774 Reg1ndash A different ADD operation depending on operand location in memory

bull However if a language is too orthogonal an inexperienced programmer might assume they can do something that makes no sensendash eg add two pointers together

Structured Control Improves ReadWritability

bull goto statements were replaced by structured programming in the 1970s

bull Can be read from top to bottomndash Most languages now contain sufficient control

statements making gotorsquos unnecessarybull The following are equivalent

if (x lt y) x++ if (x lt y) goto L1 else y++ y++ goto L2 L1 x++ L2

Concise Data StructuresTypesImprove ReadWritability

bull Adequate data types and data structures also aid readability

bull A language with Boolean types is easier to read than one withoutndash indicatorFlag = 0

is more difficult to read thanndash indicatorFlag = false

Syntax and ReadWrite-ability

bull Syntax - the way linguistic elements (eg words) are put together to form phrases or clausessentences

bull Identifier formsndash If too short reduces readability

bull Special word usendash Ada has end if and end loop while Java uses for

bothndash In Fortran 95 Do and End can also be variable names

bull Form and meaningndash In C static changes meaning depending on position

Abstraction

bull The ability to define and then use complex structures or operationsndash Allows details to be ignoredndash Allows code to be re-used instead of repeatedndash Example A binary tree in Fortran 77 required arrays while

in OO languages nodes with pointers may be used1 Abstract data typesndash implementation details are separated from the interface

allowing them to be changed without re-writing all code2 Objects3 Subprograms

Abstraction Increases Expressivity

bull Expressive language - has powerful built-in primitives for high-level abstractions

bull For example in Lispndash Pointer manipulation is implicit ndash avoid mistakesndash Mapcar ndash apply a function to every element of a list (and

return the corresponding results in a list)bull No need to write the iteration yourself ndash you would need to write

a different function for each different type of databull Infinite precision integers and rational numbersndash No need to develop functions yourselfndash Completely avoid round-off errors at will

bull Eg 23 + 13 = 1 not 999999

Reliability

bull A reliable program performs to its specifications under all conditions

bull Factors that affect reliability1 Type checking2 Exception handling3 Aliasing4 Readability and writability5 Environmental factors ndash real-time or safety-

critical application

Type Checking and Exception HandlingImprove Reliability

bull Type checkingndash Testing for type errors in a given programbull For example if a function is expecting an integer

receives a float instead

bull Exception handlingndash Used in Ada C++ Lisp and Java but not in C and

Fortranbull Eg the try and catch blocks of C++ can catch runtime

errors fix the problem and then continue the program without an ldquoabnormal endrdquo

Aliasing Reduces Readabilityand Reliability

bull Aliasingndash Referencing the same memory cell with more than

one namebull Eg in C both x and y can be used to refer to the same

memory cellint x = 5int y = ampx

ndash Leads to errorsbull Reliability increases with better readwritabilityndash If a program is difficult to read or write its easier to

make mistakes and more difficult to find them

Language Design Trade-offs

bull Reliability and cost ndash costs more to ensure greater reliabilityndash Example ndash type checkingbull In C the index ranges of arrays are not checkedbull So executes fast but it not so reliablebull On the other hand Java checks all references to array

elementsbull Java executes slower but is more reliable

Lecture Questions

bull What are 5 criteria used to evaluate languages

12345

Lecture Questions (cont)

bull How do think each of these affect software costndash Readabilityndash Writabilityndash Reliabilityndash Expressive Power

Form and Meaning of Code

bull Syntax of a language defines the legal statements that can be written ndash how it looks

bull Semantics of a language defines how the statements are executed ndash the results that are produced when the program runs

  • Language Evaluation Criteria of C++ Programming Language
  • Cost of Software
  • Costs over the Software Lifecycle (Generic model)
  • Relative Cost of 25 Each Phase of Software Development
  • Cost to Fix a Fault vs Development Phase
  • Readability of C++
  • Writability of C++ ndash Ease of Writing Programs
  • Simplicity Improves ReadWritability
  • Orthogonality
  • Orthogonality Improves ReadWritability
  • Structured Control Improves ReadWritability
  • Concise Data StructuresTypes Improve ReadWritability
  • Syntax and ReadWrite-ability
  • Abstraction
  • Abstraction Increases Expressivity
  • Reliability
  • Type Checking and Exception Handling Improve Reliability
  • Aliasing Reduces Readability and Reliability
  • Language Design Trade-offs
  • Lecture Questions
  • Lecture Questions (cont)
  • Form and Meaning of Code
Page 4: MELJUN CORTES -Programming Criteria

Relative Cost of 25Each Phase of Software Development

bull Maintenance constitutes 67 of total cost From Software Engineering

Specification(analysis)

5Requirements

2

Desine6

Modulecoding 5

ModuleTesting

7

Integration8

Maintenance67

Cost to Fix a Fault vs Development Phase

Readability of C++

bull Code easyfast - to read and understandbull Language factors that affect readability

1 Overall language simplicity 2 Orthogonality3 Control statements built-in4 Data types amp structures built-in5 Syntax considerations ndash closeness to natural

language andor mathematics

Writability of C++ndash Ease of Writing Programs

bull Easespeed - to create programs solving problems in a specific problem domain

bull Language factors that affect writability1 Simplicity and orthogonality2 Support for abstraction3 Expressive power4 DevelopmentComputer Aided Software

Engineering (CASE) environmentsbull Cryptic vs wordy syntax

Simplicity Improves ReadWritability

bull A large language takes more time to learnndash Programmers might learn only a subset

bull Feature multiplicity (having more than one way to perform a particular operation) is often confusingndash For example in C++ or Java you can decrement a variable in

four different ways x = x ndash 1 x -= 1 x-- --xbull Operator overloading (a single operator symbol has more

than one meaning) can lead to confusionbull Some languages (eg assembly languages) can be too

simple ndash too low level 2 3 4 5 or more statements needed to have the effect of 1 statement in a high-level language

Orthogonality

bull In geometry orthogonal means involving right angles

bull In general use it means being independent non-redundant non-overlapping or not related

bull In computer languages it means a construct can be used without consideration as to how its use will affect something else

bull A programming language is considered orthogonal if its features can be used without thinking about how their use will affect other features eg objects and arrays

Orthogonality Improves ReadWritability

bull Having fewer constructs and having few exceptions increases readability and writability

bull Orthogonal languages are easier to learnbull Examples

ndash Pointers should be able to point to any type of variable or data structurebull Exceptions (eg in C) are due to a lack of orthogonality

ndash ADD op1 op2 1048774 op1 vsndash ADDR Reg1 Reg2 1048774 Reg1 andndash ADDRM Reg1 MemA 1048774 Reg1ndash A different ADD operation depending on operand location in memory

bull However if a language is too orthogonal an inexperienced programmer might assume they can do something that makes no sensendash eg add two pointers together

Structured Control Improves ReadWritability

bull goto statements were replaced by structured programming in the 1970s

bull Can be read from top to bottomndash Most languages now contain sufficient control

statements making gotorsquos unnecessarybull The following are equivalent

if (x lt y) x++ if (x lt y) goto L1 else y++ y++ goto L2 L1 x++ L2

Concise Data StructuresTypesImprove ReadWritability

bull Adequate data types and data structures also aid readability

bull A language with Boolean types is easier to read than one withoutndash indicatorFlag = 0

is more difficult to read thanndash indicatorFlag = false

Syntax and ReadWrite-ability

bull Syntax - the way linguistic elements (eg words) are put together to form phrases or clausessentences

bull Identifier formsndash If too short reduces readability

bull Special word usendash Ada has end if and end loop while Java uses for

bothndash In Fortran 95 Do and End can also be variable names

bull Form and meaningndash In C static changes meaning depending on position

Abstraction

bull The ability to define and then use complex structures or operationsndash Allows details to be ignoredndash Allows code to be re-used instead of repeatedndash Example A binary tree in Fortran 77 required arrays while

in OO languages nodes with pointers may be used1 Abstract data typesndash implementation details are separated from the interface

allowing them to be changed without re-writing all code2 Objects3 Subprograms

Abstraction Increases Expressivity

bull Expressive language - has powerful built-in primitives for high-level abstractions

bull For example in Lispndash Pointer manipulation is implicit ndash avoid mistakesndash Mapcar ndash apply a function to every element of a list (and

return the corresponding results in a list)bull No need to write the iteration yourself ndash you would need to write

a different function for each different type of databull Infinite precision integers and rational numbersndash No need to develop functions yourselfndash Completely avoid round-off errors at will

bull Eg 23 + 13 = 1 not 999999

Reliability

bull A reliable program performs to its specifications under all conditions

bull Factors that affect reliability1 Type checking2 Exception handling3 Aliasing4 Readability and writability5 Environmental factors ndash real-time or safety-

critical application

Type Checking and Exception HandlingImprove Reliability

bull Type checkingndash Testing for type errors in a given programbull For example if a function is expecting an integer

receives a float instead

bull Exception handlingndash Used in Ada C++ Lisp and Java but not in C and

Fortranbull Eg the try and catch blocks of C++ can catch runtime

errors fix the problem and then continue the program without an ldquoabnormal endrdquo

Aliasing Reduces Readabilityand Reliability

bull Aliasingndash Referencing the same memory cell with more than

one namebull Eg in C both x and y can be used to refer to the same

memory cellint x = 5int y = ampx

ndash Leads to errorsbull Reliability increases with better readwritabilityndash If a program is difficult to read or write its easier to

make mistakes and more difficult to find them

Language Design Trade-offs

bull Reliability and cost ndash costs more to ensure greater reliabilityndash Example ndash type checkingbull In C the index ranges of arrays are not checkedbull So executes fast but it not so reliablebull On the other hand Java checks all references to array

elementsbull Java executes slower but is more reliable

Lecture Questions

bull What are 5 criteria used to evaluate languages

12345

Lecture Questions (cont)

bull How do think each of these affect software costndash Readabilityndash Writabilityndash Reliabilityndash Expressive Power

Form and Meaning of Code

bull Syntax of a language defines the legal statements that can be written ndash how it looks

bull Semantics of a language defines how the statements are executed ndash the results that are produced when the program runs

  • Language Evaluation Criteria of C++ Programming Language
  • Cost of Software
  • Costs over the Software Lifecycle (Generic model)
  • Relative Cost of 25 Each Phase of Software Development
  • Cost to Fix a Fault vs Development Phase
  • Readability of C++
  • Writability of C++ ndash Ease of Writing Programs
  • Simplicity Improves ReadWritability
  • Orthogonality
  • Orthogonality Improves ReadWritability
  • Structured Control Improves ReadWritability
  • Concise Data StructuresTypes Improve ReadWritability
  • Syntax and ReadWrite-ability
  • Abstraction
  • Abstraction Increases Expressivity
  • Reliability
  • Type Checking and Exception Handling Improve Reliability
  • Aliasing Reduces Readability and Reliability
  • Language Design Trade-offs
  • Lecture Questions
  • Lecture Questions (cont)
  • Form and Meaning of Code
Page 5: MELJUN CORTES -Programming Criteria

Cost to Fix a Fault vs Development Phase

Readability of C++

bull Code easyfast - to read and understandbull Language factors that affect readability

1 Overall language simplicity 2 Orthogonality3 Control statements built-in4 Data types amp structures built-in5 Syntax considerations ndash closeness to natural

language andor mathematics

Writability of C++ndash Ease of Writing Programs

bull Easespeed - to create programs solving problems in a specific problem domain

bull Language factors that affect writability1 Simplicity and orthogonality2 Support for abstraction3 Expressive power4 DevelopmentComputer Aided Software

Engineering (CASE) environmentsbull Cryptic vs wordy syntax

Simplicity Improves ReadWritability

bull A large language takes more time to learnndash Programmers might learn only a subset

bull Feature multiplicity (having more than one way to perform a particular operation) is often confusingndash For example in C++ or Java you can decrement a variable in

four different ways x = x ndash 1 x -= 1 x-- --xbull Operator overloading (a single operator symbol has more

than one meaning) can lead to confusionbull Some languages (eg assembly languages) can be too

simple ndash too low level 2 3 4 5 or more statements needed to have the effect of 1 statement in a high-level language

Orthogonality

bull In geometry orthogonal means involving right angles

bull In general use it means being independent non-redundant non-overlapping or not related

bull In computer languages it means a construct can be used without consideration as to how its use will affect something else

bull A programming language is considered orthogonal if its features can be used without thinking about how their use will affect other features eg objects and arrays

Orthogonality Improves ReadWritability

bull Having fewer constructs and having few exceptions increases readability and writability

bull Orthogonal languages are easier to learnbull Examples

ndash Pointers should be able to point to any type of variable or data structurebull Exceptions (eg in C) are due to a lack of orthogonality

ndash ADD op1 op2 1048774 op1 vsndash ADDR Reg1 Reg2 1048774 Reg1 andndash ADDRM Reg1 MemA 1048774 Reg1ndash A different ADD operation depending on operand location in memory

bull However if a language is too orthogonal an inexperienced programmer might assume they can do something that makes no sensendash eg add two pointers together

Structured Control Improves ReadWritability

bull goto statements were replaced by structured programming in the 1970s

bull Can be read from top to bottomndash Most languages now contain sufficient control

statements making gotorsquos unnecessarybull The following are equivalent

if (x lt y) x++ if (x lt y) goto L1 else y++ y++ goto L2 L1 x++ L2

Concise Data StructuresTypesImprove ReadWritability

bull Adequate data types and data structures also aid readability

bull A language with Boolean types is easier to read than one withoutndash indicatorFlag = 0

is more difficult to read thanndash indicatorFlag = false

Syntax and ReadWrite-ability

bull Syntax - the way linguistic elements (eg words) are put together to form phrases or clausessentences

bull Identifier formsndash If too short reduces readability

bull Special word usendash Ada has end if and end loop while Java uses for

bothndash In Fortran 95 Do and End can also be variable names

bull Form and meaningndash In C static changes meaning depending on position

Abstraction

bull The ability to define and then use complex structures or operationsndash Allows details to be ignoredndash Allows code to be re-used instead of repeatedndash Example A binary tree in Fortran 77 required arrays while

in OO languages nodes with pointers may be used1 Abstract data typesndash implementation details are separated from the interface

allowing them to be changed without re-writing all code2 Objects3 Subprograms

Abstraction Increases Expressivity

bull Expressive language - has powerful built-in primitives for high-level abstractions

bull For example in Lispndash Pointer manipulation is implicit ndash avoid mistakesndash Mapcar ndash apply a function to every element of a list (and

return the corresponding results in a list)bull No need to write the iteration yourself ndash you would need to write

a different function for each different type of databull Infinite precision integers and rational numbersndash No need to develop functions yourselfndash Completely avoid round-off errors at will

bull Eg 23 + 13 = 1 not 999999

Reliability

bull A reliable program performs to its specifications under all conditions

bull Factors that affect reliability1 Type checking2 Exception handling3 Aliasing4 Readability and writability5 Environmental factors ndash real-time or safety-

critical application

Type Checking and Exception HandlingImprove Reliability

bull Type checkingndash Testing for type errors in a given programbull For example if a function is expecting an integer

receives a float instead

bull Exception handlingndash Used in Ada C++ Lisp and Java but not in C and

Fortranbull Eg the try and catch blocks of C++ can catch runtime

errors fix the problem and then continue the program without an ldquoabnormal endrdquo

Aliasing Reduces Readabilityand Reliability

bull Aliasingndash Referencing the same memory cell with more than

one namebull Eg in C both x and y can be used to refer to the same

memory cellint x = 5int y = ampx

ndash Leads to errorsbull Reliability increases with better readwritabilityndash If a program is difficult to read or write its easier to

make mistakes and more difficult to find them

Language Design Trade-offs

bull Reliability and cost ndash costs more to ensure greater reliabilityndash Example ndash type checkingbull In C the index ranges of arrays are not checkedbull So executes fast but it not so reliablebull On the other hand Java checks all references to array

elementsbull Java executes slower but is more reliable

Lecture Questions

bull What are 5 criteria used to evaluate languages

12345

Lecture Questions (cont)

bull How do think each of these affect software costndash Readabilityndash Writabilityndash Reliabilityndash Expressive Power

Form and Meaning of Code

bull Syntax of a language defines the legal statements that can be written ndash how it looks

bull Semantics of a language defines how the statements are executed ndash the results that are produced when the program runs

  • Language Evaluation Criteria of C++ Programming Language
  • Cost of Software
  • Costs over the Software Lifecycle (Generic model)
  • Relative Cost of 25 Each Phase of Software Development
  • Cost to Fix a Fault vs Development Phase
  • Readability of C++
  • Writability of C++ ndash Ease of Writing Programs
  • Simplicity Improves ReadWritability
  • Orthogonality
  • Orthogonality Improves ReadWritability
  • Structured Control Improves ReadWritability
  • Concise Data StructuresTypes Improve ReadWritability
  • Syntax and ReadWrite-ability
  • Abstraction
  • Abstraction Increases Expressivity
  • Reliability
  • Type Checking and Exception Handling Improve Reliability
  • Aliasing Reduces Readability and Reliability
  • Language Design Trade-offs
  • Lecture Questions
  • Lecture Questions (cont)
  • Form and Meaning of Code
Page 6: MELJUN CORTES -Programming Criteria

Readability of C++

bull Code easyfast - to read and understandbull Language factors that affect readability

1 Overall language simplicity 2 Orthogonality3 Control statements built-in4 Data types amp structures built-in5 Syntax considerations ndash closeness to natural

language andor mathematics

Writability of C++ndash Ease of Writing Programs

bull Easespeed - to create programs solving problems in a specific problem domain

bull Language factors that affect writability1 Simplicity and orthogonality2 Support for abstraction3 Expressive power4 DevelopmentComputer Aided Software

Engineering (CASE) environmentsbull Cryptic vs wordy syntax

Simplicity Improves ReadWritability

bull A large language takes more time to learnndash Programmers might learn only a subset

bull Feature multiplicity (having more than one way to perform a particular operation) is often confusingndash For example in C++ or Java you can decrement a variable in

four different ways x = x ndash 1 x -= 1 x-- --xbull Operator overloading (a single operator symbol has more

than one meaning) can lead to confusionbull Some languages (eg assembly languages) can be too

simple ndash too low level 2 3 4 5 or more statements needed to have the effect of 1 statement in a high-level language

Orthogonality

bull In geometry orthogonal means involving right angles

bull In general use it means being independent non-redundant non-overlapping or not related

bull In computer languages it means a construct can be used without consideration as to how its use will affect something else

bull A programming language is considered orthogonal if its features can be used without thinking about how their use will affect other features eg objects and arrays

Orthogonality Improves ReadWritability

bull Having fewer constructs and having few exceptions increases readability and writability

bull Orthogonal languages are easier to learnbull Examples

ndash Pointers should be able to point to any type of variable or data structurebull Exceptions (eg in C) are due to a lack of orthogonality

ndash ADD op1 op2 1048774 op1 vsndash ADDR Reg1 Reg2 1048774 Reg1 andndash ADDRM Reg1 MemA 1048774 Reg1ndash A different ADD operation depending on operand location in memory

bull However if a language is too orthogonal an inexperienced programmer might assume they can do something that makes no sensendash eg add two pointers together

Structured Control Improves ReadWritability

bull goto statements were replaced by structured programming in the 1970s

bull Can be read from top to bottomndash Most languages now contain sufficient control

statements making gotorsquos unnecessarybull The following are equivalent

if (x lt y) x++ if (x lt y) goto L1 else y++ y++ goto L2 L1 x++ L2

Concise Data StructuresTypesImprove ReadWritability

bull Adequate data types and data structures also aid readability

bull A language with Boolean types is easier to read than one withoutndash indicatorFlag = 0

is more difficult to read thanndash indicatorFlag = false

Syntax and ReadWrite-ability

bull Syntax - the way linguistic elements (eg words) are put together to form phrases or clausessentences

bull Identifier formsndash If too short reduces readability

bull Special word usendash Ada has end if and end loop while Java uses for

bothndash In Fortran 95 Do and End can also be variable names

bull Form and meaningndash In C static changes meaning depending on position

Abstraction

bull The ability to define and then use complex structures or operationsndash Allows details to be ignoredndash Allows code to be re-used instead of repeatedndash Example A binary tree in Fortran 77 required arrays while

in OO languages nodes with pointers may be used1 Abstract data typesndash implementation details are separated from the interface

allowing them to be changed without re-writing all code2 Objects3 Subprograms

Abstraction Increases Expressivity

bull Expressive language - has powerful built-in primitives for high-level abstractions

bull For example in Lispndash Pointer manipulation is implicit ndash avoid mistakesndash Mapcar ndash apply a function to every element of a list (and

return the corresponding results in a list)bull No need to write the iteration yourself ndash you would need to write

a different function for each different type of databull Infinite precision integers and rational numbersndash No need to develop functions yourselfndash Completely avoid round-off errors at will

bull Eg 23 + 13 = 1 not 999999

Reliability

bull A reliable program performs to its specifications under all conditions

bull Factors that affect reliability1 Type checking2 Exception handling3 Aliasing4 Readability and writability5 Environmental factors ndash real-time or safety-

critical application

Type Checking and Exception HandlingImprove Reliability

bull Type checkingndash Testing for type errors in a given programbull For example if a function is expecting an integer

receives a float instead

bull Exception handlingndash Used in Ada C++ Lisp and Java but not in C and

Fortranbull Eg the try and catch blocks of C++ can catch runtime

errors fix the problem and then continue the program without an ldquoabnormal endrdquo

Aliasing Reduces Readabilityand Reliability

bull Aliasingndash Referencing the same memory cell with more than

one namebull Eg in C both x and y can be used to refer to the same

memory cellint x = 5int y = ampx

ndash Leads to errorsbull Reliability increases with better readwritabilityndash If a program is difficult to read or write its easier to

make mistakes and more difficult to find them

Language Design Trade-offs

bull Reliability and cost ndash costs more to ensure greater reliabilityndash Example ndash type checkingbull In C the index ranges of arrays are not checkedbull So executes fast but it not so reliablebull On the other hand Java checks all references to array

elementsbull Java executes slower but is more reliable

Lecture Questions

bull What are 5 criteria used to evaluate languages

12345

Lecture Questions (cont)

bull How do think each of these affect software costndash Readabilityndash Writabilityndash Reliabilityndash Expressive Power

Form and Meaning of Code

bull Syntax of a language defines the legal statements that can be written ndash how it looks

bull Semantics of a language defines how the statements are executed ndash the results that are produced when the program runs

  • Language Evaluation Criteria of C++ Programming Language
  • Cost of Software
  • Costs over the Software Lifecycle (Generic model)
  • Relative Cost of 25 Each Phase of Software Development
  • Cost to Fix a Fault vs Development Phase
  • Readability of C++
  • Writability of C++ ndash Ease of Writing Programs
  • Simplicity Improves ReadWritability
  • Orthogonality
  • Orthogonality Improves ReadWritability
  • Structured Control Improves ReadWritability
  • Concise Data StructuresTypes Improve ReadWritability
  • Syntax and ReadWrite-ability
  • Abstraction
  • Abstraction Increases Expressivity
  • Reliability
  • Type Checking and Exception Handling Improve Reliability
  • Aliasing Reduces Readability and Reliability
  • Language Design Trade-offs
  • Lecture Questions
  • Lecture Questions (cont)
  • Form and Meaning of Code
Page 7: MELJUN CORTES -Programming Criteria

Writability of C++ndash Ease of Writing Programs

bull Easespeed - to create programs solving problems in a specific problem domain

bull Language factors that affect writability1 Simplicity and orthogonality2 Support for abstraction3 Expressive power4 DevelopmentComputer Aided Software

Engineering (CASE) environmentsbull Cryptic vs wordy syntax

Simplicity Improves ReadWritability

bull A large language takes more time to learnndash Programmers might learn only a subset

bull Feature multiplicity (having more than one way to perform a particular operation) is often confusingndash For example in C++ or Java you can decrement a variable in

four different ways x = x ndash 1 x -= 1 x-- --xbull Operator overloading (a single operator symbol has more

than one meaning) can lead to confusionbull Some languages (eg assembly languages) can be too

simple ndash too low level 2 3 4 5 or more statements needed to have the effect of 1 statement in a high-level language

Orthogonality

bull In geometry orthogonal means involving right angles

bull In general use it means being independent non-redundant non-overlapping or not related

bull In computer languages it means a construct can be used without consideration as to how its use will affect something else

bull A programming language is considered orthogonal if its features can be used without thinking about how their use will affect other features eg objects and arrays

Orthogonality Improves ReadWritability

bull Having fewer constructs and having few exceptions increases readability and writability

bull Orthogonal languages are easier to learnbull Examples

ndash Pointers should be able to point to any type of variable or data structurebull Exceptions (eg in C) are due to a lack of orthogonality

ndash ADD op1 op2 1048774 op1 vsndash ADDR Reg1 Reg2 1048774 Reg1 andndash ADDRM Reg1 MemA 1048774 Reg1ndash A different ADD operation depending on operand location in memory

bull However if a language is too orthogonal an inexperienced programmer might assume they can do something that makes no sensendash eg add two pointers together

Structured Control Improves ReadWritability

bull goto statements were replaced by structured programming in the 1970s

bull Can be read from top to bottomndash Most languages now contain sufficient control

statements making gotorsquos unnecessarybull The following are equivalent

if (x lt y) x++ if (x lt y) goto L1 else y++ y++ goto L2 L1 x++ L2

Concise Data StructuresTypesImprove ReadWritability

bull Adequate data types and data structures also aid readability

bull A language with Boolean types is easier to read than one withoutndash indicatorFlag = 0

is more difficult to read thanndash indicatorFlag = false

Syntax and ReadWrite-ability

bull Syntax - the way linguistic elements (eg words) are put together to form phrases or clausessentences

bull Identifier formsndash If too short reduces readability

bull Special word usendash Ada has end if and end loop while Java uses for

bothndash In Fortran 95 Do and End can also be variable names

bull Form and meaningndash In C static changes meaning depending on position

Abstraction

bull The ability to define and then use complex structures or operationsndash Allows details to be ignoredndash Allows code to be re-used instead of repeatedndash Example A binary tree in Fortran 77 required arrays while

in OO languages nodes with pointers may be used1 Abstract data typesndash implementation details are separated from the interface

allowing them to be changed without re-writing all code2 Objects3 Subprograms

Abstraction Increases Expressivity

bull Expressive language - has powerful built-in primitives for high-level abstractions

bull For example in Lispndash Pointer manipulation is implicit ndash avoid mistakesndash Mapcar ndash apply a function to every element of a list (and

return the corresponding results in a list)bull No need to write the iteration yourself ndash you would need to write

a different function for each different type of databull Infinite precision integers and rational numbersndash No need to develop functions yourselfndash Completely avoid round-off errors at will

bull Eg 23 + 13 = 1 not 999999

Reliability

bull A reliable program performs to its specifications under all conditions

bull Factors that affect reliability1 Type checking2 Exception handling3 Aliasing4 Readability and writability5 Environmental factors ndash real-time or safety-

critical application

Type Checking and Exception HandlingImprove Reliability

bull Type checkingndash Testing for type errors in a given programbull For example if a function is expecting an integer

receives a float instead

bull Exception handlingndash Used in Ada C++ Lisp and Java but not in C and

Fortranbull Eg the try and catch blocks of C++ can catch runtime

errors fix the problem and then continue the program without an ldquoabnormal endrdquo

Aliasing Reduces Readabilityand Reliability

bull Aliasingndash Referencing the same memory cell with more than

one namebull Eg in C both x and y can be used to refer to the same

memory cellint x = 5int y = ampx

ndash Leads to errorsbull Reliability increases with better readwritabilityndash If a program is difficult to read or write its easier to

make mistakes and more difficult to find them

Language Design Trade-offs

bull Reliability and cost ndash costs more to ensure greater reliabilityndash Example ndash type checkingbull In C the index ranges of arrays are not checkedbull So executes fast but it not so reliablebull On the other hand Java checks all references to array

elementsbull Java executes slower but is more reliable

Lecture Questions

bull What are 5 criteria used to evaluate languages

12345

Lecture Questions (cont)

bull How do think each of these affect software costndash Readabilityndash Writabilityndash Reliabilityndash Expressive Power

Form and Meaning of Code

bull Syntax of a language defines the legal statements that can be written ndash how it looks

bull Semantics of a language defines how the statements are executed ndash the results that are produced when the program runs

  • Language Evaluation Criteria of C++ Programming Language
  • Cost of Software
  • Costs over the Software Lifecycle (Generic model)
  • Relative Cost of 25 Each Phase of Software Development
  • Cost to Fix a Fault vs Development Phase
  • Readability of C++
  • Writability of C++ ndash Ease of Writing Programs
  • Simplicity Improves ReadWritability
  • Orthogonality
  • Orthogonality Improves ReadWritability
  • Structured Control Improves ReadWritability
  • Concise Data StructuresTypes Improve ReadWritability
  • Syntax and ReadWrite-ability
  • Abstraction
  • Abstraction Increases Expressivity
  • Reliability
  • Type Checking and Exception Handling Improve Reliability
  • Aliasing Reduces Readability and Reliability
  • Language Design Trade-offs
  • Lecture Questions
  • Lecture Questions (cont)
  • Form and Meaning of Code
Page 8: MELJUN CORTES -Programming Criteria

Simplicity Improves ReadWritability

bull A large language takes more time to learnndash Programmers might learn only a subset

bull Feature multiplicity (having more than one way to perform a particular operation) is often confusingndash For example in C++ or Java you can decrement a variable in

four different ways x = x ndash 1 x -= 1 x-- --xbull Operator overloading (a single operator symbol has more

than one meaning) can lead to confusionbull Some languages (eg assembly languages) can be too

simple ndash too low level 2 3 4 5 or more statements needed to have the effect of 1 statement in a high-level language

Orthogonality

bull In geometry orthogonal means involving right angles

bull In general use it means being independent non-redundant non-overlapping or not related

bull In computer languages it means a construct can be used without consideration as to how its use will affect something else

bull A programming language is considered orthogonal if its features can be used without thinking about how their use will affect other features eg objects and arrays

Orthogonality Improves ReadWritability

bull Having fewer constructs and having few exceptions increases readability and writability

bull Orthogonal languages are easier to learnbull Examples

ndash Pointers should be able to point to any type of variable or data structurebull Exceptions (eg in C) are due to a lack of orthogonality

ndash ADD op1 op2 1048774 op1 vsndash ADDR Reg1 Reg2 1048774 Reg1 andndash ADDRM Reg1 MemA 1048774 Reg1ndash A different ADD operation depending on operand location in memory

bull However if a language is too orthogonal an inexperienced programmer might assume they can do something that makes no sensendash eg add two pointers together

Structured Control Improves ReadWritability

bull goto statements were replaced by structured programming in the 1970s

bull Can be read from top to bottomndash Most languages now contain sufficient control

statements making gotorsquos unnecessarybull The following are equivalent

if (x lt y) x++ if (x lt y) goto L1 else y++ y++ goto L2 L1 x++ L2

Concise Data StructuresTypesImprove ReadWritability

bull Adequate data types and data structures also aid readability

bull A language with Boolean types is easier to read than one withoutndash indicatorFlag = 0

is more difficult to read thanndash indicatorFlag = false

Syntax and ReadWrite-ability

bull Syntax - the way linguistic elements (eg words) are put together to form phrases or clausessentences

bull Identifier formsndash If too short reduces readability

bull Special word usendash Ada has end if and end loop while Java uses for

bothndash In Fortran 95 Do and End can also be variable names

bull Form and meaningndash In C static changes meaning depending on position

Abstraction

bull The ability to define and then use complex structures or operationsndash Allows details to be ignoredndash Allows code to be re-used instead of repeatedndash Example A binary tree in Fortran 77 required arrays while

in OO languages nodes with pointers may be used1 Abstract data typesndash implementation details are separated from the interface

allowing them to be changed without re-writing all code2 Objects3 Subprograms

Abstraction Increases Expressivity

bull Expressive language - has powerful built-in primitives for high-level abstractions

bull For example in Lispndash Pointer manipulation is implicit ndash avoid mistakesndash Mapcar ndash apply a function to every element of a list (and

return the corresponding results in a list)bull No need to write the iteration yourself ndash you would need to write

a different function for each different type of databull Infinite precision integers and rational numbersndash No need to develop functions yourselfndash Completely avoid round-off errors at will

bull Eg 23 + 13 = 1 not 999999

Reliability

bull A reliable program performs to its specifications under all conditions

bull Factors that affect reliability1 Type checking2 Exception handling3 Aliasing4 Readability and writability5 Environmental factors ndash real-time or safety-

critical application

Type Checking and Exception HandlingImprove Reliability

bull Type checkingndash Testing for type errors in a given programbull For example if a function is expecting an integer

receives a float instead

bull Exception handlingndash Used in Ada C++ Lisp and Java but not in C and

Fortranbull Eg the try and catch blocks of C++ can catch runtime

errors fix the problem and then continue the program without an ldquoabnormal endrdquo

Aliasing Reduces Readabilityand Reliability

bull Aliasingndash Referencing the same memory cell with more than

one namebull Eg in C both x and y can be used to refer to the same

memory cellint x = 5int y = ampx

ndash Leads to errorsbull Reliability increases with better readwritabilityndash If a program is difficult to read or write its easier to

make mistakes and more difficult to find them

Language Design Trade-offs

bull Reliability and cost ndash costs more to ensure greater reliabilityndash Example ndash type checkingbull In C the index ranges of arrays are not checkedbull So executes fast but it not so reliablebull On the other hand Java checks all references to array

elementsbull Java executes slower but is more reliable

Lecture Questions

bull What are 5 criteria used to evaluate languages

12345

Lecture Questions (cont)

bull How do think each of these affect software costndash Readabilityndash Writabilityndash Reliabilityndash Expressive Power

Form and Meaning of Code

bull Syntax of a language defines the legal statements that can be written ndash how it looks

bull Semantics of a language defines how the statements are executed ndash the results that are produced when the program runs

  • Language Evaluation Criteria of C++ Programming Language
  • Cost of Software
  • Costs over the Software Lifecycle (Generic model)
  • Relative Cost of 25 Each Phase of Software Development
  • Cost to Fix a Fault vs Development Phase
  • Readability of C++
  • Writability of C++ ndash Ease of Writing Programs
  • Simplicity Improves ReadWritability
  • Orthogonality
  • Orthogonality Improves ReadWritability
  • Structured Control Improves ReadWritability
  • Concise Data StructuresTypes Improve ReadWritability
  • Syntax and ReadWrite-ability
  • Abstraction
  • Abstraction Increases Expressivity
  • Reliability
  • Type Checking and Exception Handling Improve Reliability
  • Aliasing Reduces Readability and Reliability
  • Language Design Trade-offs
  • Lecture Questions
  • Lecture Questions (cont)
  • Form and Meaning of Code
Page 9: MELJUN CORTES -Programming Criteria

Orthogonality

bull In geometry orthogonal means involving right angles

bull In general use it means being independent non-redundant non-overlapping or not related

bull In computer languages it means a construct can be used without consideration as to how its use will affect something else

bull A programming language is considered orthogonal if its features can be used without thinking about how their use will affect other features eg objects and arrays

Orthogonality Improves ReadWritability

bull Having fewer constructs and having few exceptions increases readability and writability

bull Orthogonal languages are easier to learnbull Examples

ndash Pointers should be able to point to any type of variable or data structurebull Exceptions (eg in C) are due to a lack of orthogonality

ndash ADD op1 op2 1048774 op1 vsndash ADDR Reg1 Reg2 1048774 Reg1 andndash ADDRM Reg1 MemA 1048774 Reg1ndash A different ADD operation depending on operand location in memory

bull However if a language is too orthogonal an inexperienced programmer might assume they can do something that makes no sensendash eg add two pointers together

Structured Control Improves ReadWritability

bull goto statements were replaced by structured programming in the 1970s

bull Can be read from top to bottomndash Most languages now contain sufficient control

statements making gotorsquos unnecessarybull The following are equivalent

if (x lt y) x++ if (x lt y) goto L1 else y++ y++ goto L2 L1 x++ L2

Concise Data StructuresTypesImprove ReadWritability

bull Adequate data types and data structures also aid readability

bull A language with Boolean types is easier to read than one withoutndash indicatorFlag = 0

is more difficult to read thanndash indicatorFlag = false

Syntax and ReadWrite-ability

bull Syntax - the way linguistic elements (eg words) are put together to form phrases or clausessentences

bull Identifier formsndash If too short reduces readability

bull Special word usendash Ada has end if and end loop while Java uses for

bothndash In Fortran 95 Do and End can also be variable names

bull Form and meaningndash In C static changes meaning depending on position

Abstraction

bull The ability to define and then use complex structures or operationsndash Allows details to be ignoredndash Allows code to be re-used instead of repeatedndash Example A binary tree in Fortran 77 required arrays while

in OO languages nodes with pointers may be used1 Abstract data typesndash implementation details are separated from the interface

allowing them to be changed without re-writing all code2 Objects3 Subprograms

Abstraction Increases Expressivity

bull Expressive language - has powerful built-in primitives for high-level abstractions

bull For example in Lispndash Pointer manipulation is implicit ndash avoid mistakesndash Mapcar ndash apply a function to every element of a list (and

return the corresponding results in a list)bull No need to write the iteration yourself ndash you would need to write

a different function for each different type of databull Infinite precision integers and rational numbersndash No need to develop functions yourselfndash Completely avoid round-off errors at will

bull Eg 23 + 13 = 1 not 999999

Reliability

bull A reliable program performs to its specifications under all conditions

bull Factors that affect reliability1 Type checking2 Exception handling3 Aliasing4 Readability and writability5 Environmental factors ndash real-time or safety-

critical application

Type Checking and Exception HandlingImprove Reliability

bull Type checkingndash Testing for type errors in a given programbull For example if a function is expecting an integer

receives a float instead

bull Exception handlingndash Used in Ada C++ Lisp and Java but not in C and

Fortranbull Eg the try and catch blocks of C++ can catch runtime

errors fix the problem and then continue the program without an ldquoabnormal endrdquo

Aliasing Reduces Readabilityand Reliability

bull Aliasingndash Referencing the same memory cell with more than

one namebull Eg in C both x and y can be used to refer to the same

memory cellint x = 5int y = ampx

ndash Leads to errorsbull Reliability increases with better readwritabilityndash If a program is difficult to read or write its easier to

make mistakes and more difficult to find them

Language Design Trade-offs

bull Reliability and cost ndash costs more to ensure greater reliabilityndash Example ndash type checkingbull In C the index ranges of arrays are not checkedbull So executes fast but it not so reliablebull On the other hand Java checks all references to array

elementsbull Java executes slower but is more reliable

Lecture Questions

bull What are 5 criteria used to evaluate languages

12345

Lecture Questions (cont)

bull How do think each of these affect software costndash Readabilityndash Writabilityndash Reliabilityndash Expressive Power

Form and Meaning of Code

bull Syntax of a language defines the legal statements that can be written ndash how it looks

bull Semantics of a language defines how the statements are executed ndash the results that are produced when the program runs

  • Language Evaluation Criteria of C++ Programming Language
  • Cost of Software
  • Costs over the Software Lifecycle (Generic model)
  • Relative Cost of 25 Each Phase of Software Development
  • Cost to Fix a Fault vs Development Phase
  • Readability of C++
  • Writability of C++ ndash Ease of Writing Programs
  • Simplicity Improves ReadWritability
  • Orthogonality
  • Orthogonality Improves ReadWritability
  • Structured Control Improves ReadWritability
  • Concise Data StructuresTypes Improve ReadWritability
  • Syntax and ReadWrite-ability
  • Abstraction
  • Abstraction Increases Expressivity
  • Reliability
  • Type Checking and Exception Handling Improve Reliability
  • Aliasing Reduces Readability and Reliability
  • Language Design Trade-offs
  • Lecture Questions
  • Lecture Questions (cont)
  • Form and Meaning of Code
Page 10: MELJUN CORTES -Programming Criteria

Orthogonality Improves ReadWritability

bull Having fewer constructs and having few exceptions increases readability and writability

bull Orthogonal languages are easier to learnbull Examples

ndash Pointers should be able to point to any type of variable or data structurebull Exceptions (eg in C) are due to a lack of orthogonality

ndash ADD op1 op2 1048774 op1 vsndash ADDR Reg1 Reg2 1048774 Reg1 andndash ADDRM Reg1 MemA 1048774 Reg1ndash A different ADD operation depending on operand location in memory

bull However if a language is too orthogonal an inexperienced programmer might assume they can do something that makes no sensendash eg add two pointers together

Structured Control Improves ReadWritability

bull goto statements were replaced by structured programming in the 1970s

bull Can be read from top to bottomndash Most languages now contain sufficient control

statements making gotorsquos unnecessarybull The following are equivalent

if (x lt y) x++ if (x lt y) goto L1 else y++ y++ goto L2 L1 x++ L2

Concise Data StructuresTypesImprove ReadWritability

bull Adequate data types and data structures also aid readability

bull A language with Boolean types is easier to read than one withoutndash indicatorFlag = 0

is more difficult to read thanndash indicatorFlag = false

Syntax and ReadWrite-ability

bull Syntax - the way linguistic elements (eg words) are put together to form phrases or clausessentences

bull Identifier formsndash If too short reduces readability

bull Special word usendash Ada has end if and end loop while Java uses for

bothndash In Fortran 95 Do and End can also be variable names

bull Form and meaningndash In C static changes meaning depending on position

Abstraction

bull The ability to define and then use complex structures or operationsndash Allows details to be ignoredndash Allows code to be re-used instead of repeatedndash Example A binary tree in Fortran 77 required arrays while

in OO languages nodes with pointers may be used1 Abstract data typesndash implementation details are separated from the interface

allowing them to be changed without re-writing all code2 Objects3 Subprograms

Abstraction Increases Expressivity

bull Expressive language - has powerful built-in primitives for high-level abstractions

bull For example in Lispndash Pointer manipulation is implicit ndash avoid mistakesndash Mapcar ndash apply a function to every element of a list (and

return the corresponding results in a list)bull No need to write the iteration yourself ndash you would need to write

a different function for each different type of databull Infinite precision integers and rational numbersndash No need to develop functions yourselfndash Completely avoid round-off errors at will

bull Eg 23 + 13 = 1 not 999999

Reliability

bull A reliable program performs to its specifications under all conditions

bull Factors that affect reliability1 Type checking2 Exception handling3 Aliasing4 Readability and writability5 Environmental factors ndash real-time or safety-

critical application

Type Checking and Exception HandlingImprove Reliability

bull Type checkingndash Testing for type errors in a given programbull For example if a function is expecting an integer

receives a float instead

bull Exception handlingndash Used in Ada C++ Lisp and Java but not in C and

Fortranbull Eg the try and catch blocks of C++ can catch runtime

errors fix the problem and then continue the program without an ldquoabnormal endrdquo

Aliasing Reduces Readabilityand Reliability

bull Aliasingndash Referencing the same memory cell with more than

one namebull Eg in C both x and y can be used to refer to the same

memory cellint x = 5int y = ampx

ndash Leads to errorsbull Reliability increases with better readwritabilityndash If a program is difficult to read or write its easier to

make mistakes and more difficult to find them

Language Design Trade-offs

bull Reliability and cost ndash costs more to ensure greater reliabilityndash Example ndash type checkingbull In C the index ranges of arrays are not checkedbull So executes fast but it not so reliablebull On the other hand Java checks all references to array

elementsbull Java executes slower but is more reliable

Lecture Questions

bull What are 5 criteria used to evaluate languages

12345

Lecture Questions (cont)

bull How do think each of these affect software costndash Readabilityndash Writabilityndash Reliabilityndash Expressive Power

Form and Meaning of Code

bull Syntax of a language defines the legal statements that can be written ndash how it looks

bull Semantics of a language defines how the statements are executed ndash the results that are produced when the program runs

  • Language Evaluation Criteria of C++ Programming Language
  • Cost of Software
  • Costs over the Software Lifecycle (Generic model)
  • Relative Cost of 25 Each Phase of Software Development
  • Cost to Fix a Fault vs Development Phase
  • Readability of C++
  • Writability of C++ ndash Ease of Writing Programs
  • Simplicity Improves ReadWritability
  • Orthogonality
  • Orthogonality Improves ReadWritability
  • Structured Control Improves ReadWritability
  • Concise Data StructuresTypes Improve ReadWritability
  • Syntax and ReadWrite-ability
  • Abstraction
  • Abstraction Increases Expressivity
  • Reliability
  • Type Checking and Exception Handling Improve Reliability
  • Aliasing Reduces Readability and Reliability
  • Language Design Trade-offs
  • Lecture Questions
  • Lecture Questions (cont)
  • Form and Meaning of Code
Page 11: MELJUN CORTES -Programming Criteria

Structured Control Improves ReadWritability

bull goto statements were replaced by structured programming in the 1970s

bull Can be read from top to bottomndash Most languages now contain sufficient control

statements making gotorsquos unnecessarybull The following are equivalent

if (x lt y) x++ if (x lt y) goto L1 else y++ y++ goto L2 L1 x++ L2

Concise Data StructuresTypesImprove ReadWritability

bull Adequate data types and data structures also aid readability

bull A language with Boolean types is easier to read than one withoutndash indicatorFlag = 0

is more difficult to read thanndash indicatorFlag = false

Syntax and ReadWrite-ability

bull Syntax - the way linguistic elements (eg words) are put together to form phrases or clausessentences

bull Identifier formsndash If too short reduces readability

bull Special word usendash Ada has end if and end loop while Java uses for

bothndash In Fortran 95 Do and End can also be variable names

bull Form and meaningndash In C static changes meaning depending on position

Abstraction

bull The ability to define and then use complex structures or operationsndash Allows details to be ignoredndash Allows code to be re-used instead of repeatedndash Example A binary tree in Fortran 77 required arrays while

in OO languages nodes with pointers may be used1 Abstract data typesndash implementation details are separated from the interface

allowing them to be changed without re-writing all code2 Objects3 Subprograms

Abstraction Increases Expressivity

bull Expressive language - has powerful built-in primitives for high-level abstractions

bull For example in Lispndash Pointer manipulation is implicit ndash avoid mistakesndash Mapcar ndash apply a function to every element of a list (and

return the corresponding results in a list)bull No need to write the iteration yourself ndash you would need to write

a different function for each different type of databull Infinite precision integers and rational numbersndash No need to develop functions yourselfndash Completely avoid round-off errors at will

bull Eg 23 + 13 = 1 not 999999

Reliability

bull A reliable program performs to its specifications under all conditions

bull Factors that affect reliability1 Type checking2 Exception handling3 Aliasing4 Readability and writability5 Environmental factors ndash real-time or safety-

critical application

Type Checking and Exception HandlingImprove Reliability

bull Type checkingndash Testing for type errors in a given programbull For example if a function is expecting an integer

receives a float instead

bull Exception handlingndash Used in Ada C++ Lisp and Java but not in C and

Fortranbull Eg the try and catch blocks of C++ can catch runtime

errors fix the problem and then continue the program without an ldquoabnormal endrdquo

Aliasing Reduces Readabilityand Reliability

bull Aliasingndash Referencing the same memory cell with more than

one namebull Eg in C both x and y can be used to refer to the same

memory cellint x = 5int y = ampx

ndash Leads to errorsbull Reliability increases with better readwritabilityndash If a program is difficult to read or write its easier to

make mistakes and more difficult to find them

Language Design Trade-offs

bull Reliability and cost ndash costs more to ensure greater reliabilityndash Example ndash type checkingbull In C the index ranges of arrays are not checkedbull So executes fast but it not so reliablebull On the other hand Java checks all references to array

elementsbull Java executes slower but is more reliable

Lecture Questions

bull What are 5 criteria used to evaluate languages

12345

Lecture Questions (cont)

bull How do think each of these affect software costndash Readabilityndash Writabilityndash Reliabilityndash Expressive Power

Form and Meaning of Code

bull Syntax of a language defines the legal statements that can be written ndash how it looks

bull Semantics of a language defines how the statements are executed ndash the results that are produced when the program runs

  • Language Evaluation Criteria of C++ Programming Language
  • Cost of Software
  • Costs over the Software Lifecycle (Generic model)
  • Relative Cost of 25 Each Phase of Software Development
  • Cost to Fix a Fault vs Development Phase
  • Readability of C++
  • Writability of C++ ndash Ease of Writing Programs
  • Simplicity Improves ReadWritability
  • Orthogonality
  • Orthogonality Improves ReadWritability
  • Structured Control Improves ReadWritability
  • Concise Data StructuresTypes Improve ReadWritability
  • Syntax and ReadWrite-ability
  • Abstraction
  • Abstraction Increases Expressivity
  • Reliability
  • Type Checking and Exception Handling Improve Reliability
  • Aliasing Reduces Readability and Reliability
  • Language Design Trade-offs
  • Lecture Questions
  • Lecture Questions (cont)
  • Form and Meaning of Code
Page 12: MELJUN CORTES -Programming Criteria

Concise Data StructuresTypesImprove ReadWritability

bull Adequate data types and data structures also aid readability

bull A language with Boolean types is easier to read than one withoutndash indicatorFlag = 0

is more difficult to read thanndash indicatorFlag = false

Syntax and ReadWrite-ability

bull Syntax - the way linguistic elements (eg words) are put together to form phrases or clausessentences

bull Identifier formsndash If too short reduces readability

bull Special word usendash Ada has end if and end loop while Java uses for

bothndash In Fortran 95 Do and End can also be variable names

bull Form and meaningndash In C static changes meaning depending on position

Abstraction

bull The ability to define and then use complex structures or operationsndash Allows details to be ignoredndash Allows code to be re-used instead of repeatedndash Example A binary tree in Fortran 77 required arrays while

in OO languages nodes with pointers may be used1 Abstract data typesndash implementation details are separated from the interface

allowing them to be changed without re-writing all code2 Objects3 Subprograms

Abstraction Increases Expressivity

bull Expressive language - has powerful built-in primitives for high-level abstractions

bull For example in Lispndash Pointer manipulation is implicit ndash avoid mistakesndash Mapcar ndash apply a function to every element of a list (and

return the corresponding results in a list)bull No need to write the iteration yourself ndash you would need to write

a different function for each different type of databull Infinite precision integers and rational numbersndash No need to develop functions yourselfndash Completely avoid round-off errors at will

bull Eg 23 + 13 = 1 not 999999

Reliability

bull A reliable program performs to its specifications under all conditions

bull Factors that affect reliability1 Type checking2 Exception handling3 Aliasing4 Readability and writability5 Environmental factors ndash real-time or safety-

critical application

Type Checking and Exception HandlingImprove Reliability

bull Type checkingndash Testing for type errors in a given programbull For example if a function is expecting an integer

receives a float instead

bull Exception handlingndash Used in Ada C++ Lisp and Java but not in C and

Fortranbull Eg the try and catch blocks of C++ can catch runtime

errors fix the problem and then continue the program without an ldquoabnormal endrdquo

Aliasing Reduces Readabilityand Reliability

bull Aliasingndash Referencing the same memory cell with more than

one namebull Eg in C both x and y can be used to refer to the same

memory cellint x = 5int y = ampx

ndash Leads to errorsbull Reliability increases with better readwritabilityndash If a program is difficult to read or write its easier to

make mistakes and more difficult to find them

Language Design Trade-offs

bull Reliability and cost ndash costs more to ensure greater reliabilityndash Example ndash type checkingbull In C the index ranges of arrays are not checkedbull So executes fast but it not so reliablebull On the other hand Java checks all references to array

elementsbull Java executes slower but is more reliable

Lecture Questions

bull What are 5 criteria used to evaluate languages

12345

Lecture Questions (cont)

bull How do think each of these affect software costndash Readabilityndash Writabilityndash Reliabilityndash Expressive Power

Form and Meaning of Code

bull Syntax of a language defines the legal statements that can be written ndash how it looks

bull Semantics of a language defines how the statements are executed ndash the results that are produced when the program runs

  • Language Evaluation Criteria of C++ Programming Language
  • Cost of Software
  • Costs over the Software Lifecycle (Generic model)
  • Relative Cost of 25 Each Phase of Software Development
  • Cost to Fix a Fault vs Development Phase
  • Readability of C++
  • Writability of C++ ndash Ease of Writing Programs
  • Simplicity Improves ReadWritability
  • Orthogonality
  • Orthogonality Improves ReadWritability
  • Structured Control Improves ReadWritability
  • Concise Data StructuresTypes Improve ReadWritability
  • Syntax and ReadWrite-ability
  • Abstraction
  • Abstraction Increases Expressivity
  • Reliability
  • Type Checking and Exception Handling Improve Reliability
  • Aliasing Reduces Readability and Reliability
  • Language Design Trade-offs
  • Lecture Questions
  • Lecture Questions (cont)
  • Form and Meaning of Code
Page 13: MELJUN CORTES -Programming Criteria

Syntax and ReadWrite-ability

bull Syntax - the way linguistic elements (eg words) are put together to form phrases or clausessentences

bull Identifier formsndash If too short reduces readability

bull Special word usendash Ada has end if and end loop while Java uses for

bothndash In Fortran 95 Do and End can also be variable names

bull Form and meaningndash In C static changes meaning depending on position

Abstraction

bull The ability to define and then use complex structures or operationsndash Allows details to be ignoredndash Allows code to be re-used instead of repeatedndash Example A binary tree in Fortran 77 required arrays while

in OO languages nodes with pointers may be used1 Abstract data typesndash implementation details are separated from the interface

allowing them to be changed without re-writing all code2 Objects3 Subprograms

Abstraction Increases Expressivity

bull Expressive language - has powerful built-in primitives for high-level abstractions

bull For example in Lispndash Pointer manipulation is implicit ndash avoid mistakesndash Mapcar ndash apply a function to every element of a list (and

return the corresponding results in a list)bull No need to write the iteration yourself ndash you would need to write

a different function for each different type of databull Infinite precision integers and rational numbersndash No need to develop functions yourselfndash Completely avoid round-off errors at will

bull Eg 23 + 13 = 1 not 999999

Reliability

bull A reliable program performs to its specifications under all conditions

bull Factors that affect reliability1 Type checking2 Exception handling3 Aliasing4 Readability and writability5 Environmental factors ndash real-time or safety-

critical application

Type Checking and Exception HandlingImprove Reliability

bull Type checkingndash Testing for type errors in a given programbull For example if a function is expecting an integer

receives a float instead

bull Exception handlingndash Used in Ada C++ Lisp and Java but not in C and

Fortranbull Eg the try and catch blocks of C++ can catch runtime

errors fix the problem and then continue the program without an ldquoabnormal endrdquo

Aliasing Reduces Readabilityand Reliability

bull Aliasingndash Referencing the same memory cell with more than

one namebull Eg in C both x and y can be used to refer to the same

memory cellint x = 5int y = ampx

ndash Leads to errorsbull Reliability increases with better readwritabilityndash If a program is difficult to read or write its easier to

make mistakes and more difficult to find them

Language Design Trade-offs

bull Reliability and cost ndash costs more to ensure greater reliabilityndash Example ndash type checkingbull In C the index ranges of arrays are not checkedbull So executes fast but it not so reliablebull On the other hand Java checks all references to array

elementsbull Java executes slower but is more reliable

Lecture Questions

bull What are 5 criteria used to evaluate languages

12345

Lecture Questions (cont)

bull How do think each of these affect software costndash Readabilityndash Writabilityndash Reliabilityndash Expressive Power

Form and Meaning of Code

bull Syntax of a language defines the legal statements that can be written ndash how it looks

bull Semantics of a language defines how the statements are executed ndash the results that are produced when the program runs

  • Language Evaluation Criteria of C++ Programming Language
  • Cost of Software
  • Costs over the Software Lifecycle (Generic model)
  • Relative Cost of 25 Each Phase of Software Development
  • Cost to Fix a Fault vs Development Phase
  • Readability of C++
  • Writability of C++ ndash Ease of Writing Programs
  • Simplicity Improves ReadWritability
  • Orthogonality
  • Orthogonality Improves ReadWritability
  • Structured Control Improves ReadWritability
  • Concise Data StructuresTypes Improve ReadWritability
  • Syntax and ReadWrite-ability
  • Abstraction
  • Abstraction Increases Expressivity
  • Reliability
  • Type Checking and Exception Handling Improve Reliability
  • Aliasing Reduces Readability and Reliability
  • Language Design Trade-offs
  • Lecture Questions
  • Lecture Questions (cont)
  • Form and Meaning of Code
Page 14: MELJUN CORTES -Programming Criteria

Abstraction

bull The ability to define and then use complex structures or operationsndash Allows details to be ignoredndash Allows code to be re-used instead of repeatedndash Example A binary tree in Fortran 77 required arrays while

in OO languages nodes with pointers may be used1 Abstract data typesndash implementation details are separated from the interface

allowing them to be changed without re-writing all code2 Objects3 Subprograms

Abstraction Increases Expressivity

bull Expressive language - has powerful built-in primitives for high-level abstractions

bull For example in Lispndash Pointer manipulation is implicit ndash avoid mistakesndash Mapcar ndash apply a function to every element of a list (and

return the corresponding results in a list)bull No need to write the iteration yourself ndash you would need to write

a different function for each different type of databull Infinite precision integers and rational numbersndash No need to develop functions yourselfndash Completely avoid round-off errors at will

bull Eg 23 + 13 = 1 not 999999

Reliability

bull A reliable program performs to its specifications under all conditions

bull Factors that affect reliability1 Type checking2 Exception handling3 Aliasing4 Readability and writability5 Environmental factors ndash real-time or safety-

critical application

Type Checking and Exception HandlingImprove Reliability

bull Type checkingndash Testing for type errors in a given programbull For example if a function is expecting an integer

receives a float instead

bull Exception handlingndash Used in Ada C++ Lisp and Java but not in C and

Fortranbull Eg the try and catch blocks of C++ can catch runtime

errors fix the problem and then continue the program without an ldquoabnormal endrdquo

Aliasing Reduces Readabilityand Reliability

bull Aliasingndash Referencing the same memory cell with more than

one namebull Eg in C both x and y can be used to refer to the same

memory cellint x = 5int y = ampx

ndash Leads to errorsbull Reliability increases with better readwritabilityndash If a program is difficult to read or write its easier to

make mistakes and more difficult to find them

Language Design Trade-offs

bull Reliability and cost ndash costs more to ensure greater reliabilityndash Example ndash type checkingbull In C the index ranges of arrays are not checkedbull So executes fast but it not so reliablebull On the other hand Java checks all references to array

elementsbull Java executes slower but is more reliable

Lecture Questions

bull What are 5 criteria used to evaluate languages

12345

Lecture Questions (cont)

bull How do think each of these affect software costndash Readabilityndash Writabilityndash Reliabilityndash Expressive Power

Form and Meaning of Code

bull Syntax of a language defines the legal statements that can be written ndash how it looks

bull Semantics of a language defines how the statements are executed ndash the results that are produced when the program runs

  • Language Evaluation Criteria of C++ Programming Language
  • Cost of Software
  • Costs over the Software Lifecycle (Generic model)
  • Relative Cost of 25 Each Phase of Software Development
  • Cost to Fix a Fault vs Development Phase
  • Readability of C++
  • Writability of C++ ndash Ease of Writing Programs
  • Simplicity Improves ReadWritability
  • Orthogonality
  • Orthogonality Improves ReadWritability
  • Structured Control Improves ReadWritability
  • Concise Data StructuresTypes Improve ReadWritability
  • Syntax and ReadWrite-ability
  • Abstraction
  • Abstraction Increases Expressivity
  • Reliability
  • Type Checking and Exception Handling Improve Reliability
  • Aliasing Reduces Readability and Reliability
  • Language Design Trade-offs
  • Lecture Questions
  • Lecture Questions (cont)
  • Form and Meaning of Code
Page 15: MELJUN CORTES -Programming Criteria

Abstraction Increases Expressivity

bull Expressive language - has powerful built-in primitives for high-level abstractions

bull For example in Lispndash Pointer manipulation is implicit ndash avoid mistakesndash Mapcar ndash apply a function to every element of a list (and

return the corresponding results in a list)bull No need to write the iteration yourself ndash you would need to write

a different function for each different type of databull Infinite precision integers and rational numbersndash No need to develop functions yourselfndash Completely avoid round-off errors at will

bull Eg 23 + 13 = 1 not 999999

Reliability

bull A reliable program performs to its specifications under all conditions

bull Factors that affect reliability1 Type checking2 Exception handling3 Aliasing4 Readability and writability5 Environmental factors ndash real-time or safety-

critical application

Type Checking and Exception HandlingImprove Reliability

bull Type checkingndash Testing for type errors in a given programbull For example if a function is expecting an integer

receives a float instead

bull Exception handlingndash Used in Ada C++ Lisp and Java but not in C and

Fortranbull Eg the try and catch blocks of C++ can catch runtime

errors fix the problem and then continue the program without an ldquoabnormal endrdquo

Aliasing Reduces Readabilityand Reliability

bull Aliasingndash Referencing the same memory cell with more than

one namebull Eg in C both x and y can be used to refer to the same

memory cellint x = 5int y = ampx

ndash Leads to errorsbull Reliability increases with better readwritabilityndash If a program is difficult to read or write its easier to

make mistakes and more difficult to find them

Language Design Trade-offs

bull Reliability and cost ndash costs more to ensure greater reliabilityndash Example ndash type checkingbull In C the index ranges of arrays are not checkedbull So executes fast but it not so reliablebull On the other hand Java checks all references to array

elementsbull Java executes slower but is more reliable

Lecture Questions

bull What are 5 criteria used to evaluate languages

12345

Lecture Questions (cont)

bull How do think each of these affect software costndash Readabilityndash Writabilityndash Reliabilityndash Expressive Power

Form and Meaning of Code

bull Syntax of a language defines the legal statements that can be written ndash how it looks

bull Semantics of a language defines how the statements are executed ndash the results that are produced when the program runs

  • Language Evaluation Criteria of C++ Programming Language
  • Cost of Software
  • Costs over the Software Lifecycle (Generic model)
  • Relative Cost of 25 Each Phase of Software Development
  • Cost to Fix a Fault vs Development Phase
  • Readability of C++
  • Writability of C++ ndash Ease of Writing Programs
  • Simplicity Improves ReadWritability
  • Orthogonality
  • Orthogonality Improves ReadWritability
  • Structured Control Improves ReadWritability
  • Concise Data StructuresTypes Improve ReadWritability
  • Syntax and ReadWrite-ability
  • Abstraction
  • Abstraction Increases Expressivity
  • Reliability
  • Type Checking and Exception Handling Improve Reliability
  • Aliasing Reduces Readability and Reliability
  • Language Design Trade-offs
  • Lecture Questions
  • Lecture Questions (cont)
  • Form and Meaning of Code
Page 16: MELJUN CORTES -Programming Criteria

Reliability

bull A reliable program performs to its specifications under all conditions

bull Factors that affect reliability1 Type checking2 Exception handling3 Aliasing4 Readability and writability5 Environmental factors ndash real-time or safety-

critical application

Type Checking and Exception HandlingImprove Reliability

bull Type checkingndash Testing for type errors in a given programbull For example if a function is expecting an integer

receives a float instead

bull Exception handlingndash Used in Ada C++ Lisp and Java but not in C and

Fortranbull Eg the try and catch blocks of C++ can catch runtime

errors fix the problem and then continue the program without an ldquoabnormal endrdquo

Aliasing Reduces Readabilityand Reliability

bull Aliasingndash Referencing the same memory cell with more than

one namebull Eg in C both x and y can be used to refer to the same

memory cellint x = 5int y = ampx

ndash Leads to errorsbull Reliability increases with better readwritabilityndash If a program is difficult to read or write its easier to

make mistakes and more difficult to find them

Language Design Trade-offs

bull Reliability and cost ndash costs more to ensure greater reliabilityndash Example ndash type checkingbull In C the index ranges of arrays are not checkedbull So executes fast but it not so reliablebull On the other hand Java checks all references to array

elementsbull Java executes slower but is more reliable

Lecture Questions

bull What are 5 criteria used to evaluate languages

12345

Lecture Questions (cont)

bull How do think each of these affect software costndash Readabilityndash Writabilityndash Reliabilityndash Expressive Power

Form and Meaning of Code

bull Syntax of a language defines the legal statements that can be written ndash how it looks

bull Semantics of a language defines how the statements are executed ndash the results that are produced when the program runs

  • Language Evaluation Criteria of C++ Programming Language
  • Cost of Software
  • Costs over the Software Lifecycle (Generic model)
  • Relative Cost of 25 Each Phase of Software Development
  • Cost to Fix a Fault vs Development Phase
  • Readability of C++
  • Writability of C++ ndash Ease of Writing Programs
  • Simplicity Improves ReadWritability
  • Orthogonality
  • Orthogonality Improves ReadWritability
  • Structured Control Improves ReadWritability
  • Concise Data StructuresTypes Improve ReadWritability
  • Syntax and ReadWrite-ability
  • Abstraction
  • Abstraction Increases Expressivity
  • Reliability
  • Type Checking and Exception Handling Improve Reliability
  • Aliasing Reduces Readability and Reliability
  • Language Design Trade-offs
  • Lecture Questions
  • Lecture Questions (cont)
  • Form and Meaning of Code
Page 17: MELJUN CORTES -Programming Criteria

Type Checking and Exception HandlingImprove Reliability

bull Type checkingndash Testing for type errors in a given programbull For example if a function is expecting an integer

receives a float instead

bull Exception handlingndash Used in Ada C++ Lisp and Java but not in C and

Fortranbull Eg the try and catch blocks of C++ can catch runtime

errors fix the problem and then continue the program without an ldquoabnormal endrdquo

Aliasing Reduces Readabilityand Reliability

bull Aliasingndash Referencing the same memory cell with more than

one namebull Eg in C both x and y can be used to refer to the same

memory cellint x = 5int y = ampx

ndash Leads to errorsbull Reliability increases with better readwritabilityndash If a program is difficult to read or write its easier to

make mistakes and more difficult to find them

Language Design Trade-offs

bull Reliability and cost ndash costs more to ensure greater reliabilityndash Example ndash type checkingbull In C the index ranges of arrays are not checkedbull So executes fast but it not so reliablebull On the other hand Java checks all references to array

elementsbull Java executes slower but is more reliable

Lecture Questions

bull What are 5 criteria used to evaluate languages

12345

Lecture Questions (cont)

bull How do think each of these affect software costndash Readabilityndash Writabilityndash Reliabilityndash Expressive Power

Form and Meaning of Code

bull Syntax of a language defines the legal statements that can be written ndash how it looks

bull Semantics of a language defines how the statements are executed ndash the results that are produced when the program runs

  • Language Evaluation Criteria of C++ Programming Language
  • Cost of Software
  • Costs over the Software Lifecycle (Generic model)
  • Relative Cost of 25 Each Phase of Software Development
  • Cost to Fix a Fault vs Development Phase
  • Readability of C++
  • Writability of C++ ndash Ease of Writing Programs
  • Simplicity Improves ReadWritability
  • Orthogonality
  • Orthogonality Improves ReadWritability
  • Structured Control Improves ReadWritability
  • Concise Data StructuresTypes Improve ReadWritability
  • Syntax and ReadWrite-ability
  • Abstraction
  • Abstraction Increases Expressivity
  • Reliability
  • Type Checking and Exception Handling Improve Reliability
  • Aliasing Reduces Readability and Reliability
  • Language Design Trade-offs
  • Lecture Questions
  • Lecture Questions (cont)
  • Form and Meaning of Code
Page 18: MELJUN CORTES -Programming Criteria

Aliasing Reduces Readabilityand Reliability

bull Aliasingndash Referencing the same memory cell with more than

one namebull Eg in C both x and y can be used to refer to the same

memory cellint x = 5int y = ampx

ndash Leads to errorsbull Reliability increases with better readwritabilityndash If a program is difficult to read or write its easier to

make mistakes and more difficult to find them

Language Design Trade-offs

bull Reliability and cost ndash costs more to ensure greater reliabilityndash Example ndash type checkingbull In C the index ranges of arrays are not checkedbull So executes fast but it not so reliablebull On the other hand Java checks all references to array

elementsbull Java executes slower but is more reliable

Lecture Questions

bull What are 5 criteria used to evaluate languages

12345

Lecture Questions (cont)

bull How do think each of these affect software costndash Readabilityndash Writabilityndash Reliabilityndash Expressive Power

Form and Meaning of Code

bull Syntax of a language defines the legal statements that can be written ndash how it looks

bull Semantics of a language defines how the statements are executed ndash the results that are produced when the program runs

  • Language Evaluation Criteria of C++ Programming Language
  • Cost of Software
  • Costs over the Software Lifecycle (Generic model)
  • Relative Cost of 25 Each Phase of Software Development
  • Cost to Fix a Fault vs Development Phase
  • Readability of C++
  • Writability of C++ ndash Ease of Writing Programs
  • Simplicity Improves ReadWritability
  • Orthogonality
  • Orthogonality Improves ReadWritability
  • Structured Control Improves ReadWritability
  • Concise Data StructuresTypes Improve ReadWritability
  • Syntax and ReadWrite-ability
  • Abstraction
  • Abstraction Increases Expressivity
  • Reliability
  • Type Checking and Exception Handling Improve Reliability
  • Aliasing Reduces Readability and Reliability
  • Language Design Trade-offs
  • Lecture Questions
  • Lecture Questions (cont)
  • Form and Meaning of Code
Page 19: MELJUN CORTES -Programming Criteria

Language Design Trade-offs

bull Reliability and cost ndash costs more to ensure greater reliabilityndash Example ndash type checkingbull In C the index ranges of arrays are not checkedbull So executes fast but it not so reliablebull On the other hand Java checks all references to array

elementsbull Java executes slower but is more reliable

Lecture Questions

bull What are 5 criteria used to evaluate languages

12345

Lecture Questions (cont)

bull How do think each of these affect software costndash Readabilityndash Writabilityndash Reliabilityndash Expressive Power

Form and Meaning of Code

bull Syntax of a language defines the legal statements that can be written ndash how it looks

bull Semantics of a language defines how the statements are executed ndash the results that are produced when the program runs

  • Language Evaluation Criteria of C++ Programming Language
  • Cost of Software
  • Costs over the Software Lifecycle (Generic model)
  • Relative Cost of 25 Each Phase of Software Development
  • Cost to Fix a Fault vs Development Phase
  • Readability of C++
  • Writability of C++ ndash Ease of Writing Programs
  • Simplicity Improves ReadWritability
  • Orthogonality
  • Orthogonality Improves ReadWritability
  • Structured Control Improves ReadWritability
  • Concise Data StructuresTypes Improve ReadWritability
  • Syntax and ReadWrite-ability
  • Abstraction
  • Abstraction Increases Expressivity
  • Reliability
  • Type Checking and Exception Handling Improve Reliability
  • Aliasing Reduces Readability and Reliability
  • Language Design Trade-offs
  • Lecture Questions
  • Lecture Questions (cont)
  • Form and Meaning of Code
Page 20: MELJUN CORTES -Programming Criteria

Lecture Questions

bull What are 5 criteria used to evaluate languages

12345

Lecture Questions (cont)

bull How do think each of these affect software costndash Readabilityndash Writabilityndash Reliabilityndash Expressive Power

Form and Meaning of Code

bull Syntax of a language defines the legal statements that can be written ndash how it looks

bull Semantics of a language defines how the statements are executed ndash the results that are produced when the program runs

  • Language Evaluation Criteria of C++ Programming Language
  • Cost of Software
  • Costs over the Software Lifecycle (Generic model)
  • Relative Cost of 25 Each Phase of Software Development
  • Cost to Fix a Fault vs Development Phase
  • Readability of C++
  • Writability of C++ ndash Ease of Writing Programs
  • Simplicity Improves ReadWritability
  • Orthogonality
  • Orthogonality Improves ReadWritability
  • Structured Control Improves ReadWritability
  • Concise Data StructuresTypes Improve ReadWritability
  • Syntax and ReadWrite-ability
  • Abstraction
  • Abstraction Increases Expressivity
  • Reliability
  • Type Checking and Exception Handling Improve Reliability
  • Aliasing Reduces Readability and Reliability
  • Language Design Trade-offs
  • Lecture Questions
  • Lecture Questions (cont)
  • Form and Meaning of Code
Page 21: MELJUN CORTES -Programming Criteria

Lecture Questions (cont)

bull How do think each of these affect software costndash Readabilityndash Writabilityndash Reliabilityndash Expressive Power

Form and Meaning of Code

bull Syntax of a language defines the legal statements that can be written ndash how it looks

bull Semantics of a language defines how the statements are executed ndash the results that are produced when the program runs

  • Language Evaluation Criteria of C++ Programming Language
  • Cost of Software
  • Costs over the Software Lifecycle (Generic model)
  • Relative Cost of 25 Each Phase of Software Development
  • Cost to Fix a Fault vs Development Phase
  • Readability of C++
  • Writability of C++ ndash Ease of Writing Programs
  • Simplicity Improves ReadWritability
  • Orthogonality
  • Orthogonality Improves ReadWritability
  • Structured Control Improves ReadWritability
  • Concise Data StructuresTypes Improve ReadWritability
  • Syntax and ReadWrite-ability
  • Abstraction
  • Abstraction Increases Expressivity
  • Reliability
  • Type Checking and Exception Handling Improve Reliability
  • Aliasing Reduces Readability and Reliability
  • Language Design Trade-offs
  • Lecture Questions
  • Lecture Questions (cont)
  • Form and Meaning of Code
Page 22: MELJUN CORTES -Programming Criteria

Form and Meaning of Code

bull Syntax of a language defines the legal statements that can be written ndash how it looks

bull Semantics of a language defines how the statements are executed ndash the results that are produced when the program runs

  • Language Evaluation Criteria of C++ Programming Language
  • Cost of Software
  • Costs over the Software Lifecycle (Generic model)
  • Relative Cost of 25 Each Phase of Software Development
  • Cost to Fix a Fault vs Development Phase
  • Readability of C++
  • Writability of C++ ndash Ease of Writing Programs
  • Simplicity Improves ReadWritability
  • Orthogonality
  • Orthogonality Improves ReadWritability
  • Structured Control Improves ReadWritability
  • Concise Data StructuresTypes Improve ReadWritability
  • Syntax and ReadWrite-ability
  • Abstraction
  • Abstraction Increases Expressivity
  • Reliability
  • Type Checking and Exception Handling Improve Reliability
  • Aliasing Reduces Readability and Reliability
  • Language Design Trade-offs
  • Lecture Questions
  • Lecture Questions (cont)
  • Form and Meaning of Code