history of programming languageswilliams.comp.ncat.edu/comp360/history.pdfcommon business-oriented...

43
History of Programming Languages COMP360

Upload: others

Post on 09-Oct-2020

2 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: History of Programming Languageswilliams.comp.ncat.edu/COMP360/History.pdfCommon Business-Oriented Language - Cobol •Designed in 1959 for the Department of Defense (DoD) •Grace

History ofProgramming Languages

COMP360

Page 2: History of Programming Languageswilliams.comp.ncat.edu/COMP360/History.pdfCommon Business-Oriented Language - Cobol •Designed in 1959 for the Department of Defense (DoD) •Grace

“If you don't know history, then you don't know anything. You are a leaf that doesn't know it is part of a tree.”

Michael Crichton

Page 3: History of Programming Languageswilliams.comp.ncat.edu/COMP360/History.pdfCommon Business-Oriented Language - Cobol •Designed in 1959 for the Department of Defense (DoD) •Grace

Some attributes of a good programming language

•Clarity – You can write the algorithm as you envision it in the application domain

•Readability – Someone reading a program will understand what it does

• Intuitiveness – It works the way you expect

• Scalability – The ability to write large or small programs in the language

Page 4: History of Programming Languageswilliams.comp.ncat.edu/COMP360/History.pdfCommon Business-Oriented Language - Cobol •Designed in 1959 for the Department of Defense (DoD) •Grace

More Attributes

• Safety – The language minimizes the chance to make subtle errors

• Efficiency – Programs written in the language execute fast and efficiently

• Large library – Many functions are available

• Support for abstraction – Allows encapsulating concepts

• Security – Creates programs that are less vulnerable

Page 5: History of Programming Languageswilliams.comp.ncat.edu/COMP360/History.pdfCommon Business-Oriented Language - Cobol •Designed in 1959 for the Department of Defense (DoD) •Grace

More Important Than You Would Think Attributes

•Compilation speed – It is advantageous if a program will compile quickly, particularly for student programs

• Fits the media – Cobol and Fortran were designed for punched cards

Page 6: History of Programming Languageswilliams.comp.ncat.edu/COMP360/History.pdfCommon Business-Oriented Language - Cobol •Designed in 1959 for the Department of Defense (DoD) •Grace

Charles Babbage

Charles Babbage built a mechanical computer starting in 1822. He never completed the machine.

Page 7: History of Programming Languageswilliams.comp.ncat.edu/COMP360/History.pdfCommon Business-Oriented Language - Cobol •Designed in 1959 for the Department of Defense (DoD) •Grace

Ada Lovelace

Augusta Ada, Countess of Lovelace, was the daughter of Lord Byron and friend of Charles Babbage

She is considered the first computer programmer

Page 8: History of Programming Languageswilliams.comp.ncat.edu/COMP360/History.pdfCommon Business-Oriented Language - Cobol •Designed in 1959 for the Department of Defense (DoD) •Grace

Analog Computers

• For many years electrical engineers have used mathematics to model circuits

• If you want to solve a mathematical equation, you can wire a circuit whose solution is the equation

•Analog computers are not digital, they represent a number by the voltage on a wire

• There is no programming language for an analog computer

Page 9: History of Programming Languageswilliams.comp.ncat.edu/COMP360/History.pdfCommon Business-Oriented Language - Cobol •Designed in 1959 for the Department of Defense (DoD) •Grace

ENIAC

• Electronic Numerical Integrator And Computer

• John Eckert and J. Presper Mauchly

• University of Pennsylvania

• Trajectory tables for weapons

• Started 1943

• Finished 1946

– Too late for war effort

• Used until 1955

Page 10: History of Programming Languageswilliams.comp.ncat.edu/COMP360/History.pdfCommon Business-Oriented Language - Cobol •Designed in 1959 for the Department of Defense (DoD) •Grace

ENIAC - details

• Programmed manually by switches and wiring

• Decimal (not binary)

• 20 registers of 10 digits

• 18,000 vacuum tubes

• 30 tons

• 15,000 square feet

• 140 KW power

• 5,000 additions/sec

Page 11: History of Programming Languageswilliams.comp.ncat.edu/COMP360/History.pdfCommon Business-Oriented Language - Cobol •Designed in 1959 for the Department of Defense (DoD) •Grace

