CH/S7CS/Nov., 2002
Language Evaluation Criteria (For Reference Only) Readability -
The ease with which programs can be read and understood.
-
A number of characteristics of programming languages contribute to their readability:
-
Overall simplicity
-
A language that has a large number of elementary components is usually more difficult to learn than one with a small number of elementary components.
-
Another problem is feature multiplicity, i.e. having more than one way to accomplish a particular operation.
E.g. In C, a user can increment a simple integer variable in four different ways,
count = count +1
count++
++count
count += 1
-
A third problem is operator overloading, in which single operator symbol has more than one meaning
E.g. Overloading the operator ‘+’ to mean simple integer or floating point addition, unary operation, the sum of all elements of two single-dimensional array and even vector addition.
Rem. : Language statements can also be simplified too much and reduce readability, e.g. assembly language.
-
Orthogonality
-
In a programming language, it means that there is a relatively small set of primitive constructs that can be combined in a relatively small number of ways to build the control and data structures of the language.
-
Furthermore, every possible combination is legal and meaningful -- a symmetry of relationship among primitives.
-
Example 1: Addition in the assembly languages of the IBM mainframe computers and the VAX series of super-minicomputer
In IBM mainframe,
A Reg, memory cell
AR Reg1, Reg2
Reg, Reg1 and Reg2 represent registers. The semantics of these are
Reg <--- contents(Reg) + contents(memory_cell)
Reg1 <--- contents(Reg1) + contents(Reg2)
In VAX machine,
ADDL operand_1, operand_2
whose semantic is
operand_2 <--- contents(operand_1) + contents(operand_2)
In this case, either operand can be a register or a memory cell.
The VAX instruction design is not orthogonal . There are two ways to specify operands, which can be combined in any way.
-
Example 2 : Pascal
-
Procedures can have both variable and value parameters.
-
Functions can return only unstructured types.
-
Formal parameter types must be named; they cannot be complete type descriptions.
-
Files and structured data cannot be passed by value.
Thus the type rules of Pascal are not orthogonal .
** Rem : The extreme form of orthogonality leads to unnecessary complexity.
-
Control Statements
-
The structured programming revolution of the 1970s was a reaction to the poor readability caused by the limited control structures of some of the languages of the 1950s and 1960s, e.g. BASIC and FORTRAN.
-
Early language lacks the control statements that allow strong restrictions on the use of GOTO, so writing highly readable programs in those languages was difficult.
-
Data Structures
-
Boolean variable
Using integer for flag,
Error = 1
which is ambiguous. Using Boolean,
Error = true
which is better.
-
A record data type provides a more readable way to represent employee records than a parallel array scheme. (data abstraction)
-
Syntax Consideration
-
Identifier forms
-
Restricting identifiers to very short forms detracts from readability. E.g. BASIC and FORTRAN.
-
The availability of connector characters, such as the underscore in identifiers is a great aid to readability.
-
Special words
-
Especially important is the method of forming compound statements, or statement groups, primarily in control constructs.
-
E.g. Pascal uses begin-end pairs and C uses braces ({}) for the same purpose. Both of these languages suffer because groups are always terminated in the same way, which makes it difficult to determine which group is being ended when an ‘end’ or ‘}’ is found.
FORTRAN - 77 and Ada make this clearer by using distinct closing syntax for each type of statement group, e.g. end if and end loop in Ada.
-
If the special words of a language can be used as names for program variables, the resulting programs can be very confusing.
-
Form and meaning
-
Designing statements so that their appearance at least partially indicates their action is an obvious aid to readability.
-
E.g. In FORTRAN,
go to (10, 20, 30), I
means that the variable I is used to stores a numeric value, while
go to I, (10, 20, 30)
means that it stores an label value.
Writability -
The ease with which a language can be used to create programs for a chosen problem area.
-
Most of the language characteristics that affect readability also affect writability.
-
Writability must be considered in the context of the target problem domain of a language.
-
The most important factors influencing the writability of a language:
-
Simplicity and Orthogonality
-
A large number of different constructs may lead to a misuse of some features and a disuse of others that may be either more elegant or more efficient, or both, than those that are used.
-
A smaller number of primitive constructs and a consistent set of rules for combining them (orthogonality) is much better than simply having a large number of primitive.
-
Support for Abstraction
-
Abstraction means that complicated structures or operations can be stated in simple ways by ignoring many of the details.
-
Example 1, the use of a subprogram to implement a sort algorithm that is required several times in a program.
-
Example 2, data abstraction, e.g. binary tree.
-
In FORTRAN, three parallel integer arrays is used.
-
In Pascal, an abstraction of a tree node in the form of a single record unit with two pointers and an integer.
Reliability -
A desirable goal of programming language design is to allow and encourage reliable programs, which will perform to its specifications under all conditions.
-
Several language features that affect the reliability:
-
Type checking
-
Type checking is the testing for type compatibility between two variables or a variable and a constant that are somehow involved with one another.
-
E.g. two sides of an operator, parameter correspondence.
-
Exception Handling. The ability of programs to interrupt run-time errors and other unusual conditions, to take corrective measures, and to continue is also a great aid to reliability. e.g. ON ERROR in BASIC
-
Aliasing
-
It is having two distinct referencing methods, or names for the same memory cell.
-
It is now widely accept that aliasing, without restriction, is too dangerous to justify its advantages.
-
Readability and Writability. A program written in a language that does not support natural way to express the required algorithms will necessarily use unnatural methods.
Cost -
Types of costs
-
Cost of training programmers to use the language
-
Cost of writing programs --> use high level language
-
Cost of compiling programs
-
Cost of executing programs. A language that requires many run-time type check, such as PL/1, will prohibit fast code execution.
-
Cost of maintaining programs <-- readability
-
There is a simple trade-off can be made between compilation cost and execution speed of the compiled code. The extra compilation effort results in much faster code execution.
** A final note on evaluation criteria: Most criteria, particularly readability and writability, are neither measurable nor scientifically defined.
Share with your friends: |