Software Paradigms and the Evolution of Programming Languages

Document Sample
Software Paradigms and the Evolution of Programming Languages Powered By Docstoc
					Software Paradigms and the Evolution of Programming Languages
CFICSE SF04 1999

Royal Military College of Canada Electrical and Computer Engineering +01-613-541-6000 ext. 6190

Major Greg Phillips


Why should Software Engineers care about languages?


Why should Software Engineers care about languages? Because they’re the closest thing we have to an acceptable “design notation”.

• Programming paradigms • Firsts, and a brief history of programming languages • Evolution of support for information hiding/data abstraction • Some commonly-made language distinctions

Programming Paradigms
“... most programmers work in one language and use only one programming style. They program in a paradigm enforced by the language they use. Frequently, they have not been exposed to alternate ways of thinking about a problem, and hence have difficulty in seeing the advantage of choosing a style more appropriate to the problem at hand.” — Mike Jenkins & Janice Glasgow, 1986

“Programming languages teach you not to want what they cannot provide. You have to think in a language to write programs in it, and it's hard to want something you can't describe. When I first started programming—in BASIC—I didn't miss recursion, because I didn't know there was such a thing. I thought in BASIC. I could only conceive iterative algorithms, so why should I miss recursion?” —Paul Graham, ANSI Common Lisp.

Language Paradigms (I)
Imperative language. A language which operates by a sequence of commands that change the value of data elements. Typified by assignments and iteration. Declarative language. A language which operates by making descriptive statements about data and relations between data. The algorithm is hidden in the semantics of the language. This category encompasses both applicative and logic languages. Examples of declarative features are set comprehensions and pattern-matching statements. Procedural language. A language which states how to compute the result of a given problem. Encompasses both imperative and functional languages. Applicative language. A language that operates by application of functions to values, with no side effects. A functional language in the broad sense.
From The Language List

Language Paradigms (II)
Functional language. In the narrow sense, a functional language is one that operates by use of higher-order functions, building operators that manipulate functions directly without ever appearing to manipulate data. Example: FP. Definitional language. An applicative language containing assignments interpreted as definitions. Example: Lucid. Single Assignment [(Linear)] language. An applicative language using assignments with the convention that a variable may appear on the left side of an assignment only once within the portion of the program in which it is active. Dataflow language. A language suitable for use on a dataflow architecture. Necessary properties include freedom from side effects and the equivalence of scheduling constraints with data dependencies. Examples: Val, Id, SISAL, Lucid.

