10/13/2015assoc. prof. stoyan bonev1 cos220 concepts of pls aubg, cos dept lecture 01 introduction...

144
06/27/22 Assoc. Prof. Stoyan Bonev 1 COS220 Concepts of PLs AUBG, COS dept Lecture 01 Introduction to Concepts of Programming Languages Reference: R.Sebesta, Chapters 1, 2

Upload: cecil-dean

Post on 31-Dec-2015

217 views

Category:

Documents


1 download

TRANSCRIPT

Page 1: 10/13/2015Assoc. Prof. Stoyan Bonev1 COS220 Concepts of PLs AUBG, COS dept Lecture 01 Introduction to Concepts of Programming Languages Reference: R.Sebesta,

04/19/23 Assoc. Prof. Stoyan Bonev 1

COS220 Concepts of PLs AUBG, COS dept

Lecture 01

Introduction to Concepts of Programming

Languages

Reference: R.Sebesta, Chapters 1, 2

Page 2: 10/13/2015Assoc. Prof. Stoyan Bonev1 COS220 Concepts of PLs AUBG, COS dept Lecture 01 Introduction to Concepts of Programming Languages Reference: R.Sebesta,

04/19/23 Assoc. Prof. Stoyan Bonev 2

Reasons to study Concepts of Prog Lan

• Increased capacity to express ideas;• Improved background to choose

appropriate languages;• Increased ability to learn new

languages;• Better understanding the

significance of implementation;• Overall advancement of computing.

Page 3: 10/13/2015Assoc. Prof. Stoyan Bonev1 COS220 Concepts of PLs AUBG, COS dept Lecture 01 Introduction to Concepts of Programming Languages Reference: R.Sebesta,

04/19/23 Assoc. Prof. Stoyan Bonev 3

Lecture Contents:

• Corner stones in software development process

• Programming styles• Evolution of programming languages• Programming domains• Language evaluation criteria• Influence on language design• Software life cycle

Page 4: 10/13/2015Assoc. Prof. Stoyan Bonev1 COS220 Concepts of PLs AUBG, COS dept Lecture 01 Introduction to Concepts of Programming Languages Reference: R.Sebesta,

04/19/23 Assoc. Prof. Stoyan Bonev 4

Corner stones in software development process:

• Development of High Level Languages;

• Introducing the Subroutine Concept;

• Structured Programming and its Evolution to OO Programming;

• Naming Conventions;

• Software Engineering (CASE tools).

Page 5: 10/13/2015Assoc. Prof. Stoyan Bonev1 COS220 Concepts of PLs AUBG, COS dept Lecture 01 Introduction to Concepts of Programming Languages Reference: R.Sebesta,

04/19/23 Assoc. Prof. Stoyan Bonev 5

Corner stones in software development process:

• Development of High Level Languages; – Appeared in late 1950s last century– There exist hundreds of HLL at present

Page 6: 10/13/2015Assoc. Prof. Stoyan Bonev1 COS220 Concepts of PLs AUBG, COS dept Lecture 01 Introduction to Concepts of Programming Languages Reference: R.Sebesta,

04/19/23 Assoc. Prof. Stoyan Bonev 6

Corner stones in software development process:

• Subroutine Concept;

Many reasons to introduce and discuss routines. The most important two follow:

• Using routines results in reducing program size.• Using routines permits the user to apply formal

systematic approach during program design and program implementation process.

Page 7: 10/13/2015Assoc. Prof. Stoyan Bonev1 COS220 Concepts of PLs AUBG, COS dept Lecture 01 Introduction to Concepts of Programming Languages Reference: R.Sebesta,

04/19/23 Assoc. Prof. Stoyan Bonev 7

Corner stones in software development process:

• Structured Programming and its Evolution to OOP;

Bohm and Jacopini introduced and proved the structured theorem in programming.

SequenceSelectionRepetition

E. Dijkstra established principles of structured programming.

Page 8: 10/13/2015Assoc. Prof. Stoyan Bonev1 COS220 Concepts of PLs AUBG, COS dept Lecture 01 Introduction to Concepts of Programming Languages Reference: R.Sebesta,

04/19/23 Assoc. Prof. Stoyan Bonev 8

Structured Programming

• Each computer program may compose using Sequence, Selection and Repetition constructs.

• Each program unit should have one entry point and one exit point.

• SP is known as a “goto-less” programming.– A program that can be read from top to bottom is

much easier to understand than a program that requires the reader to jump from one statement to some nonadjacent statement in order to follow the execution order.

Page 9: 10/13/2015Assoc. Prof. Stoyan Bonev1 COS220 Concepts of PLs AUBG, COS dept Lecture 01 Introduction to Concepts of Programming Languages Reference: R.Sebesta,

04/19/23 Assoc. Prof. Stoyan Bonev 9

Corner stones in software development process:

• Naming Conventions:– Mnemonic Identifiers easily spelled in English– Hungarian Notation – special prefixes– Camel Notation – names begin with a lowercase letter.

Multiword names (“my button”) are written with no spaces and no underscores and with each word after the first capitalized (myButton)

– Pascal Notation – just like Camel notation except that the first letter is also uppercase (MyButton, FileSize, LeftCorner, FreezingPoint).

Page 10: 10/13/2015Assoc. Prof. Stoyan Bonev1 COS220 Concepts of PLs AUBG, COS dept Lecture 01 Introduction to Concepts of Programming Languages Reference: R.Sebesta,

04/19/23 Assoc. Prof. Stoyan Bonev 10

Microsoft suggests:

• Variables be written with Camel notation;• Constants be written with Pascal

notation;• Member variables and methods are named

using Camel notation, while classes are named using Pascal notation.– Reference: Learning Visual Basic .NET by

Jesse Liberty, O’Reilly Publ.

Page 11: 10/13/2015Assoc. Prof. Stoyan Bonev1 COS220 Concepts of PLs AUBG, COS dept Lecture 01 Introduction to Concepts of Programming Languages Reference: R.Sebesta,

04/19/23 Assoc. Prof. Stoyan Bonev 11

Pankaj Jalote: naming conventions

• Package names should be in lower case (mypackage, edu.iitk.maths)

• Type names should be nouns and start with uppercase (Day, DateOfBirth,…)

• Var names should be nouns in lowercase; vars with large scope should have long names; loop iterators should be i, j, k,…

• Const names should be all caps• Method names should be verbs starting with

lower case (e.g. getValue())• Prefix is should be used for boolean methods

Page 12: 10/13/2015Assoc. Prof. Stoyan Bonev1 COS220 Concepts of PLs AUBG, COS dept Lecture 01 Introduction to Concepts of Programming Languages Reference: R.Sebesta,

04/19/23 Assoc. Prof. Stoyan Bonev 12

Corner stones in software development process:

• Software Engineering (CASE tools).

Software development life cycle and importance of the design stage

UML as a formal notational tool in OOA and OOD

Page 13: 10/13/2015Assoc. Prof. Stoyan Bonev1 COS220 Concepts of PLs AUBG, COS dept Lecture 01 Introduction to Concepts of Programming Languages Reference: R.Sebesta,

04/19/23 Assoc. Prof. Stoyan Bonev 13

     Programming styles:

• Procedure oriented (imperative) programming (Visual Basic, C/C++/C#, Java)

ALGORITHMS + DATA STRUCTURES = PROGRAMS

• Logic programming (Prolog – PROgramming in LOGic)

RULES + FACTS = PROGRAMS

• Functional programming (LISP - LISt Programming)

PROGRAMS = FUNCTIONS COMPOSITION

Page 14: 10/13/2015Assoc. Prof. Stoyan Bonev1 COS220 Concepts of PLs AUBG, COS dept Lecture 01 Introduction to Concepts of Programming Languages Reference: R.Sebesta,

04/19/23 Assoc. Prof. Stoyan Bonev 14

Evolution of Prog Lan:

Computer:

• machine language

• assembly language

• high level language

User:

• natural language

Page 15: 10/13/2015Assoc. Prof. Stoyan Bonev1 COS220 Concepts of PLs AUBG, COS dept Lecture 01 Introduction to Concepts of Programming Languages Reference: R.Sebesta,

04/19/23 Assoc. Prof. Stoyan Bonev 15

Language processors and Classification

depending on the source language type: • Translator;

• Assembler;

• Converter.

Page 16: 10/13/2015Assoc. Prof. Stoyan Bonev1 COS220 Concepts of PLs AUBG, COS dept Lecture 01 Introduction to Concepts of Programming Languages Reference: R.Sebesta,

04/19/23 Assoc. Prof. Stoyan Bonev 16

Programming domains – areas of computer

applications and associated languages: • Applications in area of Scientific computing

– Large numbers of floating point computations; use of arrays– Fortran

• Applications in area of Business computing– Produce reports, use decimal numbers and characters– COBOL

• Artificial intelligence– Symbols rather than numbers manipulated; use of linked lists– LISP

• Systems programming– Need efficiency because of continuous use– C

• Web Software– Eclectic collection of languages: markup (e.g., XHTML), scripting (e.g.,

PHP), general-purpose (e.g., Java)

Page 17: 10/13/2015Assoc. Prof. Stoyan Bonev1 COS220 Concepts of PLs AUBG, COS dept Lecture 01 Introduction to Concepts of Programming Languages Reference: R.Sebesta,

04/19/23 Assoc. Prof. Stoyan Bonev 17

Language Categories• Imperative

– Central features are variables, assignment statements, and iteration– Include languages that support object-oriented programming– Include scripting languages– Include the visual languages– Examples: C, Java, Perl, JavaScript, Visual BASIC .NET, C++

• Functional– Main means of making computations is by applying functions to given

parameters– Examples: LISP, Scheme

• Logic– Rule-based (rules are specified in no particular order)– Example: Prolog

• Markup/programming hybrid – Markup languages extended to support some programming– Examples: JSTL, XSLT

Page 18: 10/13/2015Assoc. Prof. Stoyan Bonev1 COS220 Concepts of PLs AUBG, COS dept Lecture 01 Introduction to Concepts of Programming Languages Reference: R.Sebesta,

04/19/23 Assoc. Prof. Stoyan Bonev 18

Language evaluation criteria:

• Readability

• Writability

• Reliability

• Cost

Page 19: 10/13/2015Assoc. Prof. Stoyan Bonev1 COS220 Concepts of PLs AUBG, COS dept Lecture 01 Introduction to Concepts of Programming Languages Reference: R.Sebesta,

04/19/23 Assoc. Prof. Stoyan Bonev 19

Language evaluation criteria:

• Readability: The ease with which programs can be read and understood.

• Writability: Measure of how easily PL can be used to create programs for a chosen problem domain.

• Reliability: A reliable program performs to its specifications under all conditions.

• Cost: Cost is a function of many factors.

Page 20: 10/13/2015Assoc. Prof. Stoyan Bonev1 COS220 Concepts of PLs AUBG, COS dept Lecture 01 Introduction to Concepts of Programming Languages Reference: R.Sebesta,

04/19/23 Assoc. Prof. Stoyan Bonev 20

Evaluation criteria: Readability

• Overall Simplicity

• Orthogonality

• Control Statements

• Data Types and Structures

• Syntax Considerations

Page 21: 10/13/2015Assoc. Prof. Stoyan Bonev1 COS220 Concepts of PLs AUBG, COS dept Lecture 01 Introduction to Concepts of Programming Languages Reference: R.Sebesta,

04/19/23 Assoc. Prof. Stoyan Bonev 21

Evaluation criteria: Readability

• Overall Simplicity– PL that has a large number of basic constructs

is more difficult to learn than PL with smaller number of them

• Feature multiplicity– Having more than one way to accomplish a particular

operation: a=a+1 a+=1 a++ ++a

• Operator overloading– Single operator symbol has more than one meaning

Page 22: 10/13/2015Assoc. Prof. Stoyan Bonev1 COS220 Concepts of PLs AUBG, COS dept Lecture 01 Introduction to Concepts of Programming Languages Reference: R.Sebesta,

04/19/23 Assoc. Prof. Stoyan Bonev 22

Evaluation criteria: Readability

Orthogonality– Orthogonality in PL means that a relatively

small set of primitive constructs may be combined in a relatively small number of ways to build control and data structures of the language

IBM assembler VAX assemblerA reg1,mem-cell ADDL oprnd1,oprnd2AR reg1,reg2

Page 23: 10/13/2015Assoc. Prof. Stoyan Bonev1 COS220 Concepts of PLs AUBG, COS dept Lecture 01 Introduction to Concepts of Programming Languages Reference: R.Sebesta,

04/19/23 Assoc. Prof. Stoyan Bonev 23

Evaluation criteria: Readability

• Control Statements– Lack of control statements makes

writing readable programs very difficult (while loop vs. if, goto statements)

Page 24: 10/13/2015Assoc. Prof. Stoyan Bonev1 COS220 Concepts of PLs AUBG, COS dept Lecture 01 Introduction to Concepts of Programming Languages Reference: R.Sebesta,

04/19/23 Assoc. Prof. Stoyan Bonev 24

Evaluation criteria: Readability

• Data Types and Structures– Presence of facilities for defining abstract

data types makes programs more readable

• timeOut = true is more readable than

• timeOut = 1

Page 25: 10/13/2015Assoc. Prof. Stoyan Bonev1 COS220 Concepts of PLs AUBG, COS dept Lecture 01 Introduction to Concepts of Programming Languages Reference: R.Sebesta,

04/19/23 Assoc. Prof. Stoyan Bonev 25

Evaluation criteria: Readability

• Syntax Considerations– Identifier forms

• Length of at most 2 chars (early BASIC) and 6 chars (early FORTRAN)

– Special words• To use or not keywords as names for

program variables

Page 26: 10/13/2015Assoc. Prof. Stoyan Bonev1 COS220 Concepts of PLs AUBG, COS dept Lecture 01 Introduction to Concepts of Programming Languages Reference: R.Sebesta,

04/19/23 Assoc. Prof. Stoyan Bonev 26

Evaluation criteria: Readability

• Example:

if then then then = else; else else = then;

To clarify the record above key words are underlined

if then then then = else; else else = then;

Page 27: 10/13/2015Assoc. Prof. Stoyan Bonev1 COS220 Concepts of PLs AUBG, COS dept Lecture 01 Introduction to Concepts of Programming Languages Reference: R.Sebesta,

04/19/23 Assoc. Prof. Stoyan Bonev 27

Evaluation criteria: Writability

• Simplicity • Orthogonality• Support for Abstraction• Expressivity

Page 28: 10/13/2015Assoc. Prof. Stoyan Bonev1 COS220 Concepts of PLs AUBG, COS dept Lecture 01 Introduction to Concepts of Programming Languages Reference: R.Sebesta,

04/19/23 Assoc. Prof. Stoyan Bonev 28

Evaluation criteria: Writability

• Simplicity• Orthogonality

Same criteria as Readability

Page 29: 10/13/2015Assoc. Prof. Stoyan Bonev1 COS220 Concepts of PLs AUBG, COS dept Lecture 01 Introduction to Concepts of Programming Languages Reference: R.Sebesta,

04/19/23 Assoc. Prof. Stoyan Bonev 29

Evaluation criteria: Writability

• Support for Abstraction– Ability to define and then use complicated

structures in ways that allow to ignore details.• Process abstraction• Data abstraction

Page 30: 10/13/2015Assoc. Prof. Stoyan Bonev1 COS220 Concepts of PLs AUBG, COS dept Lecture 01 Introduction to Concepts of Programming Languages Reference: R.Sebesta,

04/19/23 Assoc. Prof. Stoyan Bonev 30

Evaluation criteria: Writability

• Expressivity

– Count++ is more expressive than Count+=1

– Statement for is more expressive than while statement using counter controlled loops

Page 31: 10/13/2015Assoc. Prof. Stoyan Bonev1 COS220 Concepts of PLs AUBG, COS dept Lecture 01 Introduction to Concepts of Programming Languages Reference: R.Sebesta,

04/19/23 Assoc. Prof. Stoyan Bonev 31

Evaluation criteria: Reliability

• Type Checking

• Exception Handling

• Aliasing

• Readability and Writability

Page 32: 10/13/2015Assoc. Prof. Stoyan Bonev1 COS220 Concepts of PLs AUBG, COS dept Lecture 01 Introduction to Concepts of Programming Languages Reference: R.Sebesta,

04/19/23 Assoc. Prof. Stoyan Bonev 32

Evaluation criteria: Reliability

• Type Checking– Simply testing for type errors. (Type checker)

• Exception Handling– Ability to intercept run-time errors, take corrective

measures and continue execution

• Aliasing– Two or more reference methods or names for same

memory cell. Dangerous and confusing feature

• Readability and Writability

Page 33: 10/13/2015Assoc. Prof. Stoyan Bonev1 COS220 Concepts of PLs AUBG, COS dept Lecture 01 Introduction to Concepts of Programming Languages Reference: R.Sebesta,

04/19/23 Assoc. Prof. Stoyan Bonev 33

Evaluation criteria: Cost• Cost of training programmers to use the language• Cost of writing programs in the language• Cost of compiling programs in the language• Cost of executing programs written in the language• Cost of language implementation system• Cost of poor reliability• Cost of maintaining programs which includes

corrections and modifications to add new capabilities.

Page 34: 10/13/2015Assoc. Prof. Stoyan Bonev1 COS220 Concepts of PLs AUBG, COS dept Lecture 01 Introduction to Concepts of Programming Languages Reference: R.Sebesta,

04/19/23 Assoc. Prof. Stoyan Bonev 34

More PL evaluation criteria: • Portability

– The ease with which programs can be moved from one environment to another

• Generality– The applicability to a wide range of

applications

• Well-definedness– Completeness and precision of the language’s

official defining document

Page 35: 10/13/2015Assoc. Prof. Stoyan Bonev1 COS220 Concepts of PLs AUBG, COS dept Lecture 01 Introduction to Concepts of Programming Languages Reference: R.Sebesta,

04/19/23 Assoc. Prof. Stoyan Bonev 35

Influence on language design:

Computer Architecture:

Programming Methodologies:

Page 36: 10/13/2015Assoc. Prof. Stoyan Bonev1 COS220 Concepts of PLs AUBG, COS dept Lecture 01 Introduction to Concepts of Programming Languages Reference: R.Sebesta,

04/19/23 Assoc. Prof. Stoyan Bonev 36

Influence on language design:

Computer architecture: • von Neumann architecture: memory, CPU• Execution of a machine code program on a von

Neumann architecture computer occurs in a process called fetch-execute cycle. Programs reside in memory but are executed in the CPU. Each instruction to be executed must be moved from memory to the processor. The address of the next instruction to be executed is maintained in a register called Program Counter (PC) or Instruction Pointer (IP).

Page 37: 10/13/2015Assoc. Prof. Stoyan Bonev1 COS220 Concepts of PLs AUBG, COS dept Lecture 01 Introduction to Concepts of Programming Languages Reference: R.Sebesta,

04/19/23 Assoc. Prof. Stoyan Bonev 37

Computer Architecture Influence

• Well-known computer architecture: Von Neumann • Imperative languages, most dominant, because of

von Neumann computers– Data and programs stored in memory– Memory is separate from CPU– Instructions and data are piped from memory to CPU– Basis for imperative languages

• Variables model memory cells• Assignment statements model piping• Iteration is efficient

Page 38: 10/13/2015Assoc. Prof. Stoyan Bonev1 COS220 Concepts of PLs AUBG, COS dept Lecture 01 Introduction to Concepts of Programming Languages Reference: R.Sebesta,

04/19/23 Assoc. Prof. Stoyan Bonev 38

Copyright © 2009 Addison-Wesley. All rights reserved. 1-38

The von Neumann Architecture

Page 39: 10/13/2015Assoc. Prof. Stoyan Bonev1 COS220 Concepts of PLs AUBG, COS dept Lecture 01 Introduction to Concepts of Programming Languages Reference: R.Sebesta,

04/19/23 Assoc. Prof. Stoyan Bonev 39

The von Neumann Architecture

• Fetch-execute-cycle (on a von Neumann architecture computer)initialize the program counter

repeat forever

fetch the instruction pointed by the program counter

increment the program counter

decode the instruction

execute the instruction

end repeat

Page 40: 10/13/2015Assoc. Prof. Stoyan Bonev1 COS220 Concepts of PLs AUBG, COS dept Lecture 01 Introduction to Concepts of Programming Languages Reference: R.Sebesta,

04/19/23 Assoc. Prof. Stoyan Bonev 40

algorithm of the FETCH-EXECUTE cycle

• Initialize program counter PC(IP)

• Repeat forever– Fetch the instruction pointed by PC– Increment the PC to point next instruction– Decode the instruction– Execute the instruction

• End repeat

Page 41: 10/13/2015Assoc. Prof. Stoyan Bonev1 COS220 Concepts of PLs AUBG, COS dept Lecture 01 Introduction to Concepts of Programming Languages Reference: R.Sebesta,

04/19/23 Assoc. Prof. Stoyan Bonev 41

Influence on language design:

Programming Methodologies:• 1960s: simply solving sets of equations …• 1970s: top-down design, stepwise

refinement or structured programming• Late 1970s: shift from procedure-oriented

to data-oriented program design • Early 1980s: latest step in the evolution of

data-oriented SD is OOA/D and OOP.

Page 42: 10/13/2015Assoc. Prof. Stoyan Bonev1 COS220 Concepts of PLs AUBG, COS dept Lecture 01 Introduction to Concepts of Programming Languages Reference: R.Sebesta,

Software Development Method

or

Software Life Cycle

Page 43: 10/13/2015Assoc. Prof. Stoyan Bonev1 COS220 Concepts of PLs AUBG, COS dept Lecture 01 Introduction to Concepts of Programming Languages Reference: R.Sebesta,

04/19/23 Assoc. Prof. Stoyan Bonev 43

SDM /SLC/:

• Version 1:

• Specify the problem requirements; • Analyze the problem; • Design the algorithm to solve the problem; • Implement the algorithm; • Test and verify the completed program; • Maintain and update the program.

Page 44: 10/13/2015Assoc. Prof. Stoyan Bonev1 COS220 Concepts of PLs AUBG, COS dept Lecture 01 Introduction to Concepts of Programming Languages Reference: R.Sebesta,

04/19/23 Assoc. Prof. Stoyan Bonev 44

SDM /SLC/:

• Version 2:

• Systems Analysis;

• Systems Design;

• Systems Implementation;

• Systems Support.

Page 45: 10/13/2015Assoc. Prof. Stoyan Bonev1 COS220 Concepts of PLs AUBG, COS dept Lecture 01 Introduction to Concepts of Programming Languages Reference: R.Sebesta,

04/19/23 Assoc. Prof. Stoyan Bonev 45

SDM /SLC/:

• Version 3:

• Analyze;

• Design;

• Choose interface;

• Code;

• Test & debug;

• Complete documentation

Page 46: 10/13/2015Assoc. Prof. Stoyan Bonev1 COS220 Concepts of PLs AUBG, COS dept Lecture 01 Introduction to Concepts of Programming Languages Reference: R.Sebesta,

04/19/23 Assoc. Prof. Stoyan Bonev 46

Simplified SDM /SLC/:

• Version 4:

• Decide what the application will do and how it will interact with the user.

• Design the application’s user interface according to requirements of step 1.

• Write the actual code behind the events you want to handle.

Page 47: 10/13/2015Assoc. Prof. Stoyan Bonev1 COS220 Concepts of PLs AUBG, COS dept Lecture 01 Introduction to Concepts of Programming Languages Reference: R.Sebesta,

ISBN 0-321-49362-1

Chapter 1

Preliminaries

Page 48: 10/13/2015Assoc. Prof. Stoyan Bonev1 COS220 Concepts of PLs AUBG, COS dept Lecture 01 Introduction to Concepts of Programming Languages Reference: R.Sebesta,

Copyright © 2009 Addison-Wesley. All rights reserved. 1-48Copyright © 2009 Addison-Wesley. All rights reserved. 1-48

Chapter 1 Topics

• Reasons for Studying Concepts of Programming Languages

• Programming Domains• Language Evaluation Criteria• Influences on Language Design• Language Categories• Language Design Trade-Offs• Implementation Methods• Programming Environments

Page 49: 10/13/2015Assoc. Prof. Stoyan Bonev1 COS220 Concepts of PLs AUBG, COS dept Lecture 01 Introduction to Concepts of Programming Languages Reference: R.Sebesta,

Copyright © 2009 Addison-Wesley. All rights reserved. 1-49Copyright © 2009 Addison-Wesley. All rights reserved. 1-49

Reasons for Studying Concepts of Programming Languages

• Increased ability to express ideas• Improved background for choosing

appropriate languages• Increased ability to learn new languages• Better understanding of significance of

implementation• Better use of languages that are already

known• Overall advancement of computing

Page 50: 10/13/2015Assoc. Prof. Stoyan Bonev1 COS220 Concepts of PLs AUBG, COS dept Lecture 01 Introduction to Concepts of Programming Languages Reference: R.Sebesta,

Copyright © 2009 Addison-Wesley. All rights reserved. 1-50Copyright © 2009 Addison-Wesley. All rights reserved. 1-50

Programming Domains

• Scientific applications– Large numbers of floating point computations; use of arrays– Fortran

• Business applications– Produce reports, use decimal numbers and characters– COBOL

• Artificial intelligence– Symbols rather than numbers manipulated; use of linked

lists– LISP

• Systems programming– Need efficiency because of continuous use– C

• Web Software– Eclectic collection of languages: markup (e.g., XHTML),

scripting (e.g., PHP), general-purpose (e.g., Java)

Page 51: 10/13/2015Assoc. Prof. Stoyan Bonev1 COS220 Concepts of PLs AUBG, COS dept Lecture 01 Introduction to Concepts of Programming Languages Reference: R.Sebesta,

Copyright © 2009 Addison-Wesley. All rights reserved. 1-51Copyright © 2009 Addison-Wesley. All rights reserved. 1-51

Language Evaluation Criteria

• Readability: the ease with which programs can be read and understood

• Writability: the ease with which a language can be used to create programs

• Reliability: conformance to specifications (i.e., performs to its specifications)

• Cost: the ultimate total cost

Page 52: 10/13/2015Assoc. Prof. Stoyan Bonev1 COS220 Concepts of PLs AUBG, COS dept Lecture 01 Introduction to Concepts of Programming Languages Reference: R.Sebesta,

Copyright © 2009 Addison-Wesley. All rights reserved. 1-52Copyright © 2009 Addison-Wesley. All rights reserved. 1-52

Evaluation Criteria: Readability• Overall simplicity

– A manageable set of features and constructs– Minimal feature multiplicity – Minimal operator overloading

• Orthogonality – A relatively small set of primitive constructs can be combined in a

relatively small number of ways– Every possible combination is legal

• Data types– Adequate predefined data types

• Syntax considerations– Identifier forms: flexible composition – Special words and methods of forming compound statements– Form and meaning: self-descriptive constructs, meaningful keywords

Page 53: 10/13/2015Assoc. Prof. Stoyan Bonev1 COS220 Concepts of PLs AUBG, COS dept Lecture 01 Introduction to Concepts of Programming Languages Reference: R.Sebesta,

Copyright © 2009 Addison-Wesley. All rights reserved. 1-53Copyright © 2009 Addison-Wesley. All rights reserved. 1-53

Evaluation Criteria: Writability

• Simplicity and orthogonality– Few constructs, a small number of primitives, a small set of

rules for combining them

• Support for abstraction– The ability to define and use complex structures or

operations in ways that allow details to be ignored

• Expressivity– A set of relatively convenient ways of specifying operations– Strength and number of operators and predefined

functions

Page 54: 10/13/2015Assoc. Prof. Stoyan Bonev1 COS220 Concepts of PLs AUBG, COS dept Lecture 01 Introduction to Concepts of Programming Languages Reference: R.Sebesta,

Copyright © 2009 Addison-Wesley. All rights reserved. 1-54Copyright © 2009 Addison-Wesley. All rights reserved. 1-54

Evaluation Criteria: Reliability

• Type checking– Testing for type errors

• Exception handling– Intercept run-time errors and take corrective measures

• Aliasing– Presence of two or more distinct referencing methods for the

same memory location

• Readability and writability– A language that does not support “natural” ways of expressing

an algorithm will require the use of “unnatural” approaches, and hence reduced reliability

Page 55: 10/13/2015Assoc. Prof. Stoyan Bonev1 COS220 Concepts of PLs AUBG, COS dept Lecture 01 Introduction to Concepts of Programming Languages Reference: R.Sebesta,

Copyright © 2009 Addison-Wesley. All rights reserved. 1-55Copyright © 2009 Addison-Wesley. All rights reserved. 1-55

Evaluation Criteria: Cost

• Training programmers to use the language

• Writing programs (closeness to particular applications)

• Compiling programs• Executing programs• Language implementation system:

availability of free compilers• Reliability: poor reliability leads to high

costs• Maintaining programs

Page 56: 10/13/2015Assoc. Prof. Stoyan Bonev1 COS220 Concepts of PLs AUBG, COS dept Lecture 01 Introduction to Concepts of Programming Languages Reference: R.Sebesta,

Copyright © 2009 Addison-Wesley. All rights reserved. 1-56Copyright © 2009 Addison-Wesley. All rights reserved. 1-56

Evaluation Criteria: Others

• Portability– The ease with which programs can be moved

from one implementation to another

• Generality– The applicability to a wide range of

applications

• Well-definedness– The completeness and precision of the

language’s official definition

Page 57: 10/13/2015Assoc. Prof. Stoyan Bonev1 COS220 Concepts of PLs AUBG, COS dept Lecture 01 Introduction to Concepts of Programming Languages Reference: R.Sebesta,

Copyright © 2009 Addison-Wesley. All rights reserved. 1-57Copyright © 2009 Addison-Wesley. All rights reserved. 1-57

Influences on Language Design

• Computer Architecture– Languages are developed around the

prevalent computer architecture, known as the von Neumann architecture

• Programming Methodologies– New software development methodologies

(e.g., object-oriented software development) led to new programming paradigms and by extension, new programming languages

Page 58: 10/13/2015Assoc. Prof. Stoyan Bonev1 COS220 Concepts of PLs AUBG, COS dept Lecture 01 Introduction to Concepts of Programming Languages Reference: R.Sebesta,

Copyright © 2009 Addison-Wesley. All rights reserved. 1-58Copyright © 2009 Addison-Wesley. All rights reserved. 1-58

Computer Architecture Influence

• Well-known computer architecture: Von Neumann • Imperative languages, most dominant, because

of von Neumann computers– Data and programs stored in memory– Memory is separate from CPU– Instructions and data are piped from memory to CPU– Basis for imperative languages

• Variables model memory cells• Assignment statements model piping• Iteration is efficient

Page 59: 10/13/2015Assoc. Prof. Stoyan Bonev1 COS220 Concepts of PLs AUBG, COS dept Lecture 01 Introduction to Concepts of Programming Languages Reference: R.Sebesta,

Copyright © 2009 Addison-Wesley. All rights reserved. 1-59Copyright © 2009 Addison-Wesley. All rights reserved. 1-59

The von Neumann Architecture

Page 60: 10/13/2015Assoc. Prof. Stoyan Bonev1 COS220 Concepts of PLs AUBG, COS dept Lecture 01 Introduction to Concepts of Programming Languages Reference: R.Sebesta,

Copyright © 2009 Addison-Wesley. All rights reserved. 1-60Copyright © 2009 Addison-Wesley. All rights reserved. 1-60

The von Neumann Architecture

• Fetch-execute-cycle (on a von Neumann architecture computer)

initialize the program counter

repeat forever

fetch the instruction pointed by the counter

increment the counter

decode the instruction

execute the instruction

end repeat

Page 61: 10/13/2015Assoc. Prof. Stoyan Bonev1 COS220 Concepts of PLs AUBG, COS dept Lecture 01 Introduction to Concepts of Programming Languages Reference: R.Sebesta,

Copyright © 2009 Addison-Wesley. All rights reserved. 1-61Copyright © 2009 Addison-Wesley. All rights reserved. 1-61

Programming Methodologies Influences• 1950s and early 1960s: Simple applications;

worry about machine efficiency• Late 1960s: People efficiency became important;

readability, better control structures– structured programming– top-down design and step-wise refinement

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

• Middle 1980s: Object-oriented programming– Data abstraction + inheritance + polymorphism

Page 62: 10/13/2015Assoc. Prof. Stoyan Bonev1 COS220 Concepts of PLs AUBG, COS dept Lecture 01 Introduction to Concepts of Programming Languages Reference: R.Sebesta,

Copyright © 2009 Addison-Wesley. All rights reserved. 1-62Copyright © 2009 Addison-Wesley. All rights reserved. 1-62

Language Categories

• Imperative– Central features are variables, assignment statements, and

iteration– Include languages that support object-oriented programming– Include scripting languages– Include the visual languages– Examples: C, Java, Perl, JavaScript, Visual BASIC .NET, C++

• Functional– Main means of making computations is by applying functions

to given parameters– Examples: LISP, Scheme

• Logic– Rule-based (rules are specified in no particular order)– Example: Prolog

• Markup/programming hybrid – Markup languages extended to support some programming– Examples: JSTL, XSLT

Page 63: 10/13/2015Assoc. Prof. Stoyan Bonev1 COS220 Concepts of PLs AUBG, COS dept Lecture 01 Introduction to Concepts of Programming Languages Reference: R.Sebesta,

Copyright © 2009 Addison-Wesley. All rights reserved. 1-63Copyright © 2009 Addison-Wesley. All rights reserved. 1-63

Language Design Trade-Offs

• Reliability vs. cost of execution– Example: Java demands all references to array elements

be checked for proper indexing, which leads to increased execution costs

• Readability vs. writabilityExample: APL provides many powerful operators (and a

large number of new symbols), allowing complex computations to be written in a compact program but at the cost of poor readability

• Writability (flexibility) vs. reliability– Example: C++ pointers are powerful and very flexible

but are unreliable

Page 64: 10/13/2015Assoc. Prof. Stoyan Bonev1 COS220 Concepts of PLs AUBG, COS dept Lecture 01 Introduction to Concepts of Programming Languages Reference: R.Sebesta,

Copyright © 2009 Addison-Wesley. All rights reserved. 1-64Copyright © 2009 Addison-Wesley. All rights reserved. 1-64

Implementation Methods

• Compilation– Programs are translated into machine language

• Pure Interpretation– Programs are interpreted by another program known as

an interpreter

• Hybrid Implementation Systems– A compromise between compilers and pure interpreters

Page 65: 10/13/2015Assoc. Prof. Stoyan Bonev1 COS220 Concepts of PLs AUBG, COS dept Lecture 01 Introduction to Concepts of Programming Languages Reference: R.Sebesta,

Copyright © 2009 Addison-Wesley. All rights reserved. 1-65Copyright © 2009 Addison-Wesley. All rights reserved. 1-65

Layered View of Computer

The operating system and language implementation are layered over machine interface of a computer

Page 66: 10/13/2015Assoc. Prof. Stoyan Bonev1 COS220 Concepts of PLs AUBG, COS dept Lecture 01 Introduction to Concepts of Programming Languages Reference: R.Sebesta,

Copyright © 2009 Addison-Wesley. All rights reserved. 1-66Copyright © 2009 Addison-Wesley. All rights reserved. 1-66

Compilation

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

• Slow translation, fast execution• Compilation process has several phases:

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

– 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

Page 67: 10/13/2015Assoc. Prof. Stoyan Bonev1 COS220 Concepts of PLs AUBG, COS dept Lecture 01 Introduction to Concepts of Programming Languages Reference: R.Sebesta,

Copyright © 2009 Addison-Wesley. All rights reserved. 1-67Copyright © 2009 Addison-Wesley. All rights reserved. 1-67

The Compilation Process

Page 68: 10/13/2015Assoc. Prof. Stoyan Bonev1 COS220 Concepts of PLs AUBG, COS dept Lecture 01 Introduction to Concepts of Programming Languages Reference: R.Sebesta,

Copyright © 2009 Addison-Wesley. All rights reserved. 1-68Copyright © 2009 Addison-Wesley. All rights reserved. 1-68

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

Page 69: 10/13/2015Assoc. Prof. Stoyan Bonev1 COS220 Concepts of PLs AUBG, COS dept Lecture 01 Introduction to Concepts of Programming Languages Reference: R.Sebesta,

Copyright © 2009 Addison-Wesley. All rights reserved. 1-69Copyright © 2009 Addison-Wesley. All rights reserved. 1-69

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

Page 70: 10/13/2015Assoc. Prof. Stoyan Bonev1 COS220 Concepts of PLs AUBG, COS dept Lecture 01 Introduction to Concepts of Programming Languages Reference: R.Sebesta,

Copyright © 2009 Addison-Wesley. All rights reserved. 1-70Copyright © 2009 Addison-Wesley. All rights reserved. 1-70

Pure Interpretation

• No translation• Easier implementation of programs (run-time

errors can easily and immediately be displayed)• Slower execution (10 to 100 times slower than

compiled programs)• Often requires more space• Now rare for traditional high-level languages• Significant comeback with some Web scripting

languages (e.g., JavaScript, PHP)

Page 71: 10/13/2015Assoc. Prof. Stoyan Bonev1 COS220 Concepts of PLs AUBG, COS dept Lecture 01 Introduction to Concepts of Programming Languages Reference: R.Sebesta,

Copyright © 2009 Addison-Wesley. All rights reserved. 1-71Copyright © 2009 Addison-Wesley. All rights reserved. 1-71

Pure Interpretation Process

Page 72: 10/13/2015Assoc. Prof. Stoyan Bonev1 COS220 Concepts of PLs AUBG, COS dept Lecture 01 Introduction to Concepts of Programming Languages Reference: R.Sebesta,

Copyright © 2009 Addison-Wesley. All rights reserved. 1-72Copyright © 2009 Addison-Wesley. All rights reserved. 1-72

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• Examples

– Perl programs are partially compiled to detect errors before interpretation

– Initial implementations of Java were hybrid; the intermediate form, byte code, provides portability to any machine that has a byte code interpreter and a run-time system (together, these are called Java Virtual Machine)

Page 73: 10/13/2015Assoc. Prof. Stoyan Bonev1 COS220 Concepts of PLs AUBG, COS dept Lecture 01 Introduction to Concepts of Programming Languages Reference: R.Sebesta,

Copyright © 2009 Addison-Wesley. All rights reserved. 1-73Copyright © 2009 Addison-Wesley. All rights reserved. 1-73

Hybrid Implementation Process

Page 74: 10/13/2015Assoc. Prof. Stoyan Bonev1 COS220 Concepts of PLs AUBG, COS dept Lecture 01 Introduction to Concepts of Programming Languages Reference: R.Sebesta,

Copyright © 2009 Addison-Wesley. All rights reserved. 1-74Copyright © 2009 Addison-Wesley. All rights reserved. 1-74

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

Page 75: 10/13/2015Assoc. Prof. Stoyan Bonev1 COS220 Concepts of PLs AUBG, COS dept Lecture 01 Introduction to Concepts of Programming Languages Reference: R.Sebesta,

Copyright © 2009 Addison-Wesley. All rights reserved. 1-75Copyright © 2009 Addison-Wesley. All rights reserved. 1-75

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

Page 76: 10/13/2015Assoc. Prof. Stoyan Bonev1 COS220 Concepts of PLs AUBG, COS dept Lecture 01 Introduction to Concepts of Programming Languages Reference: R.Sebesta,

Copyright © 2009 Addison-Wesley. All rights reserved. 1-76Copyright © 2009 Addison-Wesley. All rights reserved. 1-76

Programming Environments

• A collection of tools used in software development

• UNIX– An older operating system and tool collection– Nowadays often used through a GUI (e.g., CDE, KDE, or

GNOME) that runs on top of UNIX

• Microsoft Visual Studio.NET– A large, complex visual environment

• Used to build Web applications and non-Web applications in any .NET language

• NetBeans– Related to Visual Studio .NET, except for Web

applications in Java

Page 77: 10/13/2015Assoc. Prof. Stoyan Bonev1 COS220 Concepts of PLs AUBG, COS dept Lecture 01 Introduction to Concepts of Programming Languages Reference: R.Sebesta,

Copyright © 2009 Addison-Wesley. All rights reserved. 1-77Copyright © 2009 Addison-Wesley. All rights reserved. 1-77

Summary

• The study of programming languages is valuable for a number of reasons:– Increase our capacity to use different constructs– Enable us to choose languages more intelligently– Makes learning new languages easier

• Most important criteria for evaluating programming languages include:– Readability, writability, reliability, cost

• Major influences on language design have been machine architecture and software development methodologies

• The major methods of implementing programming languages are: compilation, pure interpretation, and hybrid implementation

Page 78: 10/13/2015Assoc. Prof. Stoyan Bonev1 COS220 Concepts of PLs AUBG, COS dept Lecture 01 Introduction to Concepts of Programming Languages Reference: R.Sebesta,

ISBN 0-321-49362-11-78Copyright © 2009 Addison-Wesley. All rights reserved.

Chapter 2

Evolution of the Major Programming Languages

Page 79: 10/13/2015Assoc. Prof. Stoyan Bonev1 COS220 Concepts of PLs AUBG, COS dept Lecture 01 Introduction to Concepts of Programming Languages Reference: R.Sebesta,

Copyright © 2009 Addison-Wesley. All rights reserved. 1-79Copyright © 2009 Addison-Wesley. All rights reserved. 1-79

Chapter 2 Topics

• Zuse’s Plankalkül• Minimal Hardware Programming:

Pseudocodes• The IBM 704 and Fortran• Functional Programming: LISP• The First Step Toward Sophistication:

ALGOL 60• Computerizing Business Records: COBOL• The Beginnings of Timesharing: BASIC

Page 80: 10/13/2015Assoc. Prof. Stoyan Bonev1 COS220 Concepts of PLs AUBG, COS dept Lecture 01 Introduction to Concepts of Programming Languages Reference: R.Sebesta,

Copyright © 2009 Addison-Wesley. All rights reserved. 1-80Copyright © 2009 Addison-Wesley. All rights reserved. 1-80

Chapter 2 Topics (continued)

• Everything for Everybody: PL/I• Two Early Dynamic Languages: APL and

SNOBOL• The Beginnings of Data Abstraction:

SIMULA 67• Orthogonal Design: ALGOL 68• Some Early Descendants of the ALGOLs• Programming Based on Logic: Prolog• History's Largest Design Effort: Ada

Page 81: 10/13/2015Assoc. Prof. Stoyan Bonev1 COS220 Concepts of PLs AUBG, COS dept Lecture 01 Introduction to Concepts of Programming Languages Reference: R.Sebesta,

Copyright © 2009 Addison-Wesley. All rights reserved. 1-81Copyright © 2009 Addison-Wesley. All rights reserved. 1-81

Chapter 2 Topics (continued)

• Object-Oriented Programming: Smalltalk• Combining Imperative ad Object-

Oriented Features: C++• An Imperative-Based Object-Oriented

Language: Java• Scripting Languages• A C-Based Language for the New

Millennium: C#• Markup/Programming Hybrid Languages

Page 82: 10/13/2015Assoc. Prof. Stoyan Bonev1 COS220 Concepts of PLs AUBG, COS dept Lecture 01 Introduction to Concepts of Programming Languages Reference: R.Sebesta,

Copyright © 2009 Addison-Wesley. All rights reserved. 1-82Copyright © 2009 Addison-Wesley. All rights reserved. 1-82

Genealogy of Common Languages

Page 83: 10/13/2015Assoc. Prof. Stoyan Bonev1 COS220 Concepts of PLs AUBG, COS dept Lecture 01 Introduction to Concepts of Programming Languages Reference: R.Sebesta,

Copyright © 2009 Addison-Wesley. All rights reserved. 1-83Copyright © 2009 Addison-Wesley. All rights reserved. 1-83

Zuse’s Plankalkül

• Designed in 1945, but not published until 1972

• Never implemented• Advanced data structures

– floating point, arrays, records

• Invariants

Page 84: 10/13/2015Assoc. Prof. Stoyan Bonev1 COS220 Concepts of PLs AUBG, COS dept Lecture 01 Introduction to Concepts of Programming Languages Reference: R.Sebesta,

Copyright © 2009 Addison-Wesley. All rights reserved. 1-84Copyright © 2009 Addison-Wesley. All rights reserved. 1-84

Plankalkül Syntax

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

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

types)