von Neumann Architecture

• Stored Program concept

• Main memory holds programs and data

• ALU operating on binary data

• Control unit interpreting instructions from memory

and executing

• Input and output equipment operated by control unit

• Completed 1952

Page 12: History of Programming Languageswilliams.comp.ncat.edu/COMP360/History.pdfCommon Business-Oriented Language - Cobol •Designed in 1959 for the Department of Defense (DoD) •Grace

Machine Language

•Computers execute machine language

•All other computer languages are translated to machine language for execution by a compiler

•Machine language is binary and very tedious to use

•Machine language is unique to each architecture

Page 13: History of Programming Languageswilliams.comp.ncat.edu/COMP360/History.pdfCommon Business-Oriented Language - Cobol •Designed in 1959 for the Department of Defense (DoD) •Grace

Machine Language Format for Imaginary Computer

1 2 3 4 5 6 7 8 9

1

0

1

1

1

2

1

3

1

4

1

5

1

6

1

7

1

8

1

9

2

0

2

1

2

2

2

3

2

4

2

5

2

6

2

7

2

8

2

9

3

0

3

1

3

2

1 0 0 0 0 0 1 0 1 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0

0 1 0 0 0 0 1 0 0 0 0 1 0 1 1 0 0 1 1 0 1 0 0 1 0 1 0 0 0 0 0 0

1 0 1 0 1 0 1 0 1 1 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1

Add Subtract Multiply Divide Load Store JumpEql Jump

0 1 2 3 4 5 6 7

opcode register index

register

memory address

3 4 4 21

opcode unused reg 1 reg 2 reg 3

3 1 4 4 4

Load and Store

Add, Sub, Mult and Divide

Opcodes

Instruction Formats

Page 14: History of Programming Languageswilliams.comp.ncat.edu/COMP360/History.pdfCommon Business-Oriented Language - Cobol •Designed in 1959 for the Department of Defense (DoD) •Grace

Sample Instruction

1 2 3 4 5 6 7 8 9

1

0

1

1

1

2

1

3

1

4

1

5

1

6

1

7

1

8

1

9

2

0

2

1

2

2

2

3

2

4

2

5

2

6

2

7

2

8

2

9

3

0

3

1

3

2

1 0 0 0 0 0 1 0 1 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0

Add Subtract Multiply Divide Load Store JumpEql Jump

0 1 2 3 4 5 6 7

opcode register index

register

memory address

3 4 4 21

opcode unused reg 1 reg 2 reg 3

3 1 4 4 4

Load and Store

Add, Sub, Mult and Divide

Opcodes

Instruction Formats

Opcode 100 = 4 = Load instructionRegister 0001 = R1Index 0110 = R6Address 0001000 = 8

Load R1, 8[R6]

Page 15: History of Programming Languageswilliams.comp.ncat.edu/COMP360/History.pdfCommon Business-Oriented Language - Cobol •Designed in 1959 for the Department of Defense (DoD) •Grace

Program to calculate a square root

better = number;

do {

good = better;

better = (better + number/ better) / 2;

}while (good!= better);

Page 16: History of Programming Languageswilliams.comp.ncat.edu/COMP360/History.pdfCommon Business-Oriented Language - Cobol •Designed in 1959 for the Department of Defense (DoD) •Grace

Assembled Codeaddr machine assembler

004a 8b 45 e0 mov eax, number

004d 89 45 f8 mov good, eax

0050 89 45 ec mov better, eax

0053 8b 45 ec mov eax, better

again:

0056 89 45 f8 mov good, eax

0059 8b 45 e0 mov eax, number

005c ba 00 00 00 00 mov edx, 0

0061 f7 7d f8 idiv good

0064 03 45 f8 add eax, good

0067 d1 f8 sar eax, 1

0069 89 45 ec mov better, eax

006c 3b 45 f8 cmp eax, good

006f 75 e2 jne SHORT again

Page 17: History of Programming Languageswilliams.comp.ncat.edu/COMP360/History.pdfCommon Business-Oriented Language - Cobol •Designed in 1959 for the Department of Defense (DoD) •Grace

Assembly language

•Assembly language is a simplified means of writing machine language

•Addresses are represented by names

•Opcodes are represented by mnemonics

