You are on page 1of 28

Readability

One of the most important criteria for judging a programming language is the ease with which programs can be read and understood. Before 1970, software development was largely thought of in terms of writing code. The primary positive characteristics of programming languages were efficiency and machine readability.

Readability-I
Language Constructs were designed more from the point of view of the computer than of computer users. In 1970s, the software lifecycle concept was developed; Coding has much smaller role and maintenance was recognized as the major part of the cycle, especially in terms of cost. Ease of maintenance is determined in large part by the readability of programs. Readability became an important measure of the quality of programs and programming languages.

(a) Overall Simplicity


The Overall simplicity of a programming language strongly affect its readability. A language that has a large number of basic constructs is more difficult to learn than one with smaller number of them. Programmers who must use a large language often learn a subset of the language and ignore its other features. This learning pattern is sometimes used to excuse the large number of language constructs, but that argument is not valid. Readability problems occur whenever the programs author has learned a different subset from that subset with which the reader is familiar.

(a) Overall Simplicity-I


Another complicating characteristics of a programming language is feature multiplicity that is having more than one way to accomplish a particular operation. For example in java a user can increment a simple integer variable in four different ways: count = count + 1; count += 1; count++; ++count; All four have same meaning when used as stand alone expressions.

(a) Overall Simplicity-II


A third potential problem is operator overloading in which a single operator symbol has more than one meaning.

(b) Orthogonality
The meaning of an orthogonal language feature is independent of the context of its appearance in a program. Orthogonality follows from a symmetry of relationships among primitives. Pointer should be able to point to any type of variable or data structure. The lack of orthogonality lead to exceptions to the rules of the language. For example if pointers were not allowed to point to arrays, many of those possibilities would be eliminated.

(b) Orthogonality-I
Lack of orthogonality in a high level language, consider the following rules and exceptions in C. Records can be returned from function but arrays cannot. A member of structure can have any data type except void. Parameters pass by value but arrays pass by reference.

(b) Orthogonality-II
Too much orthogonality can also cause the problems. ALGOL 68 is too much orthogonal.

(c) Control Statements


The structured programming revolution of the 1970s was in part a reaction to the poor readability caused by the inadequate control statements of some of the languages of the 1950s and 1960s. In particular, it became widely recognized that indiscriminate use of goto statements severely reduces program readability. A program that can be read from top to bottom is much easier to understand than a program that requires the reader to jump from one statement to some nonadjacent statement in order to follow the execution order.

(c) Control Statements-I


while (incr < 20) { while (sum <= 100) { sum+= incr; } incr++; } Loop1: if (incr >= 20) goto out; Loop2: if (sum > 100) goto next; sum+=incr; goto loop2; Next: incr++; goto loop1; Out:

(c) Control Statements-II


The versions of BASIC and Fortran that were available in the early 1970s lacked the control statements that allow strong restrictions on the use of gotos, so writing highly readable programs in those languages was difficult.

(d) Data Types and Structures


The presence of adequate facilities for defining data types and data structure in a language is another significant aid to readability. For example suppose a numeric type is used for an indicator flag because there is no Boolean type in the language. In such a language an assignment such as: timeOut = 1; Whose meaning is unclear whereas in a language that includes Boolean types we would have timeOut = true; Whose meaning is perfectly clear.

(e) Syntax Design


The syntax or form of the elements of a language has a significant effect on the readability of programs. Identifier Forms: Restricting Identifier to very short lengths detracts from readability. If identifier can have six characters at most as in Fortran77 it is often impossible to use meaningful names for variables.

(e) Syntax Design


Special Words: Program appearance and thus program readability are strongly influenced by the forms of a languages special words for example while, class, for etc. Ada uses end if, end loop.

Writability
Writability is a measure of how easily a programming language can be used to create program for a chosen problem domain. Most of the language characteristics that affect readability also affect writability. This follows directly from the fact that the process of writing a program requires the programmer frequently to reread the part of the program that is already written.

