Example Imperative/Procedural Language : Fortran
History
John Backus (1953) sought to write programs in conventional mathematical notation, and generate code comparable to good assembly programs.
No language design effort (made it up as they went along)
Most effort spent on code generation and optimization
FORTRAN I released April 1957; working by April 1958
The current standard is FORTRAN 2003
(FORTRAN 2008 is work in progress)
Innovations
Symbolic notation for subroutines and functions
Assignments to variables of complex expressions
DO loops
Comments
Input/output formats
Machine-independence
Successes
Easy to learn; high level
Promoted by IBM; addressed large user base
(scientific computing)
“Hello World” in FORTRAN
PROGRAM HELLO
DO 10, I=1,10
PRINT *,'Hello World'
10 CONTINUE
STOP
END
Example Imperative/Procedural Language : ALGOL 60
History
Committee of PL experts formed in 1955 to design universal, machine-independent, algorithmic language
First version (ALGOL 58) never implemented; criticisms led to ALGOL 60
Innovations
BNF (Backus-Naur Form) introduced to define syntax (led to syntax-directed compilers)
First block-structured language; variables with local scope
Structured control statements
Recursive procedures
Variable size arrays
Successes
Highly influenced design of other PLs but never displaced FORTRAN
“Hello World” in BEALGOL
BEGIN
FILE F (KIND=REMOTE);
EBCDIC ARRAY E [0:11];
REPLACE E BY "HELLO WORLD!";
WHILE TRUE DO
BEGIN
WRITE (F, *, E);
END;
END.
Example Imperative/Procedural Language : COBOL
History
Designed by committee of US computer manufacturers
Targeted business applications
Intended to be readable by managers (!)
Innovations
Separate descriptions of environment, data, and processes
Successes
Adopted as de facto standard by US DOD
Stable standard for 25 years
Still the most widely used PL for business applications (!)
“Hello World” in COBOL
000100 IDENTIFICATION DIVISION.
000200 PROGRAM-ID. HELLOWORLD.
000300 DATE-WRITTEN. 02/05/96 21:04.
000400* AUTHOR BRIAN COLLINS
000500 ENVIRONMENT DIVISION.
000600 CONFIGURATION SECTION.
000700 SOURCE-COMPUTER. RM-COBOL.
000800 OBJECT-COMPUTER. RM-COBOL.
001000 DATA DIVISION.
001100 FILE SECTION.
100000 PROCEDURE DIVISION.
100200 MAIN-LOGIC SECTION.
100300 BEGIN.
100400 DISPLAY " " LINE 1 POSITION 1 ERASE EOS.
100500 DISPLAY "HELLO, WORLD." LINE 15 POSITION 10.
100600 STOP RUN.
100700 MAIN-LOGIC-EXIT.
100800 EXIT.
“Hello World” in Functional Languages
SML print("hello world!\n");
Haskell hello() = print "Hello World"
Example Logic Language : Prolog
History
Originated at U. Marseilles (early 1970s), and compilers developed at Marseilles and Edinburgh (mid to late 1970s)
Innovations
Theorem proving paradigm
Programs as sets of clauses: facts, rules and questions
Computation by “unification”
Successes
Prototypical logic programming language
Used in Japanese Fifth Generation Initiative
“Hello World” in Prolog
hello :- printstring("HELLO WORLD!!!!").
printstring([]).
printstring([H|T]) :- put(H), printstring(T).
Object-Oriented Languages – a problem is broken down into Objects which contain data and processes.
OOP - Diagrams
Inheritance Diagram
Objects/Attributes/Methods