Page 85: 10/13/2015Assoc. Prof. Stoyan Bonev1 COS220 Concepts of PLs AUBG, COS dept Lecture 01 Introduction to Concepts of Programming Languages Reference: R.Sebesta,

Copyright © 2009 Addison-Wesley. All rights reserved. 1-85Copyright © 2009 Addison-Wesley. All rights reserved. 1-85

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

Page 86: 10/13/2015Assoc. Prof. Stoyan Bonev1 COS220 Concepts of PLs AUBG, COS dept Lecture 01 Introduction to Concepts of Programming Languages Reference: R.Sebesta,

Copyright © 2009 Addison-Wesley. All rights reserved. 1-86Copyright © 2009 Addison-Wesley. All rights reserved. 1-86

Pseudocodes: Short Code

• Short Code developed by Mauchly in 1949 for BINAC computers – Expressions were coded, left to right– Example of operations:

01 – 06 abs value 1n (n+2)nd power 02 ) 07 + 2n (n+2)nd root

03 = 08 pause 4n if <= n

04 / 09 ( 58 print and tab

Page 87: 10/13/2015Assoc. Prof. Stoyan Bonev1 COS220 Concepts of PLs AUBG, COS dept Lecture 01 Introduction to Concepts of Programming Languages Reference: R.Sebesta,

Copyright © 2009 Addison-Wesley. All rights reserved. 1-87Copyright © 2009 Addison-Wesley. All rights reserved. 1-87

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

Page 88: 10/13/2015Assoc. Prof. Stoyan Bonev1 COS220 Concepts of PLs AUBG, COS dept Lecture 01 Introduction to Concepts of Programming Languages Reference: R.Sebesta,

Copyright © 2009 Addison-Wesley. All rights reserved. 1-88Copyright © 2009 Addison-Wesley. All rights reserved. 1-88

Pseudocodes: Related Systems

• The UNIVAC Compiling System– Developed by a team led by Grace Hopper– Pseudocode expanded into machine code

• David J. Wheeler (Cambridge University) – developed a method of using blocks of re-

locatable addresses to solve the problem of absolute addressing

Page 89: 10/13/2015Assoc. Prof. Stoyan Bonev1 COS220 Concepts of PLs AUBG, COS dept Lecture 01 Introduction to Concepts of Programming Languages Reference: R.Sebesta,

Copyright © 2009 Addison-Wesley. All rights reserved. 1-89Copyright © 2009 Addison-Wesley. All rights reserved. 1-89

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 (no floating-point software)

– Environment of development• Computers were small and unreliable• Applications were scientific• No programming methodology or tools• Machine efficiency was the most important concern

Page 90: 10/13/2015Assoc. Prof. Stoyan Bonev1 COS220 Concepts of PLs AUBG, COS dept Lecture 01 Introduction to Concepts of Programming Languages Reference: R.Sebesta,

Copyright © 2009 Addison-Wesley. All rights reserved. 1-90Copyright © 2009 Addison-Wesley. All rights reserved. 1-90

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)