Writability-I
Readability and writability must be considered in the context of the target problem domain of a language. It is simply not reasonable to compare the writability of two languages. For example the writabilities of COBOL and Fortran are dramatically different for creating a program to deal with two dimensional arrays for which Fortran is ideal. Their writabilities are also quite different for producing financial reports with complex formats, for which COBOL was designed.

(a) Simplicity and Orthogonality


A smaller set of primitive constructs and a consistent set of rules for combining them is much better than simply having a large number of primitives. A programmer can design a solution to a complex problem after learning only a simple set of primitive constructs. Too much orthogonality can be detriment to writability. Errors in programs can go undetected when nearly any combination of primitives is legal. This can lead to irrationality in code that cannot be discovered by the compiler.

(b) Support for Abstraction


Abstraction means the ability to define and then use complicated structures or operations in ways that allow many of the details to be ignored. Abstraction is a key concept in contemporary programming language design. The degree of abstraction in modern programming languages are very important for its writability. Programming languages can support two distinct categories of abstraction: 1)Process 2)Data

(b) Support for Abstraction-I


A simple example of process abstraction is the use of subprogram. Binary tree that store the data in its node is an example of data abstraction. The overall support for abstraction is clearly an important factor in the writability of a language.

(c) Expressivity
Expressivity in a language can refer to several different characteristics. APL is very powerful for writing mathematical expressions. In C the notation count++ is more expressive than count = count + 1 In Java for loop is easier than while. All increase the writability of a language.

Reliability
A program is said to be reliable if it performs to its specifications under all conditions. The following language features have significant effect on the reliability of program: (a)Type Checking (b)Exception Handling (c)Aliasing (d)Readability and Writability

(a) Type Checking


Type checking is an important factor in language reliability. Type checking is simply testing for type errors in a given program either by compiler or during program execution. Runtime type checking is expensive compile time type checking is more desirable. The earlier errors in programs are detected, the less expensive it is to make the required repairs. The design of Java requires checks of the types of nearly all variables and expressions at compile time.

(b) Exception Handling


The ability of a program to intercept runtime errors as well as other unusual conditions detected by the program take corrective measures and then continue is an obvious aid to reliablity. This language facility is called exception handling and present in Ada, C++ and Java and not present in C and Fortran.

(c) Aliasing
Loosely defined aliasing is having two or more distinct names that can be used to access the same memory cell. It is now widely accepted that aliasing is a dangerous feature in a programming language. Most programming languages allow some kind of aliasing e.g. two pointers set to point to the same variable. In such a program the programmer must always remember that changing the value pointed to by one of the two changes the value referenced by the other. In some languages aliasing is used to overcome deficiencies in the languages data abstraction facilities. Other languages greatly restrict aliasing to increase their reliability.

(d) Readability and Writability


Both readability and writability influence reliability. A program written in a language that does not support natural ways to express the required algorithms will use unnatural approaches. Unnatural approaches are less likely to be correct for all possible situations. Readability affects reliability in both the writing and maintenance phases of the life cycle.

Cost
The ultimate total cost of a programming language is a function of many of its characteristics. First, there is the cost of training programmers to use the language (depends upon simplicity and orthogonality of programming language). Second is the cost of writing programs in the language. Both the above two cost can be significantly reduce with good programming environment. Third is the cost of compiling programs in the language. For example high cost of running first generation Ada compilers. Fourth the cost of executing programs written in a language is greatly influenced by that language design. A language that require many runtime type checks will prevent fast code execution regardless of the quality of the compiler.Execution efficiency foremost concern in the design of early languages.

Fifth factor is the cost of the language implementation system. Java is an open source language. Python is an open source language. Sixth is the cost of poor reliability. If software fails in a critical or even the non-critical systems the cost could be very high. The final consideration is the cost of maintenance. Maintenance depends upon number of language characteristics. The primary characteristic is readability.

Conclusion
Language design criteria are weighed differently from different point of view. Language implementers are concerned primarily with the difficulty of implementing the constructs and features of the language. Language users are worried about writability first and readability later. Language designer the ability to reuse. These characteristics sometimes conflict with one another.

You might also like