Professional Documents
Culture Documents
Programming Languages
Content
Introduction to programming languages
Fortran
Algol
Principles violated and adhered by Fortran and Algol
Introduction of programming
languages
History of programming languages
Algorithms
Abu Ja’far Muhammad ibn Musa al-Khorezmi
(790-850AD)
Markov algorithms
Andrey Markov (1903-1979)
Programming Language
Formal notation for specifying computations
Syntax (usually specified by a context-free grammar)
Semantics for each syntactic construct
Practical implementation on a real or virtual machine
Translation vs. compilation vs. interpretation
C++ was originally translated into C by Stroustrup’s Cfront
John Backus
1924-1988
Program Structure
A FORTRAN program is a collection of subprogram
definitions.
Subprograms may be a FUNCTION that returns values,
a SUBROUTINE that doesn’t return a value, and one
must be the “main program”
The initial release of FORTRAN for the IBM 704
contained 32 statements, including:
DIMENSION and EQUIVALENCE statements
Assignment statements
Three-way arithmetic IF statement.
IF statements for checking exceptions.
Control Structures
GOTO statements
IF statements
DO statement
CONTINUE statement
STOP and PAUSE statements
END statement
GOTO Statements
Three types of GOTO statements
* Basic GOTO 100
* Computed GOTO(1,2,3)E
* Assigned GOTO L,(1,2,3)
IF Statement DO Statement
Contains IF, ELSE IF, ELSE, END The DO statement is used to
IF
Example establish a controlled loop
IF(Q) THEN Example DO
A=B DO 10 I = 1,10,1
C=D
ELSE IF (R) THEN
E=F
G=H
ELSE
X=Y
Z=W
END IF
CONTINUE,STOP PAUSE, and
END STATEMENT
The CONTINUE statement serves as a point of reference in
a program
No operational function is performed
It is frequently used in DO loops to provide a terminal statement
The STOP and PAUSE statements do a similar task
The STOP terminates execution
The PAUSE terminates execution, but leaves the program in a
resumable state
The END statement marks the physical end of a program
FORTRAN SYNTAX
•Lines can only be 72 characters long
•Comments start with a !
•First 6 columns must be spaces
Unless it’s a comment
•No semi-colons after each line.
Important . . . .
o Ignoring blanks
o Lack of reserved words and inbuilt input/output functions
o Three versions of GOTO
o Mixed mode operations
o Common block structure
Algol
Designed during 1958-1960
Algol introduces block structure, compound statements,
recursive procedure calls, nested if loops, and arbitrary
length identifiers.
The Algol-60 was a very simple and clear language.
BNF Notation was used for the language specification.
Algol-60 uses a hierarchical structure throughout its
design .This was a major contribution of Algol.
ALGOL-60 allows nested control structures(such as the
FOR-loop) and nested environments
Algol 60 Sample
real procedure average(A,n);
real array A; integer n; no array bounds
begin
real sum; sum := 0;
for i = 1 step 1 until n do
sum := sum + A[i];
average := sum/n no ; here
end;
Preservation of information:
Allow representation of information that the user might know and
the compiler might need.
●
Violation: Fortran does not have exception handling or type
checking
Syntatic Consistency:
Things which look similar should be similar, and things which
look different should be different.
●
Violation: FORTRAN Uses * for multiplication and ** for
exponents.
Principles Violated in Fortran
Regularity
Regular rules, without exceptions, are easier to learn, use,
describe, and implement
Zero-One-Infinity
The only reasonable numbers in a programming language design
are zero, one and infinity.
Zero-One-Infinity:
The only reasonable numbers in a programming language design
are zero, one and infinity
Compliance: Arrays in Algol can have any number of
dimensions and can have negative indices.
.
Regularity:
Regular rules, without exceptions, are easier to learn, use,
describe, and implement.
Compliance: In Algol, a sequence of statements can replace
a single statement using the block structure.
Principles Adhered in Algol
Syntactic Consistency:
Things which look similar should be similar, and things which
look different should be different.