Page 91: 10/13/2015Assoc. Prof. Stoyan Bonev1 COS220 Concepts of PLs AUBG, COS dept Lecture 01 Introduction to Concepts of Programming Languages Reference: R.Sebesta,

Copyright © 2009 Addison-Wesley. All rights reserved. 1-91Copyright © 2009 Addison-Wesley. All rights reserved. 1-91

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

Page 92: 10/13/2015Assoc. Prof. Stoyan Bonev1 COS220 Concepts of PLs AUBG, COS dept Lecture 01 Introduction to Concepts of Programming Languages Reference: R.Sebesta,

Copyright © 2009 Addison-Wesley. All rights reserved. 1-92Copyright © 2009 Addison-Wesley. All rights reserved. 1-92

Fortran I Overview (continued)

• 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

Page 93: 10/13/2015Assoc. Prof. Stoyan Bonev1 COS220 Concepts of PLs AUBG, COS dept Lecture 01 Introduction to Concepts of Programming Languages Reference: R.Sebesta,

Copyright © 2009 Addison-Wesley. All rights reserved. 1-93Copyright © 2009 Addison-Wesley. All rights reserved. 1-93

Fortran II

• Distributed in 1958– Independent compilation– Fixed the bugs

Page 94: 10/13/2015Assoc. Prof. Stoyan Bonev1 COS220 Concepts of PLs AUBG, COS dept Lecture 01 Introduction to Concepts of Programming Languages Reference: R.Sebesta,

