CPS 506 Comparative Programming Languagesssamet/cps506/CPS 506 (Winter 2010 Ryerson... · –Ruby (...

Post on 17-Oct-2020

4 views 0 download

transcript

CPS 506Comparative Programming

LLanguagesWinter 2010Winter 2010

Ryerson UniversityRyerson University

Course OutlineCourse Outlined• Introduction

• Syntax and Semantic Specificationy p• Type Systems, Semantics and Data Types• Names Scope Expression• Names, Scope, Expression• Control Structures

b d P P i• Sub-program and Parameter Passing• Exception Handlingp g• Abstract Data Type and Encapsulation

2

Course Outline (con’t)Course Outline (con t)P i L P di• Programming Language Paradigms–Imperative (C Pascal …)Imperative (C, Pascal,…)–Object-Oriented (C++, C#, Java,…)

L i (P l M )–Logic (Prolog, Mercury)–Functional (ML, Scheme, Haskell,…)( , m , , )–Even-driven (Visual Basic, Java,…)

C t P ll l (SR Li d )–Concurrent or Parallel (SR, Linda,…)–Multi-Paradigm (Ruby, Python, Perl,…)g ( y y )

3

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

• Functional language–Ruby (1993)Ruby (1993)

• A balanced functional and imperative languageslanguages

–Python (1991)• Object-Oriented functional and • Object-Oriented, functional and

imperative language

4

TextbookTextbookC t f P i L • Concepts of Programming Languages, 9th Edition

B R b W b– By Robert W. Sebestahttp://www.coursesmart.com/0136073476

• Programming Languages: Principles d P di 2 d Edi ig g g g p

and Paradigms, 2nd Edition– By Allen Tucker and Robert Noonany

http://www.mhhe.com/engcs/compsci/tucker/• …

5

EvaluationEvaluationA i (20%)• Assignments (20%)

• Midterm (30%)Midterm (30%)• Final Exam (50%)

Optional Project (10%)• Optional Project (10%)–Programming language surveyg g g g y–Paradigm survey

6

Contact InformationContact Information b P• Course Web Page

www.scs.ryerson.ca/~ssamet/y(check every three days)

• Contact Email• Contact Emailssamet@scs.ryerson.ca

Offi H• Office HoursTBA

• Teaching AssistantTBA

7

Why programming Languages?Why programming Languages?

F ilit t i f id d • 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 th ht thought processes

• Ability to choose appropriate language– understanding main features of the

languages8

Why programming Languages? y p g g g g(con’t)

I s bilit t l d d si • Increase ability to learn and design new languages

Understanding fundamental concepts– Understanding fundamental concepts• Better usage of the languages

L i k d d t f th – Learning unknown and unused parts of the languages

• Overall advancement of computing• Overall advancement of computing– Most popular languages are not always the

best onesbest ones– ALGOL 60 and Fortran

9

Introduction (con’t)Introduction (con t)Diff t f t l l• Different from natural languages– Narrower expressive domain

(Al ith i id )(Algorithmic ideas)– Communication between human and

tcomputer

• Future programming languages– Understand features, strengths and n r tan f atur , tr ngth an

weaknesses– New application needspp

10

Programming Language QualitiesProgramming Language Qualities• Criteria• Criteria

–Readability• Ease of reading and understanding a • Ease of reading and understanding a

program• Before 1970s

Effi i d M hi d bilit–Efficiency and Machine readability–Design from the point of view of

computer1970 d f

p• 1970s and after

–Software life-cycle concept–MaintenanceMaintenance–Machine orientation -> Human orientation

• Consider in the context of the domain11

Programming Language QualitiesProgramming Language Qualities

C it i ( ’t)• Criteria (con’t)–WritabilityWritability

• How easily a language can be used• Tough relation with readability • Tough relation with readability • Consider in the context of the domaindomain

–VB for GUIC for system programs–C for system programs

12

Programming Language QualitiesProgramming Language Qualities

C it i ( ’t)• Criteria (con’t)–ReliabilityReliability

• Performs according to the specifications under all conditionsspecifications under all conditions

• Crucial criterion for embedded, scientific real-time and human scientific, real time and human related systems

13

Programming Language QualitiesProgramming Language Qualities

Characteristics• Characteristics–Simplicity and Clarityp y y

• How easily a program is written and readK l d diff f th d • Knowledge difference of author and reader

Bindin–Binding• Language definition, implementation time program writing time compile time, program writing time, compile time, run time

14

Programming Language Qualities (con’t)

h ( ’ )

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 languagelanguage

• 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

E i i i• Expensive in run-time• Original C language had no parameter type checking

15

Programming Language Qualities (con’t)

h ( )

Programming Language Qualities (con t)

• Characteristics (con’t)– Exception handlingE p g

• Ability to intercept run-time errors• Prevent system crashPrevent system crash

– Aliasing• Same memory two or more names• Same memory, two or more names• Side-effect• Difficult program verification• Difficult program verification

– Applicability f h l d• Support for the application domain

16

Programming Language Qualities (con’t)Programming Language Qualities (con t)

• Characteristics (con’t)Abstraction–Abstraction• Complex s structures without pspecifying the detail implementation

Effi i t Im l m t ti–Efficient Implementation• Problems like in early r m n r yimplementation of Java and Ada

17

Programming Language Qualities (con’t)Programming Language Qualities (con t)

• Cost– Training, Writing, Compiling, Executing, g, W g, mp g, E g,

Maintenance, Implementation environment • Portability• Portability

– One program on different platforms• Generality

– Applicability to wide range of application Applicability to wide range of application domain

18

Quality Trade offsQuality Trade-offsR li bilit s W it bilit• Reliability vs. Writability– C: Pointers are flexible and powerfulR li bilit E ti C t• Reliability vs. Execution Cost– Java: Array index checking

b l d b l• Writability vs. Readability– APL: Many new symbols and complex

t ticomputations• Example: Find all prime numbers from 1 to R:( R R ×R)/R 1↓ R (From Wikipedia)(~R R .×R)/R←1↓⍳R (From Wikipedia)

19

Influence on Language DesignInfluence on Language DesignC t A hit t• Computer Architecture– Many languages are designed according

t th l t hit t V to the prevalent architecture, Van NeumannI ti l– 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 memoryy

20

Influence on Language Design g g g(con’t)

• Van Neumann ArchitectureMemory

ControlAlgorithmic Logic UnitControl 

UnitLogic UnitAccumulator

Input InputInput Input21

Influence on Language Design g g g(con’t)

C t A hit t ( ’t)• Computer Architecture (con’t)–Variables model memory celly–Assignments statements based on

piping operationp p g p–Iterative form of repetition:

efficient way to implement loops efficient way to implement loops (instructions stored in adjacent cells))

–Fetch-Execute cycle

22

Influence on Language Design g g g(con’t)

• Software Development MethodologiesMethodologies–New paradigm, new languagesp gm, g g

23

Programming methodologies influencesProgramming methodologies influences

d l l • 1950s and early 1960s: Simple applications; machine efficiency problempp y p

Late 1960s: Efficiency became important; • Late 1960s: Efficiency became important; readability; better control structures– structured programming– top-down designtop own s gn

24

Programming methodologies influences (con’t)

• Late 1970s: Process-oriented to data-orientedoriented– data abstraction

• Mid 1980s: Object-oriented • Mid 1980s: Object-oriented programming– Data abstraction; inheritance; dynamic

method binding (polymorphism)g (p y p )25

Implementation MethodsImplementation MethodsC il• Compiler–Translation of the program to p g

machine code–Examples: C, Pascal, Haskell, MLmp , , ,

Interpreter• Interpreter–Program is interpreted by a software

ig p y

program, interpreter–Examples: Cobol, APL, LISPp , ,

26

Implementation Methods (con’t)Implementation Methods (con t)H b id impl m nt ti n• Hybrid implementation– Partially translated to detect errors

Translate to an intermediate language for easier – Translate to an intermediate language for easier interpretation

– Example: Perl, initial implementation of Javap p

• Just-In-Time– Translate to intermediate language– Compile the methods that are called

E l J N t l– Example: Java, .Net languages

27

L d Vi f C mputLayered View of ComputerThe operating The operating system and language language implementation are layered are layered over machine interface of a computer

28

CompilationCompilation

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

• Slow translation, fast execution

29

The Compilation ProcessThe Compilation Process• Compilation process phases:

– lexical analysis: converts characters in the source program into lexical units

– IdentifiersIdentifiers– Special words– Operators– Punctuation symbols

– syntax analysis: transforms lexical units into parse trees which represent units into parse trees which represent the syntactic structure of program

– Semantics analysis: generate intermediate code

– code generation: machine code is generatedgenerated

30

Additional Compilation TerminologiesAdditional Compilation Terminologies

• Load module (executable image): the user and system code togetherthe user and system code together

• Linking and loading: the process of collecting system program units and linking them to a user programlinking them to a user program

31

Von Neumann BottleneckVon Neumann BottleneckC d b ’ • Connection speed between a computer’s memory and its processor determines the speed of a

tcomputer• Program instructions often can be executed much

f t th th d f th ti th faster than the speed of the connection; the connection speed thus results in a bottleneckK th N b ttl k it i th • Known as the von Neumann bottleneck; it is the primary limiting factor in the speed of computersM i i f h d d l f • Motivation for research and development of parallel computers

32

Pure InterpretationPure InterpretationN t l ti• No translation

• Works as a software simulation of a machine• Easier implementation of programs (run-time

errors can easily and immediately be di l d)displayed)

• Slower execution (10 to 100 times slower th il d )than compiled programs)– Decoding high-level language statements

