0% found this document useful (0 votes)
14 views

Design Criteria For Programming Languages

The document discusses many design criteria for programming languages including clarity, simplicity, efficiency of execution, writability, readability, reliability, implementability, maintainability, generality, orthogonality, uniformity, expressiveness, preciseness, machine independence, security, regularity, and extensibility.

Uploaded by

ririyoru
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
14 views

Design Criteria For Programming Languages

The document discusses many design criteria for programming languages including clarity, simplicity, efficiency of execution, writability, readability, reliability, implementability, maintainability, generality, orthogonality, uniformity, expressiveness, preciseness, machine independence, security, regularity, and extensibility.

Uploaded by

ririyoru
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 7

Design Criteria for Programming Languages

What are the goals of the language? Below are a list of guiding principles in the design of programming
languages. Most of which are listed in your textbook.
Principles may be conflicting. No language can accomplish all goals.

Language Goals
During 1950s--1960s - Compile programs to execute efficiently.

 There was a direct connection between language features and hardware - integers, reals, goto statements
 Programmers cheap;
 Machines expensive;
 Keep the machine busy

But today

 Compile programs that are built efficiently


 CPU power and memory very cheap
 Direct connection between language features and design concepts - encapsulation, records, inheritance,
functionality, assertions

General attributes of a good language


Clarity, simplicity, and unity - provides both a framework for thinking about algorithms and a means of
expressing those algorithms

Orthogonality -every combination of features is meaningful

Naturalness for the application - program structure reflects the logical structure of algorithm

Support for abstraction - program data reflects problem being solved

Ease of program verification - verifying that program correctly performs its required function

Programming environment - external support for the language

Portability of programs - transportability of the resulting programs from the computer on which they are
developed to other computer systems

Cost of use - program execution, program translation, program creation, and program maintenance
Efficiency of execution
This is the earliest of design criteria, because of small memories and slow execution.
FORTRAN had (has) statements that resembled machine instructions.

GOTO (10,20,30,40,50),I FORTRAN's "computed goto"

IF(A(I) - MID) 20,30,40 FORTRAN's "arithmetic if"

x <<= 3 C's bit pushing operators

Writability
This is the quality of expressivity in a language. Writability should be clear, concise, quick and correct

APL is an extreme case

A <- i 12 p 3 4 results in a 3x4 matrix initialized with consecutive integers:

[1 2 3 4]
[5 6 7 8]
[9 10 11 12]

LISP has simple, writable syntax in that data structures and program structures use same syntax.

(f a1 a2 a3 ... an) is the statement and functional syntax (function name and arguments follow)
(+ 12 total)

(1 2 3 4 (5 6 ) 7 (9 10))) is a data structure that can represent a tree like structure, nested lists, matrices, etc.

Readability
The quality of a language that enables the reader (even non-programmers) to understand the nature of the
computation or algorithm.

COBOL is the extreme example

IF NOT-END-OF-FILE-FLAG THEN
PERFORM 100-READ-NEXT-DATA-SET
VARYING I FROM 1 TO 10
AT END PERFORM 999-UNEXPECTED-EOF.

Efficient executable code


Optimizability:

 statically declared variables (vs stack based variables) are easy to reference
 constants (#define)
 register variables
 ++ (add 1 operation)

Efficiency of translation
How fast is the compiler or interpreter?

Pascal is easy

 1 pass compilation is possible


 "define it before you use it" rule

Algol has some slow features

 call-by-name parameter passing


 procedural parameters (in Pascal too)

Reliabililty
Assurance that a program does not behave unexpectedly.
e.g. array bounds checking

 can be done statically in some cases


 or generate code to watch for out of bounds

Implementability
This is the efficiency with which a translator can be written

 Algol as designed was a stack based language but computers at the time didn't have stacks as part of the
architecture
 recursion implementation is difficult without a stack
 FORTRAN EQUIVALENCE statement (a classic algorithms problem)

Maintainability
The ease of which errors can be found and corrected and new features added
This supplants writability.
Consider C++, Java, Ada and Modula-3

 modules and packages


 information hiding
 software engineering techniques

Generality
The avoidance of special cases and generalizing related constructs into one construct

 Pascal has 3 different loop structures (while, repeat, and for)--not a good example of generality
 Ada has 1 loop structure with variations -- a good example of generality

loop ... end loop

for i=1..n loop ... end loop

while cond loop ... end loop


Orthogonality
Independent functions should be controlled by independent mechanisms

 constructs should not behave differently in different contexts


 the interaction between two independent functions should be a useful feature
 every combination of features is meaningful

Example of Pascal's data types and input/output (C is similar)

Data Type I/O

char yes

integer yes

real yes

boolean yes

enum no

Benefit of Orthogonality for Programmers

 m options on x axis
 n options on y axis
 mn interactions
 m+n facts to learn
 e exceptions
 m+n+e facts and exceptions to be learned
 mn-e features
 want m+n+e << mn-e

Uniformity
The consistency of appearance and behavior of language constructs

Pascal, for example

 REPEAT-UNTIL vs WHILE DO BEGIN ... END


 ; terminator vs separator

Simplicity
keep it simple

 Pascal's success
 BASIC was simple but lacked declarations and blocks
 Java tried to simplify C++

Expressiveness
Having enough features to be available as needed for the realm of applications

Preciseness
A measure of how well a language has features for slight variations

Machine independence (portability)


The features of a language should not be developed with a bias for a particular machine

Security
Language violations of definition should not escape detection

 e.g. FORTRAN separate compilations

1. may have a mismatch of parameters to arguments


2. reason for C prototypes

Regularity (consistency)
Having consistency with accepted notations and conventions

 e.g. free format and fixed format

FORTRAN classic (also example of orthogonal problems)


DO 99 I=1.100
Extensibility
The ability to add features to the language

 MACROs in assembler
 #define in C
 FORTH allows definition of new structures
 LISP allow definition of new functions (everything is a function)
 operator overloading in Ada and C++
 class definitions in object oriented languages

You might also like