• Each line of assembly language generally creates one machine language instruction

Page 18: History of Programming Languageswilliams.comp.ncat.edu/COMP360/History.pdfCommon Business-Oriented Language - Cobol •Designed in 1959 for the Department of Defense (DoD) •Grace

Assemblers

•An assembler is a program that translates assembly language to machine language

• It converts the mnemonics to the proper numerical opcode

• The assembler calculates all of the numerical addresses

•Assemblers read one line at a time and create the machine language for that assembler statement

•Assemblers have existed since the dawn of computing

Page 19: History of Programming Languageswilliams.comp.ncat.edu/COMP360/History.pdfCommon Business-Oriented Language - Cobol •Designed in 1959 for the Department of Defense (DoD) •Grace

Forward and Backward References

•Consider the following simple assembler program

bkwd mov eax, forwd // move forwd to eax

add eax, 5 // add 5 to eax

jmp bkwd // jump to bkwd

forwd DW 47 // data word

•When the assembler reads the first line, it does not know the address for forwd

•When it gets to the third line, it knows the address of bkwd

Page 20: History of Programming Languageswilliams.comp.ncat.edu/COMP360/History.pdfCommon Business-Oriented Language - Cobol •Designed in 1959 for the Department of Defense (DoD) •Grace

Two Pass Assembler

•A two pass assembler reads the assembler source code and calculates addresses

• It creates a symbol table that has all of the program names, such as bkwd and forwd, and their address

• It then reads the source a second time and generates the output using the symbol table to get addresses

• The assembler needs only enough data space to hold the symbol table

Page 21: History of Programming Languageswilliams.comp.ncat.edu/COMP360/History.pdfCommon Business-Oriented Language - Cobol •Designed in 1959 for the Department of Defense (DoD) •Grace

One Pass Assembler

• If you can fit the generated machine code in memory, only one pass over the assembler source is needed

•When a forward reference is found, the location where the address is needed is kept in the symbol table

•When the symbol is found, its value is placed in the needed locations

Page 22: History of Programming Languageswilliams.comp.ncat.edu/COMP360/History.pdfCommon Business-Oriented Language - Cobol •Designed in 1959 for the Department of Defense (DoD) •Grace

Assembler Macros

•Many assemblers have a macro feature that allows the program to define new assembler source code statements

swap define macro

mov eax, $1

mov ebx, $2

mov $2, eax

mov $1, ebx

end macro

swap dog, cat

generates:mov eax, dogmov ebx, catmov cat, eaxmov dog, ebx

Page 23: History of Programming Languageswilliams.comp.ncat.edu/COMP360/History.pdfCommon Business-Oriented Language - Cobol •Designed in 1959 for the Department of Defense (DoD) •Grace

First Compiler

• Alick Glennie developed Autocodein 1952

• It ran on the Manchester Mark 1

• The Manchester Mark 1 was a prototype for the Ferranti Mark 1, the world's first commercially available general-purpose electronic computer in 1951

Page 24: History of Programming Languageswilliams.comp.ncat.edu/COMP360/History.pdfCommon Business-Oriented Language - Cobol •Designed in 1959 for the Department of Defense (DoD) •Grace

Autocode Example

• Calculates 𝑓 𝑡 = |𝑡| + 5𝑡3

INTEGERS +5 →c # Put 5 into c→t # Load argument from lower accumulator to variable t

+t TESTA Z # Put |t| into lower accumulator-t

ENTRY Z

SUBROUTINE 6 →z # Run square root subroutine on lower accumulator# value and put the result into z

+tt →y →x # Calculate t^3 and put it into x +tx →y →x

+z+cx CLOSE WRITE 1 # Put z + (c * x) into lower accumulator and return

example from Wikipedia

Page 25: History of Programming Languageswilliams.comp.ncat.edu/COMP360/History.pdfCommon Business-Oriented Language - Cobol •Designed in 1959 for the Department of Defense (DoD) •Grace

Speedcoding

• The first high-level programming languagecreated for an IBM computer

•Created by John Backus in 1953

•Goal was to express the program in a natural language

• Speedcoding programs often ran 10x to 20x slower than hand coded assembler programs

Page 26: History of Programming Languageswilliams.comp.ncat.edu/COMP360/History.pdfCommon Business-Oriented Language - Cobol •Designed in 1959 for the Department of Defense (DoD) •Grace