St t t d d d ti t d– Statements are decoded every time executed– Bottleneck is statement decoding and not the

communication between memory and processorcommunication between memory and processor33

Pure Interpretation (con’t)Pure Interpretation (con t)Oft n r quir s m r sp c• Often requires more space– In addition of source, symbol table has to be present

during interpretationg p– Storing source program in a form for easy access and

modification and not in minimal size• Pure interpreters (1960s)Pure interpreters (1960s)

– APL, SNOBOL, LISP• Rarely used in high-level languages (by the

1 0 )y g g g ( y

1980s)• Significant comeback with some Web scripting

languageslanguages– JavaScript– PHP

34

Pure Interpretation ProcessPure Interpretation Process

35

Hybrid Implementation SystemsHybrid Implementation Systems

• A compromise between compilers and pure interpretersp

• A high-level language program is translated t i t di t l th t ll to an intermediate language that allows easy interpretation– Faster than pure interpretation– Source statements are decoded only onceSource statements are decoded only once

36

Hybrid Implementation SystemsHybrid Implementation SystemsE l• Examples– Perl programs are partially compiled to

• Detect errors before interpretation• Detect errors before interpretation• Simplify the interpreter

– Initial implementations of Java were hybrid; the mp m f y ;intermediate form, byte code, provides portability to any machine that has

