CS 528, Spring 2024, Lecture 3a

CS 528 Spring 2024, Lecture 3a

C.A.R. Hoare. Hints on Programming Language Design (PDF). October 1973. Chapter 13 of the book on "Essays in Computing Science" by C.A.R. Hoare and C.B. Jones, available in the ACM digital library.


Overall Approach


PL Design Philosophy

What are the most difficult aspects of programming?

Other aspects:

Discussion of good language design

Important features for a high-level language?


Program design --- what a program should do?

Formulating it as a clear, precise, and acceptable specification. Can we do this today? in which language?

A good programming language should give assistance in expressing not only how the program is to run, but what it is intended to accomplish; and it should enable this to be expressed at various levels, from the overall strategy to the details of coding and data representation.

It should assist in establishing and enforcing conventions and disciplines that will ensure harmonious co-operation of the parts of a large program when they are developed separately and finally assembed together.


What is the purpose of program documentation?

To explain to a human reader the way in which a program works so that it can be successfully adapted after it goes into service, to meet the changing requirements of its users, or to improve it in the light of increased knowledge, or just to remove latent errors and oversights.

A good programming language will encourage and assist the programmer to write clear self-documenting code.


Program debugging

No machine- or implementation-dependent effects (security).

Certain programming errors cannot always be detected in this way, and must be cheaply detectable at run time; in no case can they be allowed to give rise to machine- or implementation-dependent effects, which are inexplicable in terms of the language itself.

Definition of a safe program:

programs cannot corrupt the runtime system so that further execution of the program is not fairthful to language semantics.

The compiler must be utterly reliable and compact and fast.

A necessary condition: simplicity (to the extreme)

The true craftsman thoroughly understands his tools.

Machine and assembly code sets a high standard of simplicity


Discussion of good language design

Simplicity: modularity and orthogonality are an excellent means to an end, but not a substitute.

Security (safety): what is a secure language? is he criticizing dynamically typed language (checkout compiler)?

Fast compilation (important for debugging and for making frequent changes)

Efficient object code: some interesting arguments that language designer should not ignore machine inefficiency:

Optimization has grave disadvantages (reliability, correctness, unpredictability, removing from programmer his fundamental control and responsibility for the quality of his programs).


Structuring Arithmetic Expressions E1+E2

When the operands are too large, it is better to use updating operations.

Gap between mathematical expressions and programs

Efficiency problem related to diverse applications Solution: extensible languages


Other High-Level Language Features

Program structures (switch to case)

Variables

One of the most powerful and most dangerous aspects of machine-code programming: each instruction can change the content of any register or memory location and alter the condition of any peripheral ...

Block structures:

Procedures and parameters --- very important

Types --- compile-time type checking


Language Feature Design vs. Language Design

The difference between designing a language feature (in the context of a specific language) and designing a language (consolidation not innovation)


Copyright (c) 2009-2024, Zhong Shao, Dept. of Computer Science, Yale University.