Top Banner
Five Generations
34

Five Generations. The five generations We generally count five "generations" of programming languages The generations aren't formally defined Each generation.

Dec 25, 2015

Download

Documents

Dominick Poole
Welcome message from author
This document is posted to help you gain knowledge. Please leave a comment to let me know what you think about it! Share it to your friends and learn new things together.
Transcript
Page 1: Five Generations. The five generations We generally count five "generations" of programming languages The generations aren't formally defined Each generation.

Five Generations

Page 2: Five Generations. The five generations We generally count five "generations" of programming languages The generations aren't formally defined Each generation.

The five generations

• We generally count five "generations" of programming languages

• The generations aren't formally defined• Each generation represents technological advances• "Advances" may just reflect changing preferences• Don't take the distinctions too seriously

– but they do provide a good framework for discussion

Page 3: Five Generations. The five generations We generally count five "generations" of programming languages The generations aren't formally defined Each generation.

First generation

• Examples: FORTRAN, COBOL, BASIC• Key concept: Language designs were based

directly on available hardware• Efficiency was everything• Language names are acronyms and are typically

spelled with all capital letters

Page 4: Five Generations. The five generations We generally count five "generations" of programming languages The generations aren't formally defined Each generation.

1G: Primitive data types

• Data types reflect types defined by the hardware• Multiple types of numbers (fixed, floating, various sizes)• Characters and booleans are represented as numbers• No user-defined types• Identifiers have types, but type safety is not a big concern• Identifiers bound directly to storage locations--no

dynamic storage

Page 5: Five Generations. The five generations We generally count five "generations" of programming languages The generations aren't formally defined Each generation.

1G: Data structures

• Data structures are based on those of machine language– that is, single contiguous blocks of storage

• No nesting of data structures (just arrays, records)– Arrays represent a block of locations (FORTRAN, BASIC)

– Records represent layout of data on a punched card (COBOL)

Page 6: Five Generations. The five generations We generally count five "generations" of programming languages The generations aren't formally defined Each generation.

1G: Control structures

• Control structures are based on those of machine language– Multiple kinds of GOTOs

– Little nesting of control structures (exception: DO loops in FORTRAN)

– No recursion (exception: BASIC)

– A single way to pass parameters (usually by reference)

Page 7: Five Generations. The five generations We generally count five "generations" of programming languages The generations aren't formally defined Each generation.

1G: Syntax

• One statement per line (line = punched card), fixed columns

• Hardware doesn't yet support lowercase characters• Pre-BNF, so syntax is irregular and inconsistent• Keywords not reserved, but context-dependent• Scopes are disjoint (because the is only enough

memory to compile one subprogram at a time)

Page 8: Five Generations. The five generations We generally count five "generations" of programming languages The generations aren't formally defined Each generation.

Second generation

• Algol 60 was the premier 2G language• Key concepts: Abstraction and generalization

– Algol 60 introduced the notion of a "virtual machine," not tied to particular hardware

– Algol 60 introduced real and integer data types not tied to a particular bit representation, and generalized loop and selection (if) statements

• Alan Perlis: "Algol was indeed an achievement; it was a significant advance on most of its successors."

Page 9: Five Generations. The five generations We generally count five "generations" of programming languages The generations aren't formally defined Each generation.

2G: Data structures

• Machine independence seen as a valid concern• Simplification and abstraction of numeric types

(real, integer)• Arrays with user-defined lower bounds (not just 1)• Dynamic (expandable) arrays• Booleans introduced, but still not characters

– Strings could be used for output only

• Strong typing

Page 10: Five Generations. The five generations We generally count five "generations" of programming languages The generations aren't formally defined Each generation.

2G: Control structures

• True hierarchical (nested) control structures• Generalized control structures

– Often overly complex and baroque (e.g. for, switch)

• "Blocks" provide fine control over nesting, scopes• Could pass parameters by value (good idea)• Could pass parameters by name (bad idea)

Page 11: Five Generations. The five generations We generally count five "generations" of programming languages The generations aren't formally defined Each generation.