B t d i t t• Byte code interpreter• Associated run-time system • Together, these are called Java Virtual Machineg , J V u M n

– New versions translate Java byte code into machine code for faster execution

37

Hybrid Implementation ProcessHybrid Implementation Process

38

Just-in-Time Implementation SystemsJust-in-Time Implementation Systems

ll l d • Initially translate programs to an intermediate language

• Then compile the intermediate language of the subprograms into machine code when they are

ll d called • Machine code version is kept for subsequent calls• JIT systems are widely used for Java programs• .NET languages are implemented with a JIT p

system

39

PreprocessorsPreprocessors• Preprocessor macros (instructions) are Preprocessor macros (instructions) are

commonly used to specify that code from another file is to be includedf

• A preprocessor processes a program immediately before the program is compiled mm y f p g m mpto expand embedded preprocessor macros

• A well-known example: C preprocessormp p p– expands #include, #define, and similar

macros• Possible side effect

40

Principles of language designPrinciples of language designB si b l t ss l • Basic vocabulary to express language structures, meaning, …, borrowed from

Linguistics– Linguistics– MathematicsP in ipl s t i s• Principles categories– Syntax

T S t d S ti– Type Systems and Semantics– Memory Management

E ti H dli– Exception Handling

41

Syntax (form)Syntax (form)G f i i • Grammar for writing programs

• Basic vocabulary of• Basic vocabulary of–Keywordsy–SymbolsC bi ti f k d d • Combinations of keywords and symbols forming a syntactically symbols forming a syntactically correct program

42

Syntax (con’t)Syntax (con t)P l C• Pascal

program sample;var

• Cmain() {

int a b;vara,b:integer;

begin

int a,b;a = 1;b = a+1;

a := 1;b := a+1;If ( b = a ) then

if ( b == a ){

a++;( )begin

a := a+1; b := 0;

a++;b = 0;

}b := 0;end;

end.

}

43

Type Systems and SemanticsType Systems and SemanticsT p f l s• Type of values

• Meaning of the programsF m l pp h t und st nd ff ts f• Formal approach to understand effects of– Statements

Sequence of steps– Sequence of steps– Loops– Conditional statementsConditional statements– …

