CPS 506 Comparative Programming Languages Winter 2010 Ryerson

  • Slides: 123
Download presentation
CPS 506 Comparative Programming Languages Winter 2010 Ryerson University

CPS 506 Comparative Programming Languages Winter 2010 Ryerson University

Course Outline • • Introduction Syntax and Semantic Specification Type Systems, Semantics and Data

Course Outline • • Introduction Syntax and Semantic Specification Type Systems, Semantics and Data Types Names, Scope, Expression Control Structures Sub-program and Parameter Passing Exception Handling Abstract Data Type and Encapsulation 2

Course Outline (con’t) • Programming Language Paradigms – Imperative (C, Pascal, …) – Object-Oriented

Course Outline (con’t) • Programming Language Paradigms – Imperative (C, Pascal, …) – Object-Oriented (C++, C#, Java, …) – Logic (Prolog, Mercury) – Functional (ML, Scheme, Haskell, …) – Even-driven (Visual Basic, Java, …) – Concurrent or Parallel (SR, Linda, …) – Multi-Paradigm (Ruby, Python, Perl, …) 3

Course Outline (con’t) • Languages Survey – ML (Meta Language) (1990 s) • Functional

Course Outline (con’t) • Languages Survey – ML (Meta Language) (1990 s) • Functional language – Ruby (1993) • A balanced functional and imperative languages – Python (1991) • Object-Oriented, functional and imperative language 4

Textbook • Concepts of Programming Languages, 9 th Edition – By Robert W. Sebesta

Textbook • Concepts of Programming Languages, 9 th Edition – By Robert W. Sebesta http: //www. coursesmart. com/0136073476 • Programming Languages: Principles and Paradigms, 2 nd Edition – By Allen Tucker and Robert Noonan • … http: //www. mhhe. com/engcs/compsci/tucker/ 5

Evaluation • Assignments • Midterm • Final Exam (20%) (30%) (50%) • Optional Project

Evaluation • Assignments • Midterm • Final Exam (20%) (30%) (50%) • Optional Project (10%) – Programming language survey – Paradigm survey 6

Contact Information • Course Web Page www. scs. ryerson. ca/~ssamet/ (check every three days)

Contact Information • Course Web Page www. scs. ryerson. ca/~ssamet/ (check every three days) • Contact Email ssamet@scs. ryerson. ca • Office Hours TBA • Teaching Assistant TBA 7

Why programming Languages? • Facilitate expression of ideas and communication – The more expressive

Why programming Languages? • Facilitate expression of ideas and communication – The more expressive power of the language , the deeper thought – Awareness of the programming languages increases range of software development thought processes • Ability to choose appropriate language – understanding main features of the languages 8

Why programming Languages? (con’t) • Increase ability to learn and design new languages –

Why programming Languages? (con’t) • Increase ability to learn and design new languages – Understanding fundamental concepts • Better usage of the languages – Learning unknown and unused parts of the languages • Overall advancement of computing – Most popular languages are not always the best ones – ALGOL 60 and Fortran 9

Introduction (con’t) • Different from natural languages – Narrower expressive domain (Algorithmic ideas) –

Introduction (con’t) • Different from natural languages – Narrower expressive domain (Algorithmic ideas) – Communication between human and computer • Future programming languages – Understand features, strengths and weaknesses – New application needs 10

Programming Language Qualities • Criteria – Readability • Ease of reading and understanding a

Programming Language Qualities • Criteria – Readability • Ease of reading and understanding a program • Before 1970 s – Efficiency and Machine readability – Design from the point of view of computer • 1970 s and after – Software life-cycle concept – Maintenance – Machine orientation -> Human orientation • Consider in the context of the domain 11

Programming Language Qualities • Criteria (con’t) – Writability • How easily a language can

Programming Language Qualities • Criteria (con’t) – Writability • How easily a language can be used • Tough relation with readability • Consider in the context of the domain – VB for GUI – C for system programs 12

Programming Language Qualities • Criteria (con’t) – Reliability • Performs according to the specifications

Programming Language Qualities • Criteria (con’t) – Reliability • Performs according to the specifications under all conditions • Crucial criterion for embedded, scientific, real-time and human related systems 13

Programming Language Qualities • Characteristics – Simplicity and Clarity • How easily a program

Programming Language Qualities • Characteristics – Simplicity and Clarity • How easily a program is written and read • Knowledge difference of author and reader – Binding • Language definition, implementation time, program writing time, compile time, run time 14

Programming Language Qualities (con’t) • Characteristics (con’t) – Orthogonality • Small set of primitive

Programming Language Qualities (con’t) • Characteristics (con’t) – Orthogonality • Small set of primitive constructs can be combined in a small number of ways to define the components of a language • Not too many ways for doing the same thing • A symbol or reserve word always have the same meaning – Type checking • Testing for type errors • Expensive in run-time • Original C language had no parameter type checking 15

Programming Language Qualities (con’t) • Characteristics (con’t) – Exception handling • Ability to intercept

Programming Language Qualities (con’t) • Characteristics (con’t) – Exception handling • Ability to intercept run-time errors • Prevent system crash – Aliasing • Same memory, two or more names • Side-effect • Difficult program verification – Applicability • Support for the application domain 16

Programming Language Qualities (con’t) • Characteristics (con’t) – Abstraction • Complex s structures without

Programming Language Qualities (con’t) • Characteristics (con’t) – Abstraction • Complex s structures without specifying the detail implementation – Efficient Implementation • Problems like in early implementation of Java and Ada 17

Programming Language Qualities (con’t) • Cost – Training, Writing, Compiling, Executing, Maintenance, Implementation environment

Programming Language Qualities (con’t) • Cost – Training, Writing, Compiling, Executing, Maintenance, Implementation environment • Portability – One program on different platforms • Generality – Applicability to wide range of application domain 18

Quality Trade-offs • Reliability vs. Writability – C: Pointers are flexible and powerful •

Quality Trade-offs • Reliability vs. Writability – C: Pointers are flexible and powerful • Reliability vs. Execution Cost – Java: Array index checking • Writability vs. Readability – APL: Many new symbols and complex computations • Example: Find all prime numbers from 1 to R: (~R∊R∘. ×R)/R← 1↓�R (From Wikipedia) 19

Influence on Language Design • Computer Architecture – Many languages are designed according to

Influence on Language Design • Computer Architecture – Many languages are designed according to the prevalent architecture, Van Neumann – Imperative languages – Both data and program in the same memory – CPU is separate from memory – Data and instructions piped to CPU – Results moved back to memory 20

Influence on Language Design (con’t) • Van Neumann Architecture Memory Control Unit Algorithmic Logic

Influence on Language Design (con’t) • Van Neumann Architecture Memory Control Unit Algorithmic Logic Unit Accumulator Input 21

Influence on Language Design (con’t) • Computer Architecture (con’t) – Variables model memory cell

Influence on Language Design (con’t) • Computer Architecture (con’t) – Variables model memory cell – Assignments statements based on piping operation – Iterative form of repetition: efficient way to implement loops (instructions stored in adjacent cells) – Fetch-Execute cycle 22

Influence on Language Design (con’t) • Software Development Methodologies – New paradigm, new languages

Influence on Language Design (con’t) • Software Development Methodologies – New paradigm, new languages 23

Programming methodologies influences • 1950 s and early 1960 s: Simple applications; machine efficiency

Programming methodologies influences • 1950 s and early 1960 s: Simple applications; machine efficiency problem • Late 1960 s: Efficiency became important; readability; better control structures – structured programming – top-down design 24

Programming methodologies influences (con’t) • Late 1970 s: Process-oriented to dataoriented – data abstraction

Programming methodologies influences (con’t) • Late 1970 s: Process-oriented to dataoriented – data abstraction • Mid 1980 s: Object-oriented programming – Data abstraction; inheritance; dynamic method binding (polymorphism) 25

Implementation Methods • Compiler – Translation of the program to machine code – Examples:

Implementation Methods • Compiler – Translation of the program to machine code – Examples: C, Pascal, Haskell, ML • Interpreter – Program is interpreted by a software program, interpreter – Examples: Cobol, APL, LISP 26

Implementation Methods (con’t) • Hybrid implementation – Partially translated to detect errors – Translate

Implementation Methods (con’t) • Hybrid implementation – Partially translated to detect errors – Translate to an intermediate language for easier interpretation – Example: Perl, initial implementation of Java • Just-In-Time – Translate to intermediate language – Compile the methods that are called – Example: Java, . Net languages 27

Layered View of Computer The operating system and language implementation are layered over machine

Layered View of Computer The operating system and language implementation are layered over machine interface of a computer 28

Compilation • Translate high-level program (source language) into machine code (machine language) • Slow

Compilation • Translate high-level program (source language) into machine code (machine language) • Slow translation, fast execution 29

The Compilation Process • Compilation process phases: – lexical analysis: converts characters in the

The Compilation Process • Compilation process phases: – lexical analysis: converts characters in the source program into lexical units – Identifiers – Special words – Operators – Punctuation symbols – syntax analysis: transforms lexical units into parse trees which represent the syntactic structure of program – Semantics analysis: generate intermediate code – code generation: machine code is generated 30

Additional Compilation Terminologies • Load module (executable image): the user and system code together

Additional Compilation Terminologies • Load module (executable image): the user and system code together • Linking and loading: the process of collecting system program units and linking them to a user program 31

Von Neumann Bottleneck • Connection speed between a computer’s memory and its processor determines

Von Neumann Bottleneck • Connection speed between a computer’s memory and its processor determines the speed of a computer • Program instructions often can be executed much faster than the speed of the connection; the connection speed thus results in a bottleneck • Known as the von Neumann bottleneck; it is the primary limiting factor in the speed of computers • Motivation for research and development of parallel computers 32

Pure Interpretation • No translation • Works as a software simulation of a machine

Pure Interpretation • No translation • Works as a software simulation of a machine • Easier implementation of programs (run-time errors can easily and immediately be displayed) • Slower execution (10 to 100 times slower than compiled programs) – Decoding high-level language statements – Statements are decoded every time executed – Bottleneck is statement decoding and not the communication between memory and processor 33

Pure Interpretation (con’t) • Often requires more space – In addition of source, symbol

Pure Interpretation (con’t) • Often requires more space – In addition of source, symbol table has to be present during interpretation – Storing source program in a form for easy access and modification and not in minimal size • Pure interpreters (1960 s) – APL, SNOBOL, LISP • Rarely used in high-level languages (by the 1980 s) • Significant comeback with some Web scripting languages – Java. Script – PHP 34

Pure Interpretation Process 35

Pure Interpretation Process 35

Hybrid Implementation Systems • A compromise between compilers and pure interpreters • A high-level

Hybrid Implementation Systems • A compromise between compilers and pure interpreters • A high-level language program is translated to an intermediate language that allows easy interpretation – Faster than pure interpretation – Source statements are decoded only once 36

Hybrid Implementation Systems • Examples – Perl programs are partially compiled to • Detect

Hybrid Implementation Systems • Examples – Perl programs are partially compiled to • Detect errors before interpretation • Simplify the interpreter – Initial implementations of Java were hybrid; the intermediate form, byte code, provides portability to any machine that has • Byte code interpreter • Associated run-time system • Together, these are called Java Virtual Machine – New versions translate Java byte code into machine code for faster execution 37

Hybrid Implementation Process 38

Hybrid Implementation Process 38

Just-in-Time Implementation Systems • Initially translate programs to an intermediate language • Then compile

Just-in-Time Implementation Systems • Initially translate programs to an intermediate language • Then compile the intermediate language of the subprograms into machine code when they are called • Machine code version is kept for subsequent calls • JIT systems are widely used for Java programs • . NET languages are implemented with a JIT system 39

Preprocessors • Preprocessor macros (instructions) are commonly used to specify that code from another

Preprocessors • Preprocessor macros (instructions) are commonly used to specify that code from another file is to be included • A preprocessor processes a program immediately before the program is compiled to expand embedded preprocessor macros • A well-known example: C preprocessor – expands #include, #define, and similar macros • Possible side effect 40

Principles of language design • Basic vocabulary to express language structures, meaning, …, borrowed

Principles of language design • Basic vocabulary to express language structures, meaning, …, borrowed from – Linguistics – Mathematics • Principles categories – Syntax – Type Systems and Semantics – Memory Management – Exception Handling 41

Syntax (form) • Grammar for writing programs • Basic vocabulary of – Keywords –

Syntax (form) • Grammar for writing programs • Basic vocabulary of – Keywords – Symbols • Combinations of keywords and symbols forming a syntactically correct program 42

Syntax (con’t) • Pascal program sample; var a, b: integer; begin a : =

Syntax (con’t) • Pascal program sample; var a, b: integer; begin a : = 1; b : = a+1; If ( b = a ) then begin a : = a+1; b : = 0; end. • C main() { int a, b; a = 1; b = a+1; if ( b == a ) { a++; b = 0; } } 43

Type Systems and Semantics • Type of values • Meaning of the programs •

Type Systems and Semantics • Type of values • Meaning of the programs • Formal approach to understand effects of – – – Statements Sequence of steps Loops Conditional statements … • Abstract definition (independent of machine or OS architectures) 44

Type Systems and Semantics (con’t) • Different characteristics of data object – Location –

Type Systems and Semantics (con’t) • Different characteristics of data object – Location – Name – Value – Type • Primitive, Composite and Recursive data types • Type Binding • Type Checking • Type Conversion 45

Memory Management • Mapping of values, data structures, and program structures to the memory

Memory Management • Mapping of values, data structures, and program structures to the memory • Static memory (Stack) • Dynamic memory (Heap) • Objects lifetime • Garbage collection 46

Exception Handling • Unexpected input error • Unexpected division by zero • Unexpected unsuccessful

Exception Handling • Unexpected input error • Unexpected division by zero • Unexpected unsuccessful space allocation in the heap • A fundamental feature in modern languages 47

Programming Paradigms • Imperative – Series of steps • Calculate • Retrieve input •

Programming Paradigms • Imperative – Series of steps • Calculate • Retrieve input • Produce output – Procedural Abstraction • • Assignments Loops Sequences Conditional Statements – Examples • Cobol, Fortran, C, C++ 48

Programming Paradigms (con’t) • Object Oriented – Collection of objects interact with each other

Programming Paradigms (con’t) • Object Oriented – Collection of objects interact with each other – Building blocks • Object modeling • Classification • Inheritance – Examples • Java, Smalltalk, C++, C#, Ruby, Ada 95 49

Programming Paradigms (con’t) • Logic – Collection of declarative rules – “What outcome” instead

Programming Paradigms (con’t) • Logic – Collection of declarative rules – “What outcome” instead of “How accomplish” – Natural vehicle for expressing nondeterminism – A series of possible solutions to a problem – Examples • Prolog 50

Programming Paradigms (con’t) • Functional – Collection of mathematical functions – One input (domain)

Programming Paradigms (con’t) • Functional – Collection of mathematical functions – One input (domain) and one result (range) – Functions interacts using • Composition • Conditionals • Recursion – Examples • Lisp, Scheme, ML, Haskell 51

Programming Paradigms (con’t) • Event-driven – Continuous loop that responds to events – Events

Programming Paradigms (con’t) • Event-driven – Continuous loop that responds to events – Events could be in various orders • Keystroke, mouse click, … – Examples • Visual Basic, Java 52

Programming Paradigms (con’t) • Concurrent – Collection of parallel processes or treads – Sharing

Programming Paradigms (con’t) • Concurrent – Collection of parallel processes or treads – Sharing information – Processes could be executed asynchronously – Parallelism in one process – Examples • SR, Linda, High Performance Fortran 53

Programming Paradigms (con’t) • Multi-Paradigm – Support more than one programming paradigm – Frameworks

Programming Paradigms (con’t) • Multi-Paradigm – Support more than one programming paradigm – Frameworks providing a variety of styles for programmer to use a mix constructs from various paradigms – Idea: There is no single paradigm to solve the problems efficiently and easily – Examples • Oz, Ruby, Python, Perl, … 54

Application Domains • Scientific – Complex calculations – Fast process – Accurate results –

Application Domains • Scientific – Complex calculations – Fast process – Accurate results – Imperative and parallel paradigms – Fortran 90, C, High Performance Fortran 55

Application Domains (con’t) • Management Information Systems (MIS) – Business and commercial systems –

Application Domains (con’t) • Management Information Systems (MIS) – Business and commercial systems – Database management – Imperative, Declarative and event -driven paradigms – Cobol, RPG, SQL, Java, Tcl/Tk 56

Application Domains (con’t) • Artificial Intelligence (AI) – Modeling human intelligent bahavior – Logical

Application Domains (con’t) • Artificial Intelligence (AI) – Modeling human intelligent bahavior – Logical deduction – Cognition – Functional and logic paradigms – Prolog, CLP 57

Application Domains (con’t) • Systems – Operating systems – Network software – Compilers –

Application Domains (con’t) • Systems – Operating systems – Network software – Compilers – Imperative, event-driven, and parallel paradigms –C 58

Application Domains (con’t) • Web-centric – E-Commerce – E-Government – Event-driven, and Object. Oriented

Application Domains (con’t) • Web-centric – E-Commerce – E-Government – Event-driven, and Object. Oriented paradigms – Perl, Tcl/Tk, Visual Basic, Java 59

60

60

Zuse’s Plankalkül (Plan Calculus) • Designed in 1945, but not published until 1972 •

Zuse’s Plankalkül (Plan Calculus) • Designed in 1945, but not published until 1972 • First compiler in 1998 • Engineering Purpose • Never implemented • Advanced data structures – floating point, arrays, records 61

Plankalkül Syntax • An assignment statement to assign the expression A[4] + 1 to

Plankalkül Syntax • An assignment statement to assign the expression A[4] + 1 to A[5] V S | A + 1 => A | 4 5 | 1. n (subscripts) (data types) 62

Minimal Hardware Programming: Pseudocodes • What was wrong with using machine code? –Poor readability

Minimal Hardware Programming: Pseudocodes • What was wrong with using machine code? –Poor readability –Poor modifiability –Expression coding was tedious –Machine deficiencies--no indexing or floating point 63

Pseudocodes: Short Code • Short Code developed by Mauchly in 1949 for BINAC computers

Pseudocodes: Short Code • Short Code developed by Mauchly in 1949 for BINAC computers – Expressions were coded, left to right – Example of operations: X 0 = SQRT(ABS(Y 0)) 00 X 0 03 20 06 Y 0 01 02 03 04 – ) = / 06 07 08 09 abs value + pause ( 1 n 2 n 4 n 58 (n+2)nd power (n+2)nd root if <= n print and tab 64

Pseudocodes: Speedcoding • Speedcoding developed by Backus in 1954 for IBM 701 – Pseudo

Pseudocodes: Speedcoding • Speedcoding developed by Backus in 1954 for IBM 701 – Pseudo ops for arithmetic and math functions – Conditional and unconditional branching – Auto-increment registers for array access – Slow! – Only 700 words left for user program 65

IBM 704 and Fortran • • Fortran 0: 1954 - not implemented Fortran I:

IBM 704 and Fortran • • Fortran 0: 1954 - not implemented Fortran I: 1957 – Designed for the new IBM 704, which had index registers and floating point hardware - This led to the idea of compiled programming languages, because there was no place to hide the cost of interpretation – Environment of development • Computers had small memories, slow and unreliable • Applications were scientific • No programming methodology or tools • Machine efficiency was the most important concern 66

Design Process of Fortran • Impact of environment on design of Fortran I –

Design Process of Fortran • Impact of environment on design of Fortran I – No need for dynamic storage – Need good array handling and counting loops – No string handling, decimal arithmetic, or powerful input/output (for business software) 67

Fortran I Overview • First implemented version of Fortran – Names could have up

Fortran I Overview • First implemented version of Fortran – Names could have up to six characters – Post-test counting loop (DO) – Formatted I/O – User-defined subprograms – Three-way selection statement (arithmetic IF) – No data typing statements 68

Fortran I Overview (con’t) • First implemented version of FORTRAN – No separate compilation

Fortran I Overview (con’t) • First implemented version of FORTRAN – No separate compilation – Compiler released in April 1957, after 18 worker-years of effort – Programs larger than 400 lines rarely compiled correctly, mainly due to poor reliability of 704 – Code was very fast – Quickly became widely used 69

Fortran II • Distributed in 1958 –Independent compilation –Fixed the bugs 70

Fortran II • Distributed in 1958 –Independent compilation –Fixed the bugs 70

Fortran IV • Evolved during 1960 -62 –Explicit type declarations –Logical selection statement –Subprogram

Fortran IV • Evolved during 1960 -62 –Explicit type declarations –Logical selection statement –Subprogram names could be parameters –ANSI standard in 1966 71

Fortran 77 • Became the new standard in 1978 –Character string handling –Logical loop

Fortran 77 • Became the new standard in 1978 –Character string handling –Logical loop control statement –IF-THEN-ELSE statement 72

Fortran 90 • Most significant changes from Fortran 77 – Modules – Dynamic arrays

Fortran 90 • Most significant changes from Fortran 77 – Modules – Dynamic arrays – Pointers – Recursion – CASE statement – Parameter type checking 73

Latest versions of Fortran • Fortran 95 – relatively minor additions, plus some deletions

Latest versions of Fortran • Fortran 95 – relatively minor additions, plus some deletions • Fortran 2003 - ditto 74

Fortran Evaluation • Highly optimizing compilers (all versions before 90) – Types and storage

Fortran Evaluation • Highly optimizing compilers (all versions before 90) – Types and storage of all variables are fixed before run time • Dramatically changed forever the way computers are used • Characterized as the lingua franca of the computing world 75

Functional Programming: LISP • LISt Processing language – Designed at MIT by Mc. Carthy

Functional Programming: LISP • LISt Processing language – Designed at MIT by Mc. Carthy • AI research needed a language to – Process data in lists (rather than arrays) – Symbolic computation (rather than numeric) • Only two data types: atoms and lists • Syntax is based on lambda calculus 76

Representation of Two LISP Lists Representing the lists (A B C D) and (A

Representation of Two LISP Lists Representing the lists (A B C D) and (A (B C) D (E (F G))) 77

LISP Evaluation • Pioneered functional programming – No need for variables or assignment –

LISP Evaluation • Pioneered functional programming – No need for variables or assignment – Control via recursion and conditional expressions • Still the dominant language for AI • COMMON LISP and Scheme are contemporary dialects of LISP • ML, Miranda, and Haskell are related languages 78

Scheme • • • Developed at MIT in mid 1970 s Small Extensive use

Scheme • • • Developed at MIT in mid 1970 s Small Extensive use of static scoping Functions as first-class entities Simple syntax (and small size) make it ideal for educational applications 79

COMMON LISP • An effort to combine features of several dialects of LISP into

COMMON LISP • An effort to combine features of several dialects of LISP into a single language • Large, complex 80

The First Step Toward Sophistication: ALGOL 60 • Environment of development – FORTRAN had

The First Step Toward Sophistication: ALGOL 60 • Environment of development – FORTRAN had (barely) arrived for IBM 70 x – Many other languages were being developed, all for specific machines – No portable language; all were machinedependent – No universal language for communicating algorithms • ALGOL 60 was the result of efforts to design a universal language 81

Early Design Process • ACM and GAMM met for four days for design (May

Early Design Process • ACM and GAMM met for four days for design (May 27 to June 1, 1958) • Goals of the language – Close to mathematical notation – Good for describing algorithms – Must be translatable to machine code 82

ALGOL 58 • • • Concept of type was formalized Names could be any

ALGOL 58 • • • Concept of type was formalized Names could be any length Arrays could have any number of subscripts Parameters were separated by mode (in & out) Subscripts were placed in brackets Compound statements (begin. . . end) Semicolon as a statement separator Assignment operator was : = if had an else-if clause No I/O - “would make it machine dependent” 83

ALGOL 58 Implementation • Not meant to be implemented, but variations of it were

ALGOL 58 Implementation • Not meant to be implemented, but variations of it were (MAD, JOVIAL) • Although IBM was initially enthusiastic, all support was dropped by mid 1959 84

ALGOL 60 Overview • Modified ALGOL 58 at 6 -day meeting in Paris •

ALGOL 60 Overview • Modified ALGOL 58 at 6 -day meeting in Paris • New features – Block structure (local scope) – Two parameter passing methods – Subprogram recursion – Stack-dynamic arrays – Still no I/O and no string handling 85

ALGOL 60 Evaluation • Successes – It was the standard way to publish algorithms

ALGOL 60 Evaluation • Successes – It was the standard way to publish algorithms for over 20 years – All subsequent imperative languages are based on it – First machine-independent language – First language whose syntax was formally defined (BNF) 86

ALGOL 60 Evaluation (con’t) • Failure – Never widely used, especially in U. S.

ALGOL 60 Evaluation (con’t) • Failure – Never widely used, especially in U. S. – Reasons • Lack of I/O and the character set made programs non-portable • Too flexible--hard to implement • Entrenchment of Fortran • Formal syntax description • Lack of support from IBM 87

Computerizing Business Records: COBOL • Environment of development – UNIVAC was beginning to use

Computerizing Business Records: COBOL • Environment of development – UNIVAC was beginning to use FLOW-MATIC – USAF was beginning to use AIMACO – IBM was developing COMTRAN 88

COBOL Historical Background • Based on FLOW-MATIC • FLOW-MATIC features – Names up to

COBOL Historical Background • Based on FLOW-MATIC • FLOW-MATIC features – Names up to 12 characters, with embedded hyphens – English names for arithmetic operators (no arithmetic expressions) – Data and code were completely separate – The first word in every statement was a verb 89

COBOL Design Process • First Design Meeting (Pentagon) - May 1959 • Design goals

COBOL Design Process • First Design Meeting (Pentagon) - May 1959 • Design goals – Must look like simple English – Must be easy to use, even if that means it will be less powerful – Must broaden the base of computer users – Must not be biased by current compiler problems • Design committee members were all from computer manufacturers and Do. D branches • Design Problems: arithmetic expressions? subscripts? Fights among manufacturers 90

COBOL Evaluation • Contributions – First macro facility in a high-level language – Hierarchical

COBOL Evaluation • Contributions – First macro facility in a high-level language – Hierarchical data structures (records) – Nested selection statements – Long names (up to 30 characters), with hyphens – Separate data division 91

COBOL: Do. D Influence • First language required by Do. D –would have failed

COBOL: Do. D Influence • First language required by Do. D –would have failed without Do. D • Still the most widely used business applications language 92

The Beginning of Timesharing: BASIC • Designed by Kemeny & Kurtz at Dartmouth •

The Beginning of Timesharing: BASIC • Designed by Kemeny & Kurtz at Dartmouth • Design Goals: – Easy to learn and use for non-science students – Must be “pleasant and friendly” – Fast turnaround for homework – Free and private access – User time is more important than computer time • Current popular dialect: Visual BASIC • First widely used language with time sharing 93

Everything for Everybody: PL/I • Designed by IBM and SHARE • Computing situation in

Everything for Everybody: PL/I • Designed by IBM and SHARE • Computing situation in 1964 (IBM's point of view) – Scientific computing • IBM 1620 and 7090 computers • FORTRAN • SHARE user group – Business computing • IBM 1401, 7080 computers • COBOL • GUIDE user group 94

PL/I: Background • By 1963 – Scientific users began to need more elaborate I/O,

PL/I: Background • By 1963 – Scientific users began to need more elaborate I/O, like COBOL had; business users began to need floating point and arrays for MIS – It looked like many shops would begin to need two kinds of computers, languages, and support staff--too costly • The obvious solution – Build a new computer to do both kinds of applications – Design a new language to do both kinds of applications 95

PL/I: Design Process • Designed in five months by the 3 X 3 Committee

PL/I: Design Process • Designed in five months by the 3 X 3 Committee – Three members from IBM, three members from SHARE • Initial concept – An extension of Fortran IV • Initially called NPL (New Programming Language) • Name changed to PL/I in 1965 96

PL/I: Evaluation • PL/I contributions – First unit-level concurrency – First exception handling –

PL/I: Evaluation • PL/I contributions – First unit-level concurrency – First exception handling – Switch-selectable recursion – First pointer data type – First array cross sections • Concerns – Many new features were poorly designed – Too large and too complex 97

Two Early Dynamic Languages: APL and SNOBOL • Characterized by dynamic typing and dynamic

Two Early Dynamic Languages: APL and SNOBOL • Characterized by dynamic typing and dynamic storage allocation • Variables are untyped – A variable acquires a type when it is assigned a value • Storage is allocated to a variable when it is assigned a value 98

APL: A Programming Language • Designed as a hardware description language at IBM by

APL: A Programming Language • Designed as a hardware description language at IBM by Ken Iverson around 1960 – Highly expressive (many operators, for both scalars and arrays of various dimensions) – Programs are very difficult to read • Still in use; minimal changes 99

SNOBOL • Designed as a string manipulation language at Bell Labs by Farber, Griswold,

SNOBOL • Designed as a string manipulation language at Bell Labs by Farber, Griswold, and Polensky in 1964 • Powerful operators for string pattern matching • Slower than alternative languages (and thus no longer used for writing editors) • Still used for certain text processing tasks 100

The Beginning of Data Abstraction: SIMULA 67 • Designed primarily for system simulation in

The Beginning of Data Abstraction: SIMULA 67 • Designed primarily for system simulation in Norway by Nygaard and Dahl • Based on ALGOL 60 and SIMULA I • Primary Contributions – Coroutines - a kind of subprogram – Classes, objects, and inheritance 101

Orthogonal Design: ALGOL 68 • From the continued development of ALGOL 60 but not

Orthogonal Design: ALGOL 68 • From the continued development of ALGOL 60 but not a superset of that language • Source of several new ideas (even though the language itself never achieved widespread use) • Design is based on the concept of orthogonality – A few basic concepts, plus a few combining mechanisms 102

ALGOL 68 Evaluation • Contributions – User-defined data structures – Reference types – Dynamic

ALGOL 68 Evaluation • Contributions – User-defined data structures – Reference types – Dynamic arrays (called flex arrays) • Comments – Less usage than ALGOL 60 – Had strong influence on subsequent languages, especially Pascal, C, and Ada 103

Pascal - 1971 • Developed by Wirth (a former member of the ALGOL 68

Pascal - 1971 • Developed by Wirth (a former member of the ALGOL 68 committee) • Designed for teaching structured programming • Small, simple, nothing really new • Largest impact was on teaching programming – From mid-1970 s until the late 1990 s, it was the most widely used language for teaching programming 104

C - 1972 • Designed for systems programming (at Bell Labs by Dennis Richie)

C - 1972 • Designed for systems programming (at Bell Labs by Dennis Richie) • Evolved primarily from BCLP, B, but also ALGOL 68 • Powerful set of operators, but poor type checking • Initially spread through UNIX • Many areas of application 105

Programming Based on Logic: Prolog • Developed, by Comerauer and Roussel (University of Aix-Marseille),

Programming Based on Logic: Prolog • Developed, by Comerauer and Roussel (University of Aix-Marseille), with help from Kowalski ( University of Edinburgh) • Based on formal logic • Non-procedural • Can be summarized as being an intelligent database system that uses an inferencing process to infer the truth of given queries • Highly inefficient, small application areas 106

History’s Largest Design Effort: Ada • Huge design effort, involving hundreds of people, much

History’s Largest Design Effort: Ada • Huge design effort, involving hundreds of people, much money, and about eight years – Strawman requirements (April 1975) – Woodman requirements (August 1975) – Tinman requirements (1976) – Ironman equipments (1977) – Steelman requirements (1978) • Named Ada after Augusta Ada Byron, the first programmer 107

Ada Evaluation • • Contributions – Packages - support for data abstraction – Exception

Ada Evaluation • • Contributions – Packages - support for data abstraction – Exception handling - elaborate – Generic program units – Concurrency - through the tasking model Comments – Competitive design – Included all that was then known about software engineering and language design – First compilers were very difficult; the first really usable compiler came nearly five years after the language design was completed 108

Ada 95 • Ada 95 (began in 1988) – Support for OOP through type

Ada 95 • Ada 95 (began in 1988) – Support for OOP through type derivation – Better control mechanisms for shared data – New concurrency features – More flexible libraries • Popularity suffered because the Do. D no longer requires its use but also because of popularity of C++ 109

Object-Oriented Programming: Smalltalk • Developed at Xerox PARC, initially by Alan Kay, later by

Object-Oriented Programming: Smalltalk • Developed at Xerox PARC, initially by Alan Kay, later by Adele Goldberg • First full implementation of an objectoriented language (data abstraction, inheritance, and dynamic binding) • Pioneered the graphical user interface design • Promoted OOP 110

Combining Imperative and Object. Oriented Programming: C++ • Developed at Bell Labs by Stroustrup

Combining Imperative and Object. Oriented Programming: C++ • Developed at Bell Labs by Stroustrup in 1980 • Evolved from C and SIMULA 67 • Facilities for object-oriented programming, taken partially from SIMULA 67 • Provides exception handling • A large and complex language, in part because it supports both procedural and OO programming • Rapidly grew in popularity, along with OOP • ANSI standard approved in November 1997 • Microsoft’s version (released with. NET in 2002): Managed C++ – delegates, interfaces, no multiple inheritance 111

Related OOP Languages • Eiffel (designed by Bertrand Meyer - 1992) – Not directly

Related OOP Languages • Eiffel (designed by Bertrand Meyer - 1992) – Not directly derived from any other language – Smaller and simpler than C++, but still has most of the power – Lacked popularity of C++ because many C++ enthusiasts were already C programmers • Delphi (Borland) – Pascal plus features to support OOP – More elegant and safer than C++ 112

An Imperative-Based Object-Oriented Language: Java • Developed at Sun in the early 1990 s

An Imperative-Based Object-Oriented Language: Java • Developed at Sun in the early 1990 s – C and C++ were not satisfactory for embedded electronic devices • Based on C++ – Significantly simplified (does not include struct, union, enum, pointer arithmetic, and half of the assignment coercions of C++) – Supports only OOP – Has references, but not pointers – Includes support for applets and a form of concurrency 113

Java Evaluation • Eliminated many unsafe features of C++ • Supports concurrency • Libraries

Java Evaluation • Eliminated many unsafe features of C++ • Supports concurrency • Libraries for applets, GUIs, database access • Portable: Java Virtual Machine concept, JIT compilers • Widely used for Web programming • Use increased faster than any previous language • Most recent version, 5. 0, released in 2004 114

Scripting Languages for the Web • Perl – Designed by Larry Wall—first released in

Scripting Languages for the Web • Perl – Designed by Larry Wall—first released in 1987 – Variables are statically typed but implicitly declared – Three distinctive namespaces, denoted by the first character of a variable’s name – Powerful, but somewhat dangerous – Gained widespread use for CGI programming on the Web – Also used for a replacement for UNIX system administration language 115

Scripting Languages for the Web • Java. Script – Began at Netscape, but later

Scripting Languages for the Web • Java. Script – Began at Netscape, but later became a joint venture of Netscape and Sun Microsystems – A client-side HTML-embedded scripting language, often used to create dynamic HTML documents – Purely interpreted – Related to Java only through similar syntax 116

Scripting Languages for the Web • PHP – PHP: Hypertext Preprocessor, designed by Rasmus

Scripting Languages for the Web • PHP – PHP: Hypertext Preprocessor, designed by Rasmus Lerdorf – A server-side HTML-embedded scripting language, often used form processing and database access through the Web – Purely interpreted 117

Scripting Languages for the Web • Python – An OO interpreted scripting language –

Scripting Languages for the Web • Python – An OO interpreted scripting language – Type checked but dynamically typed – Used for CGI programming and form processing – Dynamically typed, but type checked – Supports lists, tuples, and hashes 118

Scripting Languages for the Web • Lua – An OO interpreted scripting language –

Scripting Languages for the Web • Lua – An OO interpreted scripting language – Type checked but dynamically typed – Used for CGI programming and form processing – Dynamically typed, but type checked – Supports lists, tuples, and hashes, all with its single data structure, the table – Easily extendable 119

Scripting Languages for the Web • Ruby – Designed in Japan by Yukihiro Matsumoto

Scripting Languages for the Web • Ruby – Designed in Japan by Yukihiro Matsumoto (a. k. a, “Matz”) – Began as a replacement for Perl and Python – A pure object-oriented scripting language - All data are objects – Most operators are implemented as methods, which can be redefined by user code – Purely interpreted 120

A C-Based Language for the New Millennium: C# • Part of the. NET development

A C-Based Language for the New Millennium: C# • Part of the. NET development platform (2000) • Based on C++ , Java, and Delphi • Provides a language for component-based software development • All. NET languages use Common Type System (CTS), which provides a common class library 121

Markup/Programming Hybrid Languages • XSLT – e. Xtensible Markup Language (XML): a metamarkup language

Markup/Programming Hybrid Languages • XSLT – e. Xtensible Markup Language (XML): a metamarkup language – e. Xtensible Stylesheet Language Transformation (XSTL) transforms XML documents for display – Programming constructs (e. g. , looping) 122

Markup/Programming Hybrid Languages • JSP – Java Server Pages: a collection of technologies to

Markup/Programming Hybrid Languages • JSP – Java Server Pages: a collection of technologies to support dynamic Web documents – servlet: a Java program that resides on a Web server and is enacted when called by a requested HTML document; a servlet’s output is displayed by the browser – JSTL includes programming constructs in the form of HTML elements 123