Presentation is loading. Please wait.

Presentation is loading. Please wait.

Chapter 1: Preliminaries Lecture # 2. Chapter 1: Preliminaries Reasons for Studying Concepts of Programming Languages Programming Domains Language Evaluation.

Similar presentations


Presentation on theme: "Chapter 1: Preliminaries Lecture # 2. Chapter 1: Preliminaries Reasons for Studying Concepts of Programming Languages Programming Domains Language Evaluation."— Presentation transcript:

1 Chapter 1: Preliminaries Lecture # 2

2 Chapter 1: Preliminaries Reasons for Studying Concepts of Programming Languages Programming Domains Language Evaluation Criteria Influences on Language Design Language Categories Language Design Tradeoffs Implementation Methods Programming Environments

3 Language Evaluation Criteria 1. Readability: 1. Readability: the ease with which programs can be read and understood. 2. Writability: 2. Writability: the ease with which a language can be used to create programs. 3. Reliability: 3. Reliability: performs to its specifications under all conditions. 4. Cost: 4. Cost: the ultimate total cost of a programming language. 5. Others.

4 Readability Overall simplicity. Orthogonality. Control statements. Data types and structures. Syntax considerations.  The following characteristics contribute to the readability of a programming language:

5 Readability: Overall simplicity Few clear constructs each with unique meaning.  A language with a large number of components is more difficult to learn than one with fewer components. Few feature multiplicity  Features doing the same operation.  Incrementation in C: x++ ; ++x ; x=x+1 ; x+=1 ; Operator overloading can reduce readability.

6 Readability: Orthogonality A relatively small set of primitive constructs can be combined in a relatively small number of ways (consistent rules) to build the control and data structures of the language. Every possible combination of primitives is legal and meaningful. Example: Suppose a language has  4 primitive data types: int, float, double, char  2 type operators: array and pointer  If the 2 type operators can be applied to themselves and the 4 data types, a large number of data structures is possible.

7 Readability: Orthogonality, cont. The more orthogonal the design, the fewer exceptions the language rules require. Example of lack of orthogonality in C:  There are 2 kinds of structured data types, arrays and structs; structs can be returned from functions, but arrays cannot.  Parameters are passed by value, except for arrays, which are passed by reference.

8 Readability: Orthogonality, cont. Too much orthogonality can cause problems, such as in ALGOL 68 which had an explosion of combinations. Functional programming languages such as LISP offer a good mix of simplicity and orthogonality.

9 Readability: Control statements The relatively recent introduction of control constructs was a reaction to the indiscriminate use of the goto statement. FORTRAN 77 had no while loop  To implement a while construct, an IF statement and a restricted GOTO were used: 20 IF (X.LT. 10) GOTO 30 -- statements inside “loop” GOTO 20 30 -- first statement after loop

10 Readability: Data types and structures Features for user-defined data types enhance readability. Record types for storing employee info vs. a collection of related arrays. CHARACTER (LEN = 30) NAME(100) INTEGER AGE(100) INTEGER EMPLOYEE_NUMBER(100) REAL SALARY(100)

11 Readability: Syntax considerations Identifier forms  Restricting identifiers to very short length detracts from readability.  FORTRAN 77: at most 6 chars, blanks ignored.  Original ANSI Basic: a single letter or a single letter followed by a single digit.

12 Readability: Syntax considerations, cont. Special words  Such as if, for, while, class, …  Method for forming compound statements: Pascal: begin... End C: {... } Ada: if... end if, loop... end loop Form and meaning  Semantics should follow from syntax.

13 Writability Simplicity and Orthogonality. Support of Abstraction. Expressivity.  The following characteristics influencing the writability of a language:

14 Writability Simplicity and Orthogonality. Support for abstraction:  Abstraction means the ability to define and use complex structures or operations in ways that allow details to be ignored.  Programming languages can support tow distinct categories of abstraction:  Process abstraction: An example of process abstraction is the use of a subprogram to implement a sort algorithm.  Data abstraction: An example of data abstraction is a binary tree that stores integer data in its nodes.

15 Writability, cont Expressivity  A set of relatively convenient ways of specifying computations.  APL language has powerful operators which make it easy to accomplish a lot of computation in a small program.  In C language, the notation count++ is more easier and shorter than count = count + 1.  Also, the and then Boolean operator in Ada is a convenient way of specifying short-circuit evaluation of a Boolean expression.  In Java, writing for statements for counting loops easier than with the use of while.

16 Reliability Type checking. Exception handling. Aliasing. Readability and writability.  The following characteristics have a significant effect on the reliability of programs in a given language:

17 Reliability Type checking  Type checking is testing for type errors in a given program, either by the compiler or during program execution.  The design of Java requires checks of the types of all variables and expressions at compile time.  In C language (1978), the type of an actual parameter in a function call was not checked to determine whether its type matched that of the corresponding formal parameter in the function.

18 Exception handling  The ability of a program to intercept run-time errors, take corrective measures, and then continue processing.  Ada, C++, and Java include extensive capabilities for exception handling.  But such facilities are practically nonexistent in many languages such as C and Fortran. Reliability, cont.

19 Aliasing  Aliasing is having two or more distinct names that can be used to access the same memory cell.  Aliasing is a dangerous feature in a programming language.  For example in most languages: two pointers set to point to the same variable. Readability and writability  Programs that are difficult to read are difficult to modify.  Programs that are easier to write is more likely easier to be correct.

20 Cost Cost of training programmers. Cost of writing programs. Cost of compiling programs. Cost of executing programs. Cost of the language implementation system. Cost of poor reliability. Cost of maintaining programs.

21 Evaluation Criteria: Others Portability  Programs that can be run on different machines. Generality  The applicability to a wide range of applications. Well-definedness  The completeness and precision of the language’s official defining document.


Download ppt "Chapter 1: Preliminaries Lecture # 2. Chapter 1: Preliminaries Reasons for Studying Concepts of Programming Languages Programming Domains Language Evaluation."

Similar presentations


Ads by Google