Date post: | 17-Jan-2016 |
Category: |
Documents |
Upload: | marshall-black |
View: | 213 times |
Download: | 1 times |
What Makes a Good Language?
Lecture 3
The first formal languages
The evolution of writing systems to record language reveals the first steps toward formal notation and unambiguous communication.
The world’s oldest written documents are in Sumerian - small 3 dimensional tokens used for counting things like grain, wine and cattle
At first writing was composed of individual pictographs
The first formal languages
Gradually civilization moved to ideographs, symbols for ideas
meaning understood by convention, not by the picture
earliest known algorithms are due to Babylonians - a base 60 notation for arithmetic, including fractions
Designs of High-level Computer Languages Mechanisms to design still must be perfected every known language has its shortcomings usually the more popular languages have
less shortcomings
Popularity
some reasons for success or failure of language may be external :
a government mandate (COBOL or Ada) strong computer manufacturer support
(FORTRAN) excellent text (Griswold’s SNOBOL4 text) use as theoretical study (Pascal and LISP)
Attributes of a Good Language
Clarity, simplicity, and unity language provides both a conceptual framework for
thinking about algorithms and a way of expressing aid the programmer before coding unified set of primitives used in developing algorithms conceptual integrity - minimum number of different
concepts and rules for combining to be as simple and regular as possible
FORTRAN had 3 but not higher dimensional arrays
Syntax Affects the ease with which a program may be
written, tested and later understood and modified (readability)
many languages contain syntactic constructs that look identical put are radically different. Example, SNOBOL, a presence of a blank char, which is an operator, in a statement may entirely alter its meaning. Or a(1) versus a[1]
How many ways can you write in C to add to a variable x? or = as ==
Famous FORTRAN example
Do 10 I = 1.5 a(I) = X + B(I) 10 continue FORTRAN ignores all spaces so this was interpreted to do10i = 1.5 destroyed a rocket!
Hamming code
Provides the greatest distance between representations
catch errors easily each representation is at least separated by
two distinct places Notice the syntax of the Do was “too” close
to the syntax of the assignment.
Orthogonality
Able to combine various features of a language in all possible combination and still make sense.
Expressions and conditionals are orthogonal if any expression can be used within the conditional statement
this make a language easier to learn (fewer exceptions and special cases)
also program will compile without errors even if it contains a combination that does not make sense this is why orthogonality is controversial
Naturalness for the application
Program structure reflects the underlying logical structure
provide appropriate data structures, operations and control structures
Support for abstraction The jump made from the abstract data structures to the
solution built with the language data structures and operations
class scheduling - need the structures of student, class section, instructor, lecture room - need the operation of assign student to a class section
what support is provided? Programmer should use language self-contained
abstractions without knowing details of implementation It is desirable to have constructs that factor out recurring
patterns, e.g., subprograms
Ease of program verification
Reliability is a central concern verification - a program correctly performs its
required function proven correct by a formal verification
method informally by desk checking tested with test input data and results
checked against specifications
Programming environment
Presence of an appropriate programming environment may make a technically weak language easier to work with
special editors, testing packages facilities for maintaining, modifying multiple
versions
Portability of programs
Transportability - independent of the features of a particular machine
standardized definitions Ada, FORTRAN, C all have standardized
definitions ML come from single source implementation
allowing the language designer some control over portable features of the language
Cost of use Program execution - optimizing compilers, efficient
register allocation, efficient run-time support important in large production programs that will be
executed repeatedly Cost of program translation - compiled many times Cost of program creation, testing, and use - a
inefficient language may take less programmer time (Smalltalk)
Cost of use
Cost of program maintenance - greatest amount of dollars spent
Language Standardization
What describes a programming language? int i; i = (1&& 2 ) + 3; Is this valid C? What is the the value of i? How would you answer this?
Read the definition in the language reference manual to decide what the statement means.
Or Write the program on your local computer system to see what happens
or read the definition in the language standard
Language Standardization
The first and second option are tied to a particular implementation. Is that implementation correct?
Often, language design involves some intricate details and one vendor may have a different interpretation from another, yielding a slightly different execution behavior.
What about “additional” features
Standards
Proprietary Standards Consensus Standards In the US, the American National Standards
Institute, ANSI programming language standards are assigned to
committee X3 of the Computer Business Equipment Manufactures, or CBEMA
partially technical and partially political consensus process
The FORTRAN 77 string problem Strings and substrings were desirable features most implementations already had such features several feasible implementations of substrings
if M = “abcdefg” then “bcde” could be M[2:5] or M[2:4] (start at 2 and go 4 chars) or start at the right M[3:6]
no consensus, left out (expedient)
Standards
Timeliness. When do we standardize a language?
Conformance. What does it mean for a program to adhere to a
standard and for a compiler to compile to a standard?
Obsolescence. When does a standard age and how does it get
modified
Timeliness
FORTRAN was standardize in 1966 when there many incompatible versions
Ada was standardize before any implementations
balance LISP - no standard reference (Scheme,
Common LISP, IBCL) all exist are similar, but incompatible
Conformance
A program is conformant if it only uses features defined in the standard
A conforming compiler is one which when given a conformant program, produces an executable program that produces the correct output
However, extensions can be added and programs can use those extensions.
Obsolescence
Standards have to be reviewed every five years and either be renewed or dropped
most standards require backward compatibility A feature is obsolescent if it is a candidate
feature that may be dropped in the next version of the standards warns users that the feature is still available, but in
the next 5 to 10 years will be dropped. Fair warning to rewrite code using that feature
Obsolescence
A deprecated feature may become obsolescent with the next standard, hence may be dropped after two revisions gives a 10-20 year warning.
New programs should not use either class of features.