• Abstract definition (independent of machine ( por OS architectures)

44

Type Systems and Semantics yp y(con’t)

Diff t h t isti s f d t bj t• Different characteristics of data object– Location

N– Name– Value

T– Type• Primitive, Composite and Recursive data

t p stypes• Type Binding

T Ch k• Type Checking• Type Conversionyp

45

Memory ManagementMemory ManagementM i f l d • Mapping of values, data structures and program structures, and program structures to the memory

• Static memory (Stack)• Dynamic memory (Heap)• Dynamic memory (Heap)• Objects lifetimeObjects lifetime• Garbage collection

46

Exception HandlingException Handling

• Unexpected input errorU t d di i i b • Unexpected division by zero

• Unexpected unsuccessful space • Unexpected unsuccessful space allocation in the heapp

• A fundamental feature in modern languages

47

Programming ParadigmsProgramming ParadigmsI i• Imperative– Series of steps

• CalculateCalculate• Retrieve input• Produce output

– Procedural Abstraction• Assignments• LoopsLoops• Sequences• Conditional Statements

E l– Examples• Cobol, Fortran, C, C++

48

Programming Paradigms (con’t)Programming Paradigms (con t)

d• Object Oriented– Collection of objects interact with each j

other– Building blocksBuilding blocks

• Object modeling• Classification• Classification• Inheritance

E l– Examples• Java, Smalltalk, C++, C#, Ruby, Ada 95

49

Programming Paradigms (con’t)Programming Paradigms (con t)

• Logic– Collection of declarative rules– “What outcome” instead of “How

accomplish”accomplish– Natural vehicle for expressing non-

determinismdeterminism– A series of possible solutions to a problem– Examples

• Prolog

50

Programming Paradigms (con’t)Programming Paradigms (con t)

l• Functional– Collection of mathematical functions– One input (domain) and one result (range)

Functions interacts using– Functions interacts using• Composition

C diti l• Conditionals• Recursion

– Examples• Lisp, Scheme, ML, Haskell

51

Programming Paradigms (con’t)Programming Paradigms (con t)

• Event-drivenContinuous loop that responds to –Continuous loop that responds to events

–Events could be in various ordersl• Keystroke, mouse click, …

–Examples–Examples• Visual Basic, Java

52

Programming Paradigms (con’t)Programming Paradigms (con t)

C t• Concurrent– Collection of parallel processes or p p

treads– Sharing informationSharing information– Processes could be executed

asynchronouslyasynchronously– Parallelism in one process– Examples

• SR, Linda, High Performance Fortrang53

Programming Paradigms (con’t)Programming Paradigms (con t)

M lti P di• Multi-Paradigm– Support more than one programming

dparadigm– Frameworks providing a variety of styles

f for programmer to use a mix constructs from various paradigmsId Th i i l di l – Idea: There is no single paradigm to solve the problems efficiently and easilyE l– Examples• Oz, Ruby, Python, Perl, …

54

Application DomainsApplication Domains

• ScientificComplex calculations–Complex calculations

–Fast processp–Accurate results

I ti d ll l di–Imperative and parallel paradigms–Fortran 90, C, High Performance F 9 , , g f m

Fortran

55

Application Domains (con’t)Application Domains (con t)

• Management Information Systems (MIS)Systems (MIS)–Business and commercial systemsmm y m–Database management–Imperative, Declarative and

event-driven paradigmsevent-driven paradigms–Cobol, RPG, SQL, Java, Tcl/Tk, , Q , ,

56

Application Domains (con’t)Application Domains (con t)

• Artificial Intelligence (AI)Modelin human intelli ent bahavior–Modeling human intelligent bahavior

–Logical deductionLogical deduction–Cognition–Functional and logic paradigms

P l CLP–Prolog, CLP

57

Application Domains (con’t)Application Domains (con t)

• SystemsOperating systems–Operating systems

–Network software–Compilers

I ti t d i d –Imperative, event-driven, and parallel paradigms

–C

58

Application Domains (con’t)Application Domains (con t)

• Web-centricE Commerce–E-Commerce

–E-GovernmentE Government–Event-driven, and Object-

Oriented paradigmsPerl Tcl/Tk Visual Basic Java–Perl, Tcl/Tk, Visual Basic, Java

59

60

Zuse’s Plankalkül (Plan Calculus)Zuse s Plankalkül (Plan Calculus)

• Designed in 1945, but not published until 1972until 1972

• First compiler in 1998• Engineering Purpose• Never implemented• Never implemented• Advanced data structures

–floating point, arrays, records

61

Plankalkül SyntaxPlankalkül Syntax

• An assignment statement to assign the expression A[4] + 1 assign the expression A[4] + 1 to A[5] [ ]

| A + 1 => AV | 4 5 (subscripts)S | 1.n 1.n (data types)

62

Minimal Hardware Programming: P d dPseudocodes

Wh i h i • What was wrong with using machine code?machine code?–Poor readabilityy–Poor modifiabilityE i di t di–Expression coding was tediousMachine deficiencies no –Machine deficiencies--no indexing or floating point

63

Pseudocodes: Short Code Pseudocodes: Short Code h d d l d b hl 1 4 f • Short Code developed by Mauchly in 1949 for

BINAC computers – Expressions were coded, left to right– Example of operations:Example of operations

X0 = SQRT(ABS(Y0))00 X0 03 20 06 Y000 X0 03 20 06 Y0

01 – 06 abs value 1n (n+2)nd power02 ) 07 + 2n (n+2)nd root02 ) 07 + 2n (n+2)nd root03 = 08 pause 4n if <= n04 / 09 ( 58 print and tab

64

Pseudocodes: SpeedcodingPseudocodes: Speedcodingd d d l d b B k 1 4 f • 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– Auto-increment registers for array access– Slow!

O l 700 d l f f – Only 700 words left for user program

65

IBM 704 and FortranIBM 704 and FortranF t 0 1954 t i l t d• Fortran 0: 1954 - not implemented

• Fortran I:1957– Designed for the new IBM 704, which had index registers and Des gned for the new IBM 704, wh ch had ndex reg sters and

floating point hardware- This led to the idea of compiled programming languages, because there was no place to hide the cost of interpretationbecause 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• No programming methodology or tools• Machine efficiency was the most important concern

66

Design Process of FortranDesign Process of Fortran• Impact of environment on design of

Fortran IFortran I–No need for dynamic storage–Need good array handling and

counting loopscounting loops–No string handling, decimal

h f l / arithmetic, or powerful input/output (for business software)(for bus ness software)

67

Fortran I OverviewFortran I Overview l d f • First implemented version of Fortran

– Names could have up to six charactersNames could have up to six characters– Post-test counting loop (DO)

F d /– Formatted I/O– User-defined subprogramsUser defined subprograms– Three-way selection statement

(arithmetic IF)(arithmetic IF)– No data typing statements

68

Fortran I Overview (con’t)Fortran I Overview (con t)F l d f F • First implemented version of FORTRAN – No separate compilationp p– Compiler released in April 1957, after 18

worker-years of effortworker years of effort– Programs larger than 400 lines rarely

compiled correctly mainly due to poor compiled correctly, mainly due to poor reliability of 704Code was very fast– Code was very fast

– Quickly became widely used

69

Fortran IIFortran II

• Distributed in 1958I d d t il ti–Independent compilationFixed the bugs–Fixed the bugs

70

Fortran IVFortran IV

• Evolved during 1960-62E li it t d l ti–Explicit type declarationsLogical selection statement–Logical selection statement

–Subprogram names could be Subprogram names could be parameters

–ANSI standard in 196671

Fortran 77Fortran 77

• Became the new standard in 19781978–Character string handlingCharacter string handling–Logical loop control statementg p–IF-THEN-ELSE statement

72

Fortran 90Fortran 90 f h f • Most significant changes from Fortran

77– Modules

Dynamic arrays– Dynamic arrays– Pointers– Recursion

CASE statement– CASE statement– Parameter type checkingyp g

73

Latest versions of FortranLatest versions of Fortran

• Fortran 95 – relatively minor additions plus some deletionsadditions, plus some deletions

• Fortran 2003 - dittoFortran 2003 ditto

74

Fortran EvaluationFortran Evaluationhl l ( ll • Highly optimizing compilers (all versions

before 90))– Types and storage of all variables are

fixed before run timefixed before run time• Dramatically changed forever the way

dcomputers are used• Characterized as the lingua franca of the Character zed as the l ngua franca of the

computing world

75

Functional Programming: g gLISP

P l• LISt Processing language– Designed at MIT by McCarthyg y y

• AI research needed a language to– Process data in lists (rather than arrays)– Process data in lists (rather than arrays)– Symbolic computation (rather than

numeric)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 (B C) D (E (F G)))