2G: Syntax

• BNF used to simplify and regularize syntax• Free-format programs (not line-oriented)• Indentation used to show hierarchical structure of

program• Typically used reserved keywords rather than

keyword-in-context• Lowercase letters used (but not supported by

hardware)

Page 12: Five Generations. The five generations We generally count five "generations" of programming languages The generations aren't formally defined Each generation.

Third generation

• Example: Pascal• Key concepts: Simplicity and generality

– More but simpler control structures

– Expanded and generalized data types

Page 13: Five Generations. The five generations We generally count five "generations" of programming languages The generations aren't formally defined Each generation.

3G: Data Structures

• Recognition that not everything is a number• Language support for strings (or at least characters)• New data types introduced:

– sets– subranges– enumeration types

• User-defined data types• Hierarchical nesting of data types• User-controllable memory allocation

Page 14: Five Generations. The five generations We generally count five "generations" of programming languages The generations aren't formally defined Each generation.

3G: Control structures

• More but simpler control structures– three kinds of loop replace Algol's single for loop

• Case statements introduced – called "switch" in C, Java

• Simpler control structures can be more efficient as well as easier to understand

• "Call by name" parameter transmission was discarded

Page 15: Five Generations. The five generations We generally count five "generations" of programming languages The generations aren't formally defined Each generation.

Syntax

• No significant improvements over Algol 60

Page 16: Five Generations. The five generations We generally count five "generations" of programming languages The generations aren't formally defined Each generation.

First generation features of C

• Efficiency is primary concern• Based on PDP-7 hardware• "Flat" program space--no nested scopes or functions

– This weakness leads to need for make

• Some first generation syntax ("=" for assignment)

Page 17: Five Generations. The five generations We generally count five "generations" of programming languages The generations aren't formally defined Each generation.

Second generation features of C

• Abstractions of numeric types, pointers• Pointer and array abstractions are lower-level than

some machine hardware– Wrong abstraction level can hinder optimization

• Seen on a button: "C combines the flexibility of assembly language with the power of assembly language"

Page 18: Five Generations. The five generations We generally count five "generations" of programming languages The generations aren't formally defined Each generation.

Third generation features of C

• Hierarchical data structures (if not programs)• Support for strings (sort of), and enumeration

types (almost)• User-controllable memory allocation

• Bottom line: C mixes characteristics of three generations

Page 19: Five Generations. The five generations We generally count five "generations" of programming languages The generations aren't formally defined Each generation.

Fourth generation

• Examples are Ada, Modula• Key concept: Emphasis on data abstraction

Page 20: Five Generations. The five generations We generally count five "generations" of programming languages The generations aren't formally defined Each generation.

4G: Data structures

• Separation of specification and definition– Other programmers and program parts can access the

specification, not the code

– This gives better support for information hiding

– But this leads to duplication, which is error-prone

• Name access by mutual consent• Generic or polymorphic subprograms• Exceptions (errors) attain the status of a data type

Page 21: Five Generations. The five generations We generally count five "generations" of programming languages The generations aren't formally defined Each generation.

4G: Control structures

• Concurrent programming, that is, multiple communicating processes

• Protected or synchronized types• Functions can be overloaded (operators, too)• Exception handlers result in a new flow of control

Page 22: Five Generations. The five generations We generally count five "generations" of programming languages The generations aren't formally defined Each generation.

4G: Syntax

• Fully bracketed control structures replace begin...end or {...}

• Examples:

– if...end if;– loop...end loop;– function foo ( ) ... end foo;

Page 23: Five Generations. The five generations We generally count five "generations" of programming languages The generations aren't formally defined Each generation.

Fifth generation, I

• Key concept: No general agreement on what 5G is• Prolog was the basis of the Japanese "Fifth-

Generation Project"– The Fifth-Generation Project was not a success

• O-O languages are now the dominant paradigm– They are the de facto fifth generation

• But logic programming has a prior claim to the name• Functional programming is also a contender for 5G

Page 24: Five Generations. The five generations We generally count five "generations" of programming languages The generations aren't formally defined Each generation.

