Programming Language Language Evaluation Criteria



Download 181.29 Kb.
Page1/5
Date28.01.2017
Size181.29 Kb.
#10755
  1   2   3   4   5

CH/S7CS/Nov., 2002

Programming Language

Language Evaluation Criteria (For Reference Only)

Readability


  1. The ease with which programs can be read and understood.

  2. A number of characteristics of programming languages contribute to their readability:

    1. Overall simplicity

      1. 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.

      2. 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

      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.

    1. Orthogonality

      1. 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.

      2. Furthermore, every possible combination is legal and meaningful -- a symmetry of relationship among primitives.

      3. 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.



      1. Example 2 : Pascal

        1. Procedures can have both variable and value parameters.

        2. Functions can return only unstructured types.

        3. Formal parameter types must be named; they cannot be complete type descriptions.

        4. 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.



    1. Control Statements

      1. 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.

      2. 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.

    2. Data Structures

      1. Boolean variable

Using integer for flag,

Error = 1

which is ambiguous. Using Boolean,

Error = true

which is better.


      1. A record data type provides a more readable way to represent employee records than a parallel array scheme. (data abstraction)

    1. Syntax Consideration

      1. Identifier forms

        1. Restricting identifiers to very short forms detracts from readability. E.g. BASIC and FORTRAN.

        2. The availability of connector characters, such as the underscore in identifiers is a great aid to readability.

      2. Special words

        1. Especially important is the method of forming compound statements, or statement groups, primarily in control constructs.

        2. 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.

        1. If the special words of a language can be used as names for program variables, the resulting programs can be very confusing.

      1. Form and meaning

        1. Designing statements so that their appearance at least partially indicates their action is an obvious aid to readability.

        2. 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


  1. The ease with which a language can be used to create programs for a chosen problem area.

  2. Most of the language characteristics that affect readability also affect writability.

  3. Writability must be considered in the context of the target problem domain of a language.

  4. The most important factors influencing the writability of a language:

    1. Simplicity and Orthogonality

      1. 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.

      2. 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.

    2. Support for Abstraction

      1. Abstraction means that complicated structures or operations can be stated in simple ways by ignoring many of the details.

      2. Example 1, the use of a subprogram to implement a sort algorithm that is required several times in a program.

      3. Example 2, data abstraction, e.g. binary tree.

        1. In FORTRAN, three parallel integer arrays is used.

        2. In Pascal, an abstraction of a tree node in the form of a single record unit with two pointers and an integer.

Reliability


  1. A desirable goal of programming language design is to allow and encourage reliable programs, which will perform to its specifications under all conditions.

  2. Several language features that affect the reliability:

    1. Type checking

      1. Type checking is the testing for type compatibility between two variables or a variable and a constant that are somehow involved with one another.

      2. E.g. two sides of an operator, parameter correspondence.

    2. 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

    3. Aliasing

      1. It is having two distinct referencing methods, or names for the same memory cell.

      2. It is now widely accept that aliasing, without restriction, is too dangerous to justify its advantages.

    4. 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


  1. Types of costs

    1. Cost of training programmers to use the language

    2. Cost of writing programs --> use high level language

    3. Cost of compiling programs

    4. Cost of executing programs. A language that requires many run-time type check, such as PL/1, will prohibit fast code execution.

    5. Cost of maintaining programs <-- readability

  2. 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.


Download 181.29 Kb.

Share with your friends:
  1   2   3   4   5




The database is protected by copyright ©ininet.org 2024
send message

    Main page