View
215
Download
1
Category
Preview:
Citation preview
Language Evaluation Criteria
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
bull Code easyfast - to read and understandbull Language factors that affect readability
1 Overall language simplicity2 Orthogonality3 Control statements built-in4 Data types amp structures built-in5 Syntax considerations ndash closeness to natural
language andor mathematics
Writability 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
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
bull Code easyfast - to read and understandbull Language factors that affect readability
1 Overall language simplicity2 Orthogonality3 Control statements built-in4 Data types amp structures built-in5 Syntax considerations ndash closeness to natural
language andor mathematics
Writability 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
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
bull Code easyfast - to read and understandbull Language factors that affect readability
1 Overall language simplicity2 Orthogonality3 Control statements built-in4 Data types amp structures built-in5 Syntax considerations ndash closeness to natural
language andor mathematics
Writability 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
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
bull Code easyfast - to read and understandbull Language factors that affect readability
1 Overall language simplicity2 Orthogonality3 Control statements built-in4 Data types amp structures built-in5 Syntax considerations ndash closeness to natural
language andor mathematics
Writability 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
Cost to Fix a Fault vs Development Phase
Readability
bull Code easyfast - to read and understandbull Language factors that affect readability
1 Overall language simplicity2 Orthogonality3 Control statements built-in4 Data types amp structures built-in5 Syntax considerations ndash closeness to natural
language andor mathematics
Writability 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
Readability
bull Code easyfast - to read and understandbull Language factors that affect readability
1 Overall language simplicity2 Orthogonality3 Control statements built-in4 Data types amp structures built-in5 Syntax considerations ndash closeness to natural
language andor mathematics
Writability 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
Writability 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
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
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
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
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
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
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
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
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
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
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
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 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
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
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
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
Recommended