FLOW-MATIC

• The first English-like data processing language

•Developed for the UNIVAC I at Remington Rand under Grace Hopper from 1955 to 1959

•Data structures were defined by filling in pre-printed forms

from Wikipedia

Page 27: History of Programming Languageswilliams.comp.ncat.edu/COMP360/History.pdfCommon Business-Oriented Language - Cobol •Designed in 1959 for the Department of Defense (DoD) •Grace

Sample FLOW-MATIC Program

(0) INPUT INVENTORY FILE-A PRICE FILE-B ; OUTPUT PRICED-INV FILE-C UNPRICED-INV FILE-D ; HSP D .

(1) COMPARE PRODUCT-NO (A) WITH PRODUCT-NO (B) ; IF GREATER GO TO OPERATION 10 ; IF EQUAL GO TO OPERATION 5 ; OTHERWISE GO TO OPERATION 2 .

(2) TRANSFER A TO D .

(3) WRITE-ITEM D .

(4) JUMP TO OPERATION 8 .

(5) TRANSFER A TO C .

(6) MOVE UNIT-PRICE (B) TO UNIT-PRICE (C) .

(7) WRITE-ITEM C .

(15) REWIND B .example from Wikipedia

Page 28: History of Programming Languageswilliams.comp.ncat.edu/COMP360/History.pdfCommon Business-Oriented Language - Cobol •Designed in 1959 for the Department of Defense (DoD) •Grace

chart from Wikipedia

Page 29: History of Programming Languageswilliams.comp.ncat.edu/COMP360/History.pdfCommon Business-Oriented Language - Cobol •Designed in 1959 for the Department of Defense (DoD) •Grace

Formula Translating System - Fortran

•Created at IBM by John Backus in 1957

• It reduced the number of programming statements necessary by a factor of 20

• Still in use, primarily for high performance computing

Page 30: History of Programming Languageswilliams.comp.ncat.edu/COMP360/History.pdfCommon Business-Oriented Language - Cobol •Designed in 1959 for the Department of Defense (DoD) •Grace

Fortran Facts• Spaces were ignored and could be added or removed•INABOX and IN A BOX are the same variable

• Lines could be given a number23 IF (DOG .EQ. CAT) GOTO 47

•Variables that began with the letters I through N were INTEGER and all others were REAL unless declared otherwise• Supports complex numbers•Arrays start at one• Exponentiation in equations: CAT**3 is CAT3

•Officially prohibited recursion

Page 31: History of Programming Languageswilliams.comp.ncat.edu/COMP360/History.pdfCommon Business-Oriented Language - Cobol •Designed in 1959 for the Department of Defense (DoD) •Grace

Many Fortran Versions

• Fortran has evolved over the years

• If statement formats

IF (CAT – DOG) 34, 789, 46

IF (CAT .EQ. DOG) GO TO 789

IF (CAT .EQ. DOG) THEN … ELSE … END IF

Page 32: History of Programming Languageswilliams.comp.ncat.edu/COMP360/History.pdfCommon Business-Oriented Language - Cobol •Designed in 1959 for the Department of Defense (DoD) •Grace

How good is Fortran?

•Clarity – Allows you to write equations and engineering algorithms

•Readability – Generally OK, although the jumps make for spaghetti code

• Intuitiveness – It generally works the way you expect

• Scalability – Some very large computationally intensive programs are written in Fortran

Page 33: History of Programming Languageswilliams.comp.ncat.edu/COMP360/History.pdfCommon Business-Oriented Language - Cobol •Designed in 1959 for the Department of Defense (DoD) •Grace

More Fortran Attributes

• Safety – Does not check for subtle errors or security

• Efficiency – Fortran’s simple memory model and no pointers allows compilers to create efficient code

• Large library – Many math functions are available

• Support for abstraction – Does not provide for objects or other types of abstraction

Page 34: History of Programming Languageswilliams.comp.ncat.edu/COMP360/History.pdfCommon Business-Oriented Language - Cobol •Designed in 1959 for the Department of Defense (DoD) •Grace

Common Business-Oriented Language - Cobol

•Designed in 1959 for the Department of Defense (DoD)

•Grace Hopper is commonly referred to as“the (grand)mother of COBOL”