Language Paradigms (III)
Logic language. A logic language deals with predicates or relationships p(X,Y). A program consists of a set of Horn clauses which may be:
• facts - p(X,Y) is true • rules - p is true if q1 and q2 and ...qn are true • queries - is g1 and g2 and true? (gi's are the goals.)

Further clauses are inferred using resolution. One clause is selected containing p as an assumption, another containing p as a consequence, and p is eliminated between them. If the two p's have different arguments they must be unified, using the substitution with the fewest constraints that makes them the same. Logic languages try alternative resolutions for each goal in succession, backtracking in a search for a common solution. ORparallel languages try alternative resolutions in parallel, while ANDparallel languages try to satisfy several goals in parallel.

Language Paradigms (IV)
Concurrent language. A concurrent language describes programs that may be executed in parallel. This may be either
• multiprogramming: sharing one processor • multiprocessing: separate processors sharing one memory • distributed

Concurrent languages differ in the way that processes are created:
• coroutines - control is explicitly transferred - Simula I, SL5, BLISS, Modula-2. • fork/join - PL/I, Mesa • cobegin/coend - ALGOL 68, CSP, Edison, Argus • process declarations - DP, SR, Concurrent Pascal, Modula, PLITS, Ada • • • • • • • semaphores - ALGOL 68 conditional critical regions - Edison, DP, Argus monitors - Concurrent Pascal, Modula message passing - CSP, PLITS, Gypsy, Actors remote procedure calls - DP, *Mod rendezvous - Ada, SR atomic transactions - Argus

and the ways in which processes interact:

Language Paradigms (V)
Constraint language. A language in which a problem is specified and solved by a series of constraining relationships. Object-Oriented language. A language in which data and the functions which access it are treated as a unit. Examples: C++, Smalltalk, Java Query language. An interface to a database. Example: SQL. Fourth generation language (4GL's). A very high-level language. May use natural English or visual constructs. Algorithms or data structures may be chosen by the compiler. Example: SQL*Forms Specification language. A formalism for expressing a hardware or software design. Examples: UML, LOTOS, Z, VDM Assembly language. A symbolic representation of the machine language of a specific computer. Intermediate language. A language used as an intermediate stage in compilation. May be either text or binary. Example: Java bytecode Metalanguage. A language used for formal description of another language. Examples: BNF, Reynolds’ semantic framework

Language Paradigms (VI)
Visual Language. A language consisting of drawings rather than text. Typically, visual languages consist of a limited vocabulary of nodes and connections, with a well defined syntax and semantics. Often supplemented by text. Examples: Petri nets, StateCharts, ObjecTime, Software Through Pictures. Domain Specific Language. A language closely linked to a particular application area. Examples: array languages (APL, NIAL), statistical languages (LISA, SAS ), symbolic math languages (MACSYMA, Mathematica). Reflective Language. A language with the ability to modify its own properties. Also referred to as a “metaobject” language. Examples: Smalltalk, CLOS.

The “Firsts”
• First computer program: 1843 by Ada Byron, Lady Lovelace, for Charles Babbage’s Analytical Engine • First programming language: 1945, Konrad Zuse’s “Plankalkül”, designed for the Z-4 but never implemented • First implemented programming language: “Short Code” for the Binac and Univac by J.W. Mauchly, 1949. Example: “x = y - z” is coded as “00 V0 03 V1 01 V2” • First true compiled language: “Autocode” for the Manchester Mark I by Alick E. Glennie, 1952

• Developed by John Backus for the IBM 704 mainframe in 1957. Spawned FORTRAN II, IV, 77, 90 and still going strong, especially for scientific computation. • Example:



• ALGOL was developed cooperatively by the ACM and GAMM in 1958, refined and released in 1960, and revised in 1962. It has been described as “a dramatic improvement on most of its successors.” • Example:
integer procedure factorial (n); value n; integer n; factorial := if n > 0 then n * factorial(n-1) else 1;

• An extension to ALGOL 60 by Kristen Nygaard & Ole-Johan Dahl, designed in 1962, implemented in 1964, substantially revised in 1967. Originally intended specifically to support discrete event simulation but turned out to be more generally useful than originally envisioned. • Introduced the record class, leading the way to data abstraction and inheritance, leading the way to object-oriented programming.

• Designed at Xerox PARC from 1972-1980; publicly available implementation in 1983. • Took the concepts of class and message from SIMULA-67 and made them all-pervasive, the quintessential object-oriented language. Innovations included the bitmap display, windowing system and use of mouse. • Example:
(In class Number)

factorial ^self > 0 ifTrue: [self * (self - 1) factorial] ifFalse: [1].

Topology of Generation I & Early Generation II Languages


Topology of Generation II & Early Generation III Languages


Topology of Late Generation III Languages



Topology of Object-Based Languages (Small Application)

Topology of Object-Based Languages (Large Application)

Compiled versus Interpreted
Pure Compiled Implementation
Application (programming language)

Pure Interpreted Implementation

Hybrid Implementation
Application (programming language) Byte code Compiler

Native Compiler
Application (compiled) Operating System Hardware

Application (programming language) Interpreter Operating System Hardware

Application (byte code compiled) Byte code Interpreter Operating System Hardware

Fast Execution

Rapid Development and Portability

Explicitly Typed versus Typeless
• Explicitly (statically) typed languages have type information explicitly included in the source code
• Examples: Java, C++, Ada, Pascal, Fortran • Claimed advantages:
• • • • compiler can enforce the intended design decisions interfaces are better specified code can be compiled into more efficient (faster) programs easier to understand and maintain

• Typeless languages have type information implicit in source code and context of use
• Examples: Smalltalk, Python, Lisp, CLOS, ML • Claimed advantages:
• • • •

easier to produce reusable code, and to reuse existing code simplifies incremental evolution of systems easier to understand and maintain more fun

Explicitly Typed versus Typeless (II)
public class Counter { int count; public Counter() { count = 0; } public void incBy(int inc) { count = count + inc; } public int getCount() { return count; } }


class Counter: def __init__(self): self.count = 0 def incBy(self, inc): self.count = self.count + inc def getCount(self): return self.count

System Programming versus Scripting
• System programming languages produce efficient, highly structured components with well-enforced interfaces • Scripting languages provide very high level constructs for rapid application development, and mechanisms for integrating components together • One approach: build the components in a system programming language; assemble them using a scripting language.
John Ousterhout. Scripting: Higher Level Programming for the 21st Century. IEEE Computer, March 1998. Also at

• examples: C++, Ada, Java

• examples: Perl, TCL, Python

Influential Languages
• • • • • • • • • • • • • • • 1957 1958 1960 1960 1962 1962 1964 1964 1966 1970 1972 1975 1975 1977 1978 FORTRAN ALGOL LISP COBOL APL SIMULA BASIC PL/I ISWIM Prolog C Pascal Scheme OPS5 CSP • • • • • • • • • • • • • • 1978 1980 1983 1983 1983 1984 1986 1986 1986 1988 1988 1988 1990 [1995 FP dBASE II Smalltalk-80 Ada Parlog Standard ML C++ CLP(R) Eiffel CLOS Mathematica Oberon Haskell Java (?)]