Copyright © 2009 Addison-Wesley. All rights reserved. 1-94Copyright © 2009 Addison-Wesley. All rights reserved. 1-94

Fortran IV

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

Page 95: 10/13/2015Assoc. Prof. Stoyan Bonev1 COS220 Concepts of PLs AUBG, COS dept Lecture 01 Introduction to Concepts of Programming Languages Reference: R.Sebesta,

Copyright © 2009 Addison-Wesley. All rights reserved. 1-95Copyright © 2009 Addison-Wesley. All rights reserved. 1-95

Fortran 77

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

Page 96: 10/13/2015Assoc. Prof. Stoyan Bonev1 COS220 Concepts of PLs AUBG, COS dept Lecture 01 Introduction to Concepts of Programming Languages Reference: R.Sebesta,

Copyright © 2009 Addison-Wesley. All rights reserved. 1-96Copyright © 2009 Addison-Wesley. All rights reserved. 1-96

Fortran 90

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

Page 97: 10/13/2015Assoc. Prof. Stoyan Bonev1 COS220 Concepts of PLs AUBG, COS dept Lecture 01 Introduction to Concepts of Programming Languages Reference: R.Sebesta,

Copyright © 2009 Addison-Wesley. All rights reserved. 1-97Copyright © 2009 Addison-Wesley. All rights reserved. 1-97

