What Makes a Good Language? - PowerPoint PPT Presentation

About This Presentation
Title:

What Makes a Good Language?

Description:

The evolution of writing systems to record language reveals the first steps ... A deprecated feature may become obsolescent with the next standard, hence may be ... – PowerPoint PPT presentation

Number of Views:30
Avg rating:3.0/5.0
Slides: 27
Provided by: dolore
Learn more at: http://www.cs.bsu.edu
Category:

less

Transcript and Presenter's Notes

Title: What Makes a Good Language?


1
What Makes a Good Language?
  • Lecture 3

2
The first formal languages
  • The evolution of writing systems to record
    language reveals the first steps toward formal
    notation and unambiguous communication.
  • The worlds 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

3
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

4
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

5
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 (Griswolds SNOBOL4 text)
  • use as theoretical study (Pascal and LISP)

6
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

7
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 a1
  • How many ways can you write in C to add to a
    variable x? or as

8
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!

9
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.

10
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

11
Naturalness for the application
  • Program structure reflects the underlying logical
    structure
  • provide appropriate data structures, operations
    and control structures

12
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

13
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

14
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

15
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

16
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)

17
Cost of use
  • Cost of program maintenance - greatest amount of
    dollars spent

18
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

19
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

20
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

21
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 M25 or
    M24 (start at 2 and go 4 chars) or start at
    the right M36
  • no consensus, left out (expedient)

22
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

23
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

24
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.

25
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

26
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.
Write a Comment
User Comments (0)
About PowerShow.com