77

LISP EvaluationLISP EvaluationP d f l • Pioneered functional programming– No need for variables or assignmentg– Control via recursion and conditional

expressionsexpressions• Still the dominant language for AI

COMMON LISP and Scheme are • COMMON LISP and Scheme are contemporary dialects of LISPML Mi d d H k ll l d • ML, Miranda, and Haskell are related languages

78

SchemeScheme• Developed at MIT in mid 1970s• Small• Small• Extensive use of static scopingExtensive use of static scoping• Functions as first-class entities• Simple syntax (and small size)

make it ideal for educational make it ideal for educational applicationspp

79

COMMON LISPCOMMON LISP

• An effort to combine features of several dialects of LISP into of several dialects of LISP into a single languageg g g

• Large, complex

80

The First Step Toward Sophistication: ALGOL 60ALGOL 60

E f d l• Environment of development– FORTRAN had (barely) arrived for IBM 70x– Many other languages were being developed, all

for specific machines– No portable language; all were machine-

dependent– No universal language for communicating

algorithmsLG L 60 h l f ff d • ALGOL 60 was the result of efforts to design a

universal language

81

Early Design ProcessEarly Design ProcessACM d GAMM t f f d • ACM and GAMM met for four days for design (May 27 to June 1, 1958)g y

• Goals of the language• Goals of the language–Close to mathematical notation–Good for describing algorithms