Latest versions of Fortran

• Fortran 95 – relatively minor additions, plus some deletions

• Fortran 2003 - ditto

Page 98: 10/13/2015Assoc. Prof. Stoyan Bonev1 COS220 Concepts of PLs AUBG, COS dept Lecture 01 Introduction to Concepts of Programming Languages Reference: R.Sebesta,

Copyright © 2009 Addison-Wesley. All rights reserved. 1-98Copyright © 2009 Addison-Wesley. All rights reserved. 1-98

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

Page 99: 10/13/2015Assoc. Prof. Stoyan Bonev1 COS220 Concepts of PLs AUBG, COS dept Lecture 01 Introduction to Concepts of Programming Languages Reference: R.Sebesta,

Copyright © 2009 Addison-Wesley. All rights reserved. 1-99Copyright © 2009 Addison-Wesley. All rights reserved. 1-99

Functional Programming: LISP

• LISt Processing language– Designed at MIT by McCarthy

• 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

Page 100: 10/13/2015Assoc. Prof. Stoyan Bonev1 COS220 Concepts of PLs AUBG, COS dept Lecture 01 Introduction to Concepts of Programming Languages Reference: R.Sebesta,

Copyright © 2009 Addison-Wesley. All rights reserved. 1-100Copyright © 2009 Addison-Wesley. All rights reserved. 1-100

Representation of Two LISP Lists

Representing the lists (A B C D)and (A (B C) D (E (F G)))

Page 101: 10/13/2015Assoc. Prof. Stoyan Bonev1 COS220 Concepts of PLs AUBG, COS dept Lecture 01 Introduction to Concepts of Programming Languages Reference: R.Sebesta,

