Download as ppt, pdf, or txt
Download as ppt, pdf, or txt
You are on page 1of 24

1

Chapter 3 – PL design

Outline
3.1 historical transition of design standard
3.2 efficiency
3.3 generality, orthogonality, uniformity
3.4 other design principles at PL
3.5 problem and solution
2

3.1 Historical transition of design standard (1)

Element of main language’s success (depended on external element)


Fortran – by sponsor of computer company
Cobol – by supporter of The Pentagon
Lisp – used by AI
Pascal – for education and role of standard language of microcomputer
PL/I – IBM’s support
C – success of UNIX OS
Ada – The Pentagon’s support

Goal of main language design


Fortran – efficiency of execution
Cobol – readability by syntax like English
Algol 60 – easy to write algorithm by block structure
Pascal – simple imperative language, top-down design
3

3.1 Historical transition of design standard (2)

In the 1950s
In the early 1950, the efficiency of execution was important

ex) Fortran

General principle was important by entering of Cobol and Algol 60

ex) Algol 60 : easy to make simple algorithm by block structure, recursive

Cobol : high readability (use syntax like English)

In the 1960s
complexity control ‘s necessary

abstraction, reduction of language' rule and limitation

ex) Simula 67 : afford strong abstraction

Algol 68 : reduction of complexity of language by affording generality,


orthogonality
4

3.1 Historical transition of design standard (3)

In the 1970s – In the early of 1980s


Focus on Simplicity and abstraction

ex) Pascal, C, Euclid, Modula-2, Ada

Introduction of mathematical definition

Improve reliability of program

In the 1980s
Insert logical and mathematical concept to language

Include logic to PL

Interest in functional language

ex) ML, Miranda, Scheme

Improve interesting in OOL

ex) C++
5

Principles of PL design

basic principles of language design


efficiency

generality

orthogonality

uniformity

other principles
- simplicity - security

- expressiveness - consistency with exiting transcription or rule

- preciseness - extensibility

- machine independence - restrictability, subset


6

3.2 Efficiency (1)

Classification by standard of efficiency

Efficiency of object code

Efficiency of translation

Efficiency of implementation

Efficiency of programming
7

3.2 Efficiency (2)

Efficiency of object code

Production of efficiency execution code of translator optimization

ex) In Pascal, constant is value itself.

constant identifier is assigned at the value in translation time

Efficiency of translation

Translate fast by translator of adequate size

ex) problem of passes of language translation

Pascal : single pass, Modula-2 : 2 pass (for identifier translation)


8

3.2 Efficiency (3)

Efficiency of implementation
Problem of translator’s efficiency implementation
ex) There is a case of language not to be succeeded because the implementation
of translator is too difficult or execution algorithm is not comprehended. (Algol
60: with stack based structure for real time system)

Efficiency of programming
Simplicity and easy of program compiling

Related with expression of language, abstraction mechanism

Ideal language : Lisp, Prolog because they are very simple and lots of parts are
executed at the execution time.

reliability : readability and ability of management


9

3.3 generality, orthogonality, uniformity (1)

generality, orthogonality, and uniformity are very related

Generality : ерөнхий зан чанарыг тодорхойлох

Orthogonality: тэгш өнцөгтэй байдал

uniformity
нэг төрлийн байдал
10

3.3 generality, orthogonality, uniformity (2)

Generality: to produce the general character to integrate lots of


characters
Example of lack of generality (1 of 2)
procedure
Pascal : allow declaration of procedure and parameter, prohibit
procedural variable
Modula-2 : can use procedural variable  generality
Ada : prohibit even the use of procedure having parameter
array
Pascal : prohibit dynamic array
C, Ada : allow dynamic array  generality
Modula-2, Fortran : prohibit delivering and declaration of dynamic array
11

3.3 generality, orthogonality, uniformity (3)

Example of lack of generality(2 of 2)

Equal operator, assignment operator (=, :=)


most of language : prohibit applying to array and record
Ada : allow to apply to array and record  generality

parameter
Fortran : allow only call by reference
Algol 68, C, Java : call by value, call by value by pointer to object generality
Ada : afford generality

constant
Fortran : no constant name
Pascal : no expression to constant
Ada : afford constant with generality
12

3.3 generality, orthogonality, uniformity (4)

Problem of generality

Low simplicity of language

Low readability of language

Low reliability of language


ex) pointer of C language (afford generality) : cause problem

Java doesn’t allow pointer : solve the problem of reliability and


readability

Pascal : limit using pointer to reduce the danger and aliasing


13

3.3 generality, orthogonality, uniformity (5)

Orthogonality: The meaning of an orthogonal language feature is

independent of the context of its appearance in a program.

Example of lack of orthogonality (1 of 2)

Data type of return value of function

Pascal : only scalar and pointer

C : except of array

Ada : afford complete orthogonality (allow all data types)


14

3.3 generality, orthogonality, uniformity (6)


Example of lack of orthogonality(2 of 2)
file
Pascal : file type is special state (prohibit procedure’s parameter and assign)
The most language : file is handled as a library (get out of non-orthogonality)

string
Modula-2 : use string (small string bigger string)