Must be translatable to machine –Must be translatable to machine code

82

ALGOL 58ALGOL 58C f f li d• Concept of type was formalized

• Names could be any lengthA s c uld h n numb f subsc ipts• Arrays could have any number of subscripts

• Parameters were separated by mode (in & out)• Subscripts were placed in brackets• Subscripts were placed in brackets• Compound statements (begin ... end)• Semicolon as a statement separatorSemicolon as a statement separator• Assignment operator was :=• if had an else-if clausef f• No I/O - “would make it machine dependent”

83

ALGOL 58 ImplementationALGOL 58 Implementation

• Not meant to be implemented, but variations of it were (MAD but variations of it were (MAD, JOVIAL))

• Although IBM was initially enthusiastic, all support was dropped by mid 1959dropped by mid 1959

84

ALGOL 60 OverviewALGOL 60 Overviewd f d G 6 d P• Modified ALGOL 58 at 6-day meeting in Paris

• New features– Block structure (local scope)– Two parameter passing methods– Two parameter passing methods– Subprogram recursion

k d i – Stack-dynamic arrays

– Still no I/O and no string handling

85

ALGOL 60 EvaluationALGOL 60 EvaluationS• Successes–It was the standard way to publish It was the standard way to publish

algorithms for over 20 yearsAll subsequent imperative languages –All subsequent imperative languages are based on it

–First machine-independent language–First language whose syntax was First language whose syntax was

formally defined (BNF)

86

ALGOL 60 Evaluation (con’t)ALGOL 60 Evaluation (con t)F l• 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 descriptiony p• Lack of support from IBM

87

Computerizing Business Records: COBOLComputerizing Business Records: COBOL

• Environment of developmentUNIVAC b i i t –UNIVAC was beginning to use FLOW-MATICFLOW MATIC

–USAF was beginning to use g gAIMACO

–IBM was developing COMTRAN

88

COBOL Historical BackgroundCOBOL Historical BackgroundB d F• Based on FLOW-MATIC

• FLOW-MATIC features– Names up to 12 characters, with embedded

hyphenshyphens– English names for arithmetic operators (no

arithmetic expressions)arithmetic expressions)– Data and code were completely separate

Th fi d i – The first word in every statement was a verb

89

COBOL Design ProcessCOBOL Design ProcessFi D i M i (P ) M 1959• First Design Meeting (Pentagon) - May 1959

• Design goalsMust l k lik simpl En lish– Must look like simple English

– Must be easy to use, even if that means it will be less powerfulpowerful

– Must broaden the base of computer users– Must not be biased by current compiler problemsy p p

• Design committee members were all from computer manufacturers and DoD branches

• Design Problems: arithmetic expressions? subscripts? Fights among manufacturers

90

COBOL EvaluationCOBOL Evaluation• Contributions

– First macro facility in a high-level First macro facility in a high level languageHierarchical data structures (records)– Hierarchical data structures (records)

– Nested selection statements– Long names (up to 30 characters), with

hyphenshyphens– Separate data division

91

COBOL: DoD InfluenceCOBOL: DoD Influence

• First language required by DoDld h f il d ith t D D–would have failed without DoD

• Still the most widely used • Still the most widely used business applications languagepp g g

92

Th B i i f Ti h i BASICThe Beginning of Timesharing: BASIC

D d b K & K D h• 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 accessp– User time is more important than computer time

• Current popular dialect: Visual BASIC Current popular dialect Visual BASIC • First widely used language with time sharing

93

Everything for Everybody: y g y yPL/I

D d b BM d H RE• Designed by IBM and SHARE• Computing situation in 1964 (IBM's point of view)

– Scientific computing• IBM 1620 and 7090 computers• FORTRAN• SHARE user groupg p

– Business computing• IBM 1401, 7080 computersIBM 1401, 7080 computers• COBOL• GUIDE user groupGUIDE user group

94

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

COBOL had; business users began to need floating COBOL had; business users began to need floating point and arrays for MIS

– It looked like many shops would begin to need two kinds y p gof 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 ProcessPL/I: Design ProcessD d f h b h • 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– An extension of Fortran IV• Initially called NPL (New Programming

Language)Language)• Name changed to PL/I in 1965

96

PL/I: EvaluationPL/I: EvaluationPL/ b• PL/I contributions– First unit-level concurrency– First exception handling– Switch-selectable recursion– First pointer data type– First array cross sectionsy

• Concerns– Many new features were poorly designedMany new features were poorly designed– Too large and too complex