Copyright © 2009 Addison-Wesley. All rights reserved. 1-101Copyright © 2009 Addison-Wesley. All rights reserved. 1-101

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

Page 102: 10/13/2015Assoc. Prof. Stoyan Bonev1 COS220 Concepts of PLs AUBG, COS dept Lecture 01 Introduction to Concepts of Programming Languages Reference: R.Sebesta,

Copyright © 2009 Addison-Wesley. All rights reserved. 1-102Copyright © 2009 Addison-Wesley. All rights reserved. 1-102

Scheme

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

ideal for educational applications

Page 103: 10/13/2015Assoc. Prof. Stoyan Bonev1 COS220 Concepts of PLs AUBG, COS dept Lecture 01 Introduction to Concepts of Programming Languages Reference: R.Sebesta,

Copyright © 2009 Addison-Wesley. All rights reserved. 1-103Copyright © 2009 Addison-Wesley. All rights reserved. 1-103

COMMON LISP

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

• Large, complex

Page 104: 10/13/2015Assoc. Prof. Stoyan Bonev1 COS220 Concepts of PLs AUBG, COS dept Lecture 01 Introduction to Concepts of Programming Languages Reference: R.Sebesta,

Copyright © 2009 Addison-Wesley. All rights reserved. 1-104Copyright © 2009 Addison-Wesley. All rights reserved. 1-104

The First Step Toward Sophistication: ALGOL 60

• 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

algorithms

• ALGOL 60 was the result of efforts to design a universal language

Page 105: 10/13/2015Assoc. Prof. Stoyan Bonev1 COS220 Concepts of PLs AUBG, COS dept Lecture 01 Introduction to Concepts of Programming Languages Reference: R.Sebesta,

Copyright © 2009 Addison-Wesley. All rights reserved. 1-105Copyright © 2009 Addison-Wesley. All rights reserved. 1-105

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

Page 106: 10/13/2015Assoc. Prof. Stoyan Bonev1 COS220 Concepts of PLs AUBG, COS dept Lecture 01 Introduction to Concepts of Programming Languages Reference: R.Sebesta,

Copyright © 2009 Addison-Wesley. All rights reserved. 1-106Copyright © 2009 Addison-Wesley. All rights reserved. 1-106

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”

Page 107: 10/13/2015Assoc. Prof. Stoyan Bonev1 COS220 Concepts of PLs AUBG, COS dept Lecture 01 Introduction to Concepts of Programming Languages Reference: R.Sebesta,

Copyright © 2009 Addison-Wesley. All rights reserved. 1-107Copyright © 2009 Addison-Wesley. All rights reserved. 1-107

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

Page 108: 10/13/2015Assoc. Prof. Stoyan Bonev1 COS220 Concepts of PLs AUBG, COS dept Lecture 01 Introduction to Concepts of Programming Languages Reference: R.Sebesta,

Copyright © 2009 Addison-Wesley. All rights reserved. 1-108Copyright © 2009 Addison-Wesley. All rights reserved. 1-108

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

Page 109: 10/13/2015Assoc. Prof. Stoyan Bonev1 COS220 Concepts of PLs AUBG, COS dept Lecture 01 Introduction to Concepts of Programming Languages Reference: R.Sebesta,

Copyright © 2009 Addison-Wesley. All rights reserved. 1-109Copyright © 2009 Addison-Wesley. All rights reserved. 1-109

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)

Page 110: 10/13/2015Assoc. Prof. Stoyan Bonev1 COS220 Concepts of PLs AUBG, COS dept Lecture 01 Introduction to Concepts of Programming Languages Reference: R.Sebesta,

Copyright © 2009 Addison-Wesley. All rights reserved. 1-110Copyright © 2009 Addison-Wesley. All rights reserved. 1-110

ALGOL 60 Evaluation (continued)

• 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

Page 111: 10/13/2015Assoc. Prof. Stoyan Bonev1 COS220 Concepts of PLs AUBG, COS dept Lecture 01 Introduction to Concepts of Programming Languages Reference: R.Sebesta,

Copyright © 2009 Addison-Wesley. All rights reserved. 1-111Copyright © 2009 Addison-Wesley. All rights reserved. 1-111

Computerizing Business Records: COBOL

• Environment of development– UNIVAC was beginning to use FLOW-MATIC– USAF was beginning to use AIMACO– IBM was developing COMTRAN

Page 112: 10/13/2015Assoc. Prof. Stoyan Bonev1 COS220 Concepts of PLs AUBG, COS dept Lecture 01 Introduction to Concepts of Programming Languages Reference: R.Sebesta,

Copyright © 2009 Addison-Wesley. All rights reserved. 1-112Copyright © 2009 Addison-Wesley. All rights reserved. 1-112

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

Page 113: 10/13/2015Assoc. Prof. Stoyan Bonev1 COS220 Concepts of PLs AUBG, COS dept Lecture 01 Introduction to Concepts of Programming Languages Reference: R.Sebesta,

Copyright © 2009 Addison-Wesley. All rights reserved. 1-113Copyright © 2009 Addison-Wesley. All rights reserved. 1-113

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 DoD branches

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

Page 114: 10/13/2015Assoc. Prof. Stoyan Bonev1 COS220 Concepts of PLs AUBG, COS dept Lecture 01 Introduction to Concepts of Programming Languages Reference: R.Sebesta,

Copyright © 2009 Addison-Wesley. All rights reserved. 1-114Copyright © 2009 Addison-Wesley. All rights reserved. 1-114

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

Page 115: 10/13/2015Assoc. Prof. Stoyan Bonev1 COS220 Concepts of PLs AUBG, COS dept Lecture 01 Introduction to Concepts of Programming Languages Reference: R.Sebesta,

Copyright © 2009 Addison-Wesley. All rights reserved. 1-115Copyright © 2009 Addison-Wesley. All rights reserved. 1-115

COBOL: DoD Influence

• First language required by DoD– would have failed without DoD

• Still the most widely used business applications language

Page 116: 10/13/2015Assoc. Prof. Stoyan Bonev1 COS220 Concepts of PLs AUBG, COS dept Lecture 01 Introduction to Concepts of Programming Languages Reference: R.Sebesta,

Copyright © 2009 Addison-Wesley. All rights reserved. 1-116Copyright © 2009 Addison-Wesley. All rights reserved. 1-116

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

Page 117: 10/13/2015Assoc. Prof. Stoyan Bonev1 COS220 Concepts of PLs AUBG, COS dept Lecture 01 Introduction to Concepts of Programming Languages Reference: R.Sebesta,

Copyright © 2009 Addison-Wesley. All rights reserved. 1-117Copyright © 2009 Addison-Wesley. All rights reserved. 1-117

2.8 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

Page 118: 10/13/2015Assoc. Prof. Stoyan Bonev1 COS220 Concepts of PLs AUBG, COS dept Lecture 01 Introduction to Concepts of Programming Languages Reference: R.Sebesta,

Copyright © 2009 Addison-Wesley. All rights reserved. 1-118Copyright © 2009 Addison-Wesley. All rights reserved. 1-118

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

Page 119: 10/13/2015Assoc. Prof. Stoyan Bonev1 COS220 Concepts of PLs AUBG, COS dept Lecture 01 Introduction to Concepts of Programming Languages Reference: R.Sebesta,

Copyright © 2009 Addison-Wesley. All rights reserved. 1-119Copyright © 2009 Addison-Wesley. All rights reserved. 1-119

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

Page 120: 10/13/2015Assoc. Prof. Stoyan Bonev1 COS220 Concepts of PLs AUBG, COS dept Lecture 01 Introduction to Concepts of Programming Languages Reference: R.Sebesta,

Copyright © 2009 Addison-Wesley. All rights reserved. 1-120Copyright © 2009 Addison-Wesley. All rights reserved. 1-120

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

Page 121: 10/13/2015Assoc. Prof. Stoyan Bonev1 COS220 Concepts of PLs AUBG, COS dept Lecture 01 Introduction to Concepts of Programming Languages Reference: R.Sebesta,

Copyright © 2009 Addison-Wesley. All rights reserved. 1-121Copyright © 2009 Addison-Wesley. All rights reserved. 1-121

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

Page 122: 10/13/2015Assoc. Prof. Stoyan Bonev1 COS220 Concepts of PLs AUBG, COS dept Lecture 01 Introduction to Concepts of Programming Languages Reference: R.Sebesta,

Copyright © 2009 Addison-Wesley. All rights reserved. 1-122Copyright © 2009 Addison-Wesley. All rights reserved. 1-122

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

Page 123: 10/13/2015Assoc. Prof. Stoyan Bonev1 COS220 Concepts of PLs AUBG, COS dept Lecture 01 Introduction to Concepts of Programming Languages Reference: R.Sebesta,