parameter
C : array - call by reference, remained all type is call by value
Ada : all data types - call by value, result, value-result (orthogonality)

★ The goal of Algol 68 : guarantee orthogonality


15

3.3 generality, orthogonality, uniformity (7)


Uniformity: Similar thing should be looked as similar and have
similar meaning whereas different thing should be looked as
different and have different behavior.
Example of lack of uniformity, non-harmony : Pascal (1 of 2)
if, while statement : begin-end structure demand, repeat statement : begin-
end structure no-demand
case statement, case control statement in variant record : it is similar (solve
in Modula-2)
Return of function – it looks like an assignment ( return at general language)
1 function f : boolean ;
2 begin  use return statement
3 ...
4 f := true ;
5 end;
16

3.3 generality, orthogonality, uniformity (8)

Example of lack of uniformity, non-harmony : Pascal (2 of 2)


: declaration of pointer( integer) and pointer value(x )
(In Modula-2, use POINTER TO in declaration part)
Semi-colon(;) : used as a separator and a terminator in Modula-2, Pascal.
(used in C as a terminator)

procedure p ; (* terminator *)
var x : integer ; (* separator *)
y : real ; (* terminator *)
begin
x := 0 ; (* separator *)
y := 1.0
end; (* terminator *)
Non-uniformity can be regarded as a non-orthogonality because non-uniformity is caused
only in the special statement.
17

3.4 Other design principles at PL (1)

Simplicity (энгийн хялбар байдал)


The main principle of Pascal is simplicity
generality, orthogonality, uniformity : not guarantee
simplicity ex) Algol 68
The language is not a simplicity even though having few of
compositions
ex) Lisp, Prolog : dependant on system and have
complicated execution time even having few of
compositions
The overall simplicity of a programming language
strongly affects its readability.
Extreme simplicity – disturbance at using language, lack
of expression, many limitations
18

3.4 Other design principles at PL (2)

Expressiveness (илэрхийлдэг байдал)

It means easy to express the structure and complicated process

Strong expressiveness but not simple : Lisp, Prolog, Algol 68

Strong expressiveness and simple : C language

ex) while ( * s++ == * t++) ;

Preciseness (нарийн тодорхойлох байдал)

Definition about language precisely Is there a definition


whether the behavior of language is guessed or not?

Definition about language precisely It influences on the


reliance of the language and the complier
19

3.4 Other design principles at PL (3)

machine independence

By the definition of language independent on the machine

Afford data types defined independently with allocation of


storage and the structure of machine

Security (аюулгүй байдал)

Goal: reduce the programming error and find the error easily

Related with the reliability and accuracy of the language

When the language is designed, data types and variable


declaration is introduced.
20

3.4 Other design principles at PL (4)


Consistency with rule (тогтвортой байдал)

When language is designed, it should have a standard character and


concept.

Algol 68 – this language doesn’t follow the standard description

ex) use mode instead of type

Extensibility (сунгаж татаж болох байдал)

Method which lets users add the character of the language.

Example having extensibility - Lisp

The extensibility of procedure language is more difficult than


functional language.

Abstract (data abstraction, control abstraction) concept support an


extensibility.
21

3.4 Other design principles at PL (5)

restrictability, subset (хязгаарлах чадвар)

Ability to program efficiently even having restrict an information and a


structure of language

Advantage of restrictability

Programmers don’t need to learn whole language to use the language


efficiently

Compiler maker can use and implement adopting the subset of the
language (support subset of language)

ex ) SP/1, SP/2 … SP/k : the subset of PL/I


22

3.5 problems and the solutions (1)


Advice for successful language design (1 of 2)
Reliability (найдвартай байдал)
Use check compiler for reliability of the program
Cornell : PL/I diagnostic, C language environment (include
debugger)
Efficient translation
The early HLL (Fortran, Cobol ...)
: afford spilt compile efficient translation is possible, error is
caused
Algol 68, Pascal(in the beginning of 1970s) : emphasize the
reliability combination compiler
Ada : harmony (the advantage of split compile + the
advantage of combination compile)
solve it the afford specification part, body part
23

3.5 problems and the solutions (2)

Advice for successful language design (2 of 2)

Code optimization (оновчлол)

Efficient object code

Increase compiling cost

Part optimization like repeat part good result

Real compiler : afford the many steps of optimization

reliability

Too extreme simplicity of the language semantics decrease the readability of


program.

Appropriate simplicity increase the program’s reliability to programmer.

APL, 4th generation language


24

3.5 problems and the solutions (3)


Advice for successful language design by C. A. R Hoare
(1) revise the specific feature of the language
(2) design new language (combine the specific features)

(1) revise the specific feature of the language


• the designer focuses on the one feature once
• implement the feature to well known language
• assure that the disadvantage of the language can be solved
• to be showed how this features are simple and efficient
• make use guide
• make many example programs (compare with other methods)

(2) design new language


• observe and select the specific features
• demand an ability to mediate between the features

• clear conception about new language’s scope

• afford real implementation and user guide (for beginner and advanced)

★ new language design job is only to combine the concepts to be existed.

You might also like