97

Two Early Dynamic Languages: APL and SNOBOL

• Characterized by dynamic typing and dynamic storage allocationand dynamic storage allocation

• Variables are untypedyp–A variable acquires a type when

it i i d lit is assigned a value• Storage is allocated to a variable • Storage is allocated to a variable

when it is assigned a value98

APL: A Programming g gLanguage

d h d d • Designed as a hardware description language at IBM by Ken Iverson around g g y1960– Highly expressive (many operators for – Highly expressive (many operators, for

both scalars and arrays of various dimensions)dimensions)

– Programs are very difficult to readg y• Still in use; minimal changes

99

SNOBOLSNOBOLD d l l • Designed as a string manipulation language at Bell Labs by Farber, Griswold, and Polensky in 19641964

• Powerful operators for string pattern p g pmatching

• Slower than alternative languages (and thus Slower than alternative languages (and thus no longer used for writing editors)

• Still used for certain text processing tasks• Still used for certain text processing tasks

100

The Beginning of Data Abstraction: SIMULA 67

d l f • Designed primarily for system simulation in Norway by Nygaard and y y ygDahl

• Based on ALGOL 60 and SIMULA I• Based on ALGOL 60 and SIMULA I• Primary Contributions

– Coroutines - a kind of subprogram– Classes objects and inheritance– Classes, objects, and inheritance

101

Orthogonal Design: ALGOL 68Orthogonal Design: ALGOL 68

F h d d l f G • 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 g g puse)

• Design is based on the concept of Design is based on the concept of orthogonality– A few basic concepts plus a few combining – A few basic concepts, plus a few combining

mechanisms

102

ALGOL 68 EvaluationALGOL 68 EvaluationC b• Contributions– User-defined data structures– Reference types– Dynamic arrays (called flex arrays)

• Comments– Less usage than ALGOL 60– Had strong influence on subsequent languages, Had strong influence on subsequent languages,

especially Pascal, C, and Ada

103

Pascal 1971Pascal - 1971D l d b h ( f b f h • Developed by Wirth (a former member of the ALGOL 68 committee)

• Designed for teaching structured programmingp g g

• Small, simple, nothing really new• Largest impact was on teaching programming• Largest impact was on teaching programming

– From mid-1970s until the late 1990s, it was the most widely used language for teaching the most widely used language for teaching programming

104

C 1972C - 1972d f ( • Designed for systems programming (at

Bell Labs by Dennis Richie)y )• Evolved primarily from BCLP, B, but also

ALGOL 68ALGOL 68• Powerful set of operators, but poor type

h kichecking• Initially spread through UNIXIn t ally spread through UNIX• Many areas of application

105

Programming Based on Logic: g g gProlog

D l d b d l • Developed, by Comerauer and Roussel (University of Aix-Marseille), with help from

l k ( f Ed b h)Kowalski ( University of Edinburgh)• Based on formal logicg• Non-procedural• Can be summarized as being an intelligent • Can be summarized as being an intelligent

database system that uses an inferencing process to infer the truth of given queriesprocess to infer the truth of given queries

• Highly inefficient, small application areas

106

History’s Largest Design y g gEffort: Ada

H d ff l h d d f • Huge design effort, involving hundreds of people, much money, and about eight years– Strawman requirements (April 1975)– Woodman requirements (August 1975)Woodman requirements (August 1975)– Tinman requirements (1976)

Ironman equipments (1977)– Ironman equipments (1977)– Steelman requirements (1978)

• Named Ada after Augusta Ada Byron, the first programmerp g

107

Ada EvaluationAda EvaluationC t ib ti• Contributions– Packages - support for data abstraction– Exception handling - elaborate Except on handl ng elaborate – Generic program units– Concurrency - through the tasking model

• Comments– Competitive design– Included all that was then known about software engineering 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 compiler came nearly five years after the language design was completed

108

Ada 95Ada 95d (b 1 )• Ada 95 (began in 1988)

– Support for OOP through type derivationpp g yp– Better control mechanisms for shared data– New concurrency features– New concurrency features– More flexible libraries

P l i ff d b h D D • Popularity suffered because the DoD no longer requires its use but also because of

l i f Cpopularity of C++

109

Object-Oriented Programming: S ll lkSmalltalk

• Developed at Xerox PARC, initially by Alan Kay, later by Adele Goldbergy, y g

• First full implementation of an object-i t d l (d t b t ti oriented language (data abstraction,

inheritance, and dynamic binding)• Pioneered the graphical user interface design

P t d OOP• Promoted OOP

110

Combining Imperative and Object-O i t d P i COriented Programming: C++

D l d t B ll L b b St t i 1980• Developed at Bell Labs by Stroustrup in 1980• Evolved from C and SIMULA 67 • Facilities for object-oriented programming taken partially from 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 OOPRapidly 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 LanguagesRelated OOP Languagesl ( )• Eiffel (designed by Bertrand Meyer - 1992)

– Not directly derived from any other languagey y g g– Smaller and simpler than C++, but still has most

of the powerof the power– Lacked popularity of C++ because many C++

enthusiasts were already C programmersenthusiasts were already C programmers• Delphi (Borland)

– Pascal plus features to support OOP– More elegant and safer than C++g

112

An Imperative-Based Object-Oriented L JLanguage: Java

D l d i h l 1990• Developed at Sun in the early 1990s– C and C++ were not satisfactory for embedded

l t i d i selectronic devices• Based on C++

Si ifi tl i lifi d (d t i l d t t – Significantly simplified (does not include struct, union, enum, pointer arithmetic, and half of the assignment coercions of C++) assignment coercions of C++)

– Supports only OOP– Has references but not pointers– Has references, but not pointers– Includes support for applets and a form of

concurrencyconcurrency113

Java EvaluationJava Evaluation• Eliminated many unsafe features of C++• Supports concurrencypp y• Libraries for applets, GUIs, database access

P bl J Vi l M hi JIT • Portable: Java Virtual Machine concept, JIT compilers

• Widely used for Web programming• Use increased faster than any previous language• Use increased faster than any previous language• Most recent version, 5.0, released in 2004

114

Scripting Languages for the p g g gWeb

P l• Perl– Designed by Larry Wall—first released in 1987

V i bl s st tic ll t p d but implicitl d cl d– Variables are statically typed but implicitly declared– Three distinctive namespaces, denoted by the first

character of a character of a variable’s name

– Powerful, but somewhat dangerous, g– Gained widespread use for CGI programming on the

Web– Also used for a replacement for UNIX system

administration language

115

Scripting Languages for the p g g gWeb

• JavaScript– Began at Netscape, but later became a joint g p , m j

venture of Netscape and Sun MicrosystemsA client side HTML embedded scripting – A client-side HTML-embedded scripting language, often used to create dynamic HTML ddocuments

– Purely interpretedy p– Related to Java only through similar syntax

116

Scripting Languages for the p g g gWeb

• PHP– PHP: Hypertext Preprocessor designed by PHP: Hypertext Preprocessor, designed by

Rasmus Lerdorf– A server-side HTML-embedded scripting

language, often used for form processing g g , p gand database access through the WebP l i t t d– Purely interpreted

117

Scripting Languages for the p g g gWeb

• Python– An OO interpreted scripting languageAn OO interpreted scripting language– Type checked but dynamically typed– Used for CGI programming and form

processingprocessing– Dynamically typed, but type checked– Supports lists, tuples, and hashes

118

Scripting Languages for the p g g gWeb

• Lua– An OO interpreted scripting language– Type checked but dynamically typed– Used for CGI programming and form processingp g g p g– Dynamically typed, but type checked– Supports lists tuples and hashes all with its Supports lists, tuples, and hashes, all with its

single data structure, the tablethe table

– Easily extendable

119

Scripting Languages for the p g g gWeb

• Ruby– Designed in Japan by Yukihiro Matsumoto g p y

(a.k.a, “Matz”)– Began as a replacement for Perl and PythonBegan as a replacement for Perl and Python– A pure object-oriented scripting language

All d t bj t- All data are objects– Most operators are implemented as methods,

which can be redefined by user code– Purely interpretedy p

120

A C-Based Language for the New Mill i C#Millennium: C#

• Part of the .NET development platform (2000)( )

• Based on C++ , Java, and Delphi• Provides a language for component-based

software developmentp• All .NET languages use Common Type System

(CTS) hi h id l lib(CTS), which provides a common class library

121

Markup/Programming Hybrid LanguagesMarkup/Programming Hybrid Languages

• XSLT– eXtensible Markup Language (XML): a eXtensible Markup Language (XML): a

metamarkup language– eXtensible Stylesheet Language

Transformation (XSTL) transforms XML ( )documents for displayP i t t ( l i )– Programming constructs (e.g., looping)

122

Markup/Programming Hybrid LanguagesMarkup/Programming Hybrid Languages

• JSP– Java Server Pages: a collection of technologies g g

to support dynamic Web documents– servlet: a Java program that resides on a Web servlet a Java program that resides on a Web

server and is enacted when called by a requested HTML document; a servlet’s output requested HTML document; a servlet s output is displayed by the browserJSTL includes programming constructs in the – JSTL includes programming constructs in the form of HTML elements

123