Copyright © 2009 Addison-Wesley. All rights reserved. 1-123Copyright © 2009 Addison-Wesley. All rights reserved. 1-123

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

Page 124: 10/13/2015Assoc. Prof. Stoyan Bonev1 COS220 Concepts of PLs AUBG, COS dept Lecture 01 Introduction to Concepts of Programming Languages Reference: R.Sebesta,

Copyright © 2009 Addison-Wesley. All rights reserved. 1-124Copyright © 2009 Addison-Wesley. All rights reserved. 1-124

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

Page 125: 10/13/2015Assoc. Prof. Stoyan Bonev1 COS220 Concepts of PLs AUBG, COS dept Lecture 01 Introduction to Concepts of Programming Languages Reference: R.Sebesta,

Copyright © 2009 Addison-Wesley. All rights reserved. 1-125Copyright © 2009 Addison-Wesley. All rights reserved. 1-125

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

Page 126: 10/13/2015Assoc. Prof. Stoyan Bonev1 COS220 Concepts of PLs AUBG, COS dept Lecture 01 Introduction to Concepts of Programming Languages Reference: R.Sebesta,

Copyright © 2009 Addison-Wesley. All rights reserved. 1-126Copyright © 2009 Addison-Wesley. All rights reserved. 1-126

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

Page 127: 10/13/2015Assoc. Prof. Stoyan Bonev1 COS220 Concepts of PLs AUBG, COS dept Lecture 01 Introduction to Concepts of Programming Languages Reference: R.Sebesta,

Copyright © 2009 Addison-Wesley. All rights reserved. 1-127Copyright © 2009 Addison-Wesley. All rights reserved. 1-127

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-1970s until the late 1990s, it was

the most widely used language for teaching programming

Page 128: 10/13/2015Assoc. Prof. Stoyan Bonev1 COS220 Concepts of PLs AUBG, COS dept Lecture 01 Introduction to Concepts of Programming Languages Reference: R.Sebesta,

Copyright © 2009 Addison-Wesley. All rights reserved. 1-128Copyright © 2009 Addison-Wesley. All rights reserved. 1-128

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

Page 129: 10/13/2015Assoc. Prof. Stoyan Bonev1 COS220 Concepts of PLs AUBG, COS dept Lecture 01 Introduction to Concepts of Programming Languages Reference: R.Sebesta,

Copyright © 2009 Addison-Wesley. All rights reserved. 1-129Copyright © 2009 Addison-Wesley. All rights reserved. 1-129

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

Page 130: 10/13/2015Assoc. Prof. Stoyan Bonev1 COS220 Concepts of PLs AUBG, COS dept Lecture 01 Introduction to Concepts of Programming Languages Reference: R.Sebesta,

Copyright © 2009 Addison-Wesley. All rights reserved. 1-130Copyright © 2009 Addison-Wesley. All rights reserved. 1-130

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

Page 131: 10/13/2015Assoc. Prof. Stoyan Bonev1 COS220 Concepts of PLs AUBG, COS dept Lecture 01 Introduction to Concepts of Programming Languages Reference: R.Sebesta,

Copyright © 2009 Addison-Wesley. All rights reserved. 1-131Copyright © 2009 Addison-Wesley. All rights reserved. 1-131

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

Page 132: 10/13/2015Assoc. Prof. Stoyan Bonev1 COS220 Concepts of PLs AUBG, COS dept Lecture 01 Introduction to Concepts of Programming Languages Reference: R.Sebesta,

Copyright © 2009 Addison-Wesley. All rights reserved. 1-132Copyright © 2009 Addison-Wesley. All rights reserved. 1-132

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 DoD no longer requires its use but also because of popularity of C++

Page 133: 10/13/2015Assoc. Prof. Stoyan Bonev1 COS220 Concepts of PLs AUBG, COS dept Lecture 01 Introduction to Concepts of Programming Languages Reference: R.Sebesta,

Copyright © 2009 Addison-Wesley. All rights reserved. 1-133Copyright © 2009 Addison-Wesley. All rights reserved. 1-133

Object-Oriented Programming: Smalltalk

• Developed at Xerox PARC, initially by Alan Kay, later by Adele Goldberg

• First full implementation of an object-oriented language (data abstraction, inheritance, and dynamic binding)

• Pioneered the graphical user interface design

• Promoted OOP

Page 134: 10/13/2015Assoc. Prof. Stoyan Bonev1 COS220 Concepts of PLs AUBG, COS dept Lecture 01 Introduction to Concepts of Programming Languages Reference: R.Sebesta,

Copyright © 2009 Addison-Wesley. All rights reserved. 1-134Copyright © 2009 Addison-Wesley. All rights reserved. 1-134

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

Page 135: 10/13/2015Assoc. Prof. Stoyan Bonev1 COS220 Concepts of PLs AUBG, COS dept Lecture 01 Introduction to Concepts of Programming Languages Reference: R.Sebesta,

Copyright © 2009 Addison-Wesley. All rights reserved. 1-135Copyright © 2009 Addison-Wesley. All rights reserved. 1-135

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++

Page 136: 10/13/2015Assoc. Prof. Stoyan Bonev1 COS220 Concepts of PLs AUBG, COS dept Lecture 01 Introduction to Concepts of Programming Languages Reference: R.Sebesta,

Copyright © 2009 Addison-Wesley. All rights reserved. 1-136Copyright © 2009 Addison-Wesley. All rights reserved. 1-136

An Imperative-Based Object-Oriented Language: Java

• Developed at Sun in the early 1990s– 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

Page 137: 10/13/2015Assoc. Prof. Stoyan Bonev1 COS220 Concepts of PLs AUBG, COS dept Lecture 01 Introduction to Concepts of Programming Languages Reference: R.Sebesta,

Copyright © 2009 Addison-Wesley. All rights reserved. 1-137Copyright © 2009 Addison-Wesley. All rights reserved. 1-137

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

Page 138: 10/13/2015Assoc. Prof. Stoyan Bonev1 COS220 Concepts of PLs AUBG, COS dept Lecture 01 Introduction to Concepts of Programming Languages Reference: R.Sebesta,

Copyright © 2009 Addison-Wesley. All rights reserved. 1-138Copyright © 2009 Addison-Wesley. All rights reserved. 1-138

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

• JavaScript– 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

• PHP– PHP: Hypertext Preprocessor, designed by Rasmus Lerdorf– A server-side HTML-embedded scripting language, often used for form

processing and database access through the Web– Purely interpreted

Page 139: 10/13/2015Assoc. Prof. Stoyan Bonev1 COS220 Concepts of PLs AUBG, COS dept Lecture 01 Introduction to Concepts of Programming Languages Reference: R.Sebesta,

Copyright © 2009 Addison-Wesley. All rights reserved. 1-139

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

• 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

Copyright © 2009 Addison-Wesley. All rights reserved. 1-139

Page 140: 10/13/2015Assoc. Prof. Stoyan Bonev1 COS220 Concepts of PLs AUBG, COS dept Lecture 01 Introduction to Concepts of Programming Languages Reference: R.Sebesta,

Copyright © 2009 Addison-Wesley. All rights reserved. 1-140Copyright © 2009 Addison-Wesley. All rights reserved. 1-140

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

Page 141: 10/13/2015Assoc. Prof. Stoyan Bonev1 COS220 Concepts of PLs AUBG, COS dept Lecture 01 Introduction to Concepts of Programming Languages Reference: R.Sebesta,

Copyright © 2009 Addison-Wesley. All rights reserved. 1-141Copyright © 2009 Addison-Wesley. All rights reserved. 1-141

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

Page 142: 10/13/2015Assoc. Prof. Stoyan Bonev1 COS220 Concepts of PLs AUBG, COS dept Lecture 01 Introduction to Concepts of Programming Languages Reference: R.Sebesta,

Copyright © 2009 Addison-Wesley. All rights reserved. 1-142Copyright © 2009 Addison-Wesley. All rights reserved. 1-142

Markup/Programming Hybrid Languages

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

language– eXtensible Stylesheet Language Transformation (XSTL)

transforms XML documents for display– Programming constructs (e.g., looping)

• 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

Page 143: 10/13/2015Assoc. Prof. Stoyan Bonev1 COS220 Concepts of PLs AUBG, COS dept Lecture 01 Introduction to Concepts of Programming Languages Reference: R.Sebesta,

Copyright © 2009 Addison-Wesley. All rights reserved. 1-143Copyright © 2009 Addison-Wesley. All rights reserved. 1-143

Summary

• Development, development environment, and evaluation of a number of important programming languages

• Perspective into current issues in language design

Page 144: 10/13/2015Assoc. Prof. Stoyan Bonev1 COS220 Concepts of PLs AUBG, COS dept Lecture 01 Introduction to Concepts of Programming Languages Reference: R.Sebesta,

Thank Youfor

Your attention