Fifth generation, II

• O-O languages are Simula 67, Smalltalk, Java• Yes, the first O-O language appeared in 1967!• Almost all surviving languages now have O-O

extensions– C has Objective C, C++

– Pascal has Object Pascal

– Ada has Ada 95

– There are O-O versions of FORTRAN, BASIC, Prolog, etc.

Page 25: Five Generations. The five generations We generally count five "generations" of programming languages The generations aren't formally defined Each generation.

Fifth generation, III

• Fifth generation (Smalltalk, Java)• Key concept: Object orientation• Three essential features:

– Abstract data types (grouping of data and methods)

– Inheritance (of types and methods, with overriding)

– Messages (dynamic binding to methods)

Page 26: Five Generations. The five generations We generally count five "generations" of programming languages The generations aren't formally defined Each generation.

5G: Data structures

• Everything (or almost everything) is an object• All behaviors (methods) are encapsulated within objects• Objects are arranged in a hierarchy• But object space is still "flat," with little or no nesting

– Java's inner classes are too little, too late

• Data and methods are inherited• Data and methods can be overridden

Page 27: Five Generations. The five generations We generally count five "generations" of programming languages The generations aren't formally defined Each generation.

5G: Control structures

• Instead of calling functions, send messages to objects– Variables can hold different kinds of objects at different times

– Therefore, messages sent to the variable may go to different kinds of objects

• Most O-O languages have support for GUI events– An event is a message sent "to whom it may concern"

– Event-handling may be container-based (Mac, Java 1.0)

– Better event-handling is listener-based (Java 1.1)

Page 28: Five Generations. The five generations We generally count five "generations" of programming languages The generations aren't formally defined Each generation.

5G: Syntax

• First support for international alphabets• No other improvements in syntax• In fact, Java syntax is a throwback to the C era

Page 29: Five Generations. The five generations We generally count five "generations" of programming languages The generations aren't formally defined Each generation.

Advantages of O-O languages

• Most significant: best solution (so far) to code reuse– You can inherit data and methods from predefined objects

– It's easy to override methods or to adapt them

• This changes completely the way programmers work– Don't write from scratch; find something similar and adapt it

– Along with syntax, you must now learn vast libraries

• Additional advantage: first real support for GUIs and for event handling

Page 30: Five Generations. The five generations We generally count five "generations" of programming languages The generations aren't formally defined Each generation.

Summary: Data structures

• First generation: Flat (non-nested) blocks of storage• Second generation: Generalized numbers, strong

typing• Third generation: New data types, user-defined data

structures, dynamic memory allocation• Fourth generation: Non-lexical control of data access• Fifth generation: Objects encapsulate their methods

Page 31: Five Generations. The five generations We generally count five "generations" of programming languages The generations aren't formally defined Each generation.

Summary: Control structures

• First generation: Based on machine instructions, with heavy use of GOTOs

• Second generation: Machine independent, nested, but jack-of-all-trades

• Third generation: More but simpler control structures• Fourth generation: Concurrent programming,

exception handling• Fifth generation: Messages to objects, event handling

Page 32: Five Generations. The five generations We generally count five "generations" of programming languages The generations aren't formally defined Each generation.

Summary: Syntax

• First generation: Line-oriented, inconsistent syntax, disjoint scopes

• Second generation: Free form, uniform syntax, nested scopes

• Third generation: No advances• Fourth generation: Fully bracketed control structures• Fifth generation: No advances, some losses

Page 33: Five Generations. The five generations We generally count five "generations" of programming languages The generations aren't formally defined Each generation.

But wait...there's more!

• Simula 67 was the first true O-O language– This shows that it takes time to get good ideas into

mainstream languages

• Logic languages (Prolog) and purely functional languages (ML) still have some very good ideas

• Giant, all-inclusive languages (PL/I, Algol 68) are not the answer

• Finally, don't take this classification scheme too seriously!

Page 34: Five Generations. The five generations We generally count five "generations" of programming languages The generations aren't formally defined Each generation.

The End