• Intended to create a portable programminglanguage for data processing

• Still in use

•When she recommended that a newprogramming language be developed using English words, she “was told very quicklythat [she] couldn't do this becausecomputers didn't understand English.”

Page 35: History of Programming Languageswilliams.comp.ncat.edu/COMP360/History.pdfCommon Business-Oriented Language - Cobol •Designed in 1959 for the Department of Defense (DoD) •Grace

Hello World in CobolIDENTIFICATION DIVISION.

PROGRAM-ID. 'HELLO'.

ENVIRONMENT DIVISION.

CONFIGURATION SECTION.

SOURCE-COMPUTER. GNULINUX.

OBJECT-COMPUTER. HERCULES.

SPECIAL-NAMES.

CONSOLE IS CONSL.

DATA DIVISION.

PROCEDURE DIVISION.

00-MAIN.

DISPLAY 'HELLO, WORLD' UPON CONSL.

STOP RUN.

Page 36: History of Programming Languageswilliams.comp.ncat.edu/COMP360/History.pdfCommon Business-Oriented Language - Cobol •Designed in 1959 for the Department of Defense (DoD) •Grace

Cobol Considerations

• Excessively verbose

cat = dog + 1; Java or C++

add one to dog giving cat. Cobol

•No local variables

•Good support for record data types

• Sorting is a built-in language feature

Page 37: History of Programming Languageswilliams.comp.ncat.edu/COMP360/History.pdfCommon Business-Oriented Language - Cobol •Designed in 1959 for the Department of Defense (DoD) •Grace

How good is Cobol?

•Clarity – Designed to look like English.

•Readability – Can be read to some extent by anon-programmer

• Intuitiveness – Easier for non-programmers than professional programmers

• Scalability – There are no methods. Everything is one big program

Page 38: History of Programming Languageswilliams.comp.ncat.edu/COMP360/History.pdfCommon Business-Oriented Language - Cobol •Designed in 1959 for the Department of Defense (DoD) •Grace

More Cobol Attributes

• Safety – Some data type protection

• Efficiency – Pretty good for report writing

• Large library – Small built in library. Sorting and merging are part of the language

• Support for abstraction – Terrible! No methods or objects

Page 39: History of Programming Languageswilliams.comp.ncat.edu/COMP360/History.pdfCommon Business-Oriented Language - Cobol •Designed in 1959 for the Department of Defense (DoD) •Grace

“The use of COBOL cripples the mind; its teaching should, therefore, be regarded as a criminal offence.”

— Edsger W. Dijkstra

Page 40: History of Programming Languageswilliams.comp.ncat.edu/COMP360/History.pdfCommon Business-Oriented Language - Cobol •Designed in 1959 for the Department of Defense (DoD) •Grace

APL readability

• Find all prime numbers from 1 to R

(~R∊R∘.×R)/R←1↓ιR

• Conway’s game of life

life←{↑1 ⍵∨.∧3 4=+/,¯1 0 1∘.⊖¯1 0 1∘.⌽⊂⍵}

Page 41: History of Programming Languageswilliams.comp.ncat.edu/COMP360/History.pdfCommon Business-Oriented Language - Cobol •Designed in 1959 for the Department of Defense (DoD) •Grace

Early Programming Languages•1952 – Autocode

•1957 – FORTRAN

•1958 – LISP

•1958 – ALGOL

•1959 – COBOL

•1962 – APL

•1962 – SNOBOL

•1964 – BASIC

•1964 – PL/I

Page 42: History of Programming Languageswilliams.comp.ncat.edu/COMP360/History.pdfCommon Business-Oriented Language - Cobol •Designed in 1959 for the Department of Defense (DoD) •Grace

Programming Paradigm Development

• Simula (late 1960s) was the first language designed to support object-oriented programming

• Smalltalk (mid-1970s) provided a complete ground-up design of an object-oriented language

•Prolog (1972) was the first logic programming language

•ML (1973) was one of the first statically typed functional programming languages

Page 43: History of Programming Languageswilliams.comp.ncat.edu/COMP360/History.pdfCommon Business-Oriented Language - Cobol •Designed in 1959 for the Department of Defense (DoD) •Grace

Reading for Friday

•Read chapter 1 of the textbook