Presentation is loading. Please wait.

Presentation is loading. Please wait.

Some Important Programming Languages

Similar presentations


Presentation on theme: "Some Important Programming Languages"— Presentation transcript:

1 Some Important Programming Languages
CMPT 383

2 Fortran (1957) Fortran = Formula Translator
Design by John Backus et al from IBM Designed to be easier to use than machine language 1st version for the IBM 704 Extremely popular with scientists and engineers Still in use today

3 C AREA OF A TRIANGLE WITH A STANDARD SQUARE ROOT FUNCTION
C INPUT - TAPE READER UNIT 5, INTEGER INPUT C OUTPUT - LINE PRINTER UNIT 6, REAL OUTPUT C INPUT ERROR DISPLAY ERROR OUTPUT CODE 1 IN JOB CONTROL LISTING READ INPUT TAPE 5, 501, IA, IB, IC 501 FORMAT (3I5) C IA, IB, AND IC MAY NOT BE NEGATIVE OR ZERO C FURTHERMORE, THE SUM OF TWO SIDES OF A TRIANGLE C MUST BE GREATER THAN THE THIRD SIDE, SO WE CHECK FOR THAT, TOO IF (IA) 777, 777, 701 701 IF (IB) 777, 777, 702 702 IF (IC) 777, 777, 703 703 IF (IA+IB-IC) 777, 777, 704 704 IF (IA+IC-IB) 777, 777, 705 705 IF (IB+IC-IA) 777, 777, 799 777 STOP 1 C USING HERON'S FORMULA WE CALCULATE THE C AREA OF THE TRIANGLE 799 S = FLOATF (IA + IB + IC) / 2.0 AREA = SQRTF( S * (S - FLOATF(IA)) * (S - FLOATF(IB)) * + (S - FLOATF(IC))) WRITE OUTPUT TAPE 6, 601, IA, IB, IC, AREA 601 FORMAT (4H A= ,I5,5H B= ,I5,5H C= ,I5,8H AREA= ,F10.2, H SQUARE UNITS) STOP END More Modern Fortran PROGRAM Fibonacci IMPLICIT NONE INTEGER :: FIRST, SECOND, TEMP, IX FIRST = 0 SECOND = 1 WRITE (*,*) FIRST WRITE (*,*) SECOND DO IX = 1, 45, 1 TEMP = FIRST + SECOND FIRST = SECOND SECOND = TEMP WRITE (*,*) TEMP END DO END PROGRAM Fibonacci

4 LISP (1958) LISP = List Processing
Designed by John McCarthy and his students Designed for symbolic processing (e.g. calculating symbolic derivatives) and AI Extremely simple core language Pioneered many programming ideas Many dialects over the years (defun factorial (n) (if (= n 0) 1 (* n (factorial (- n 1)))))

5 COBOL (1959) COBOL = Common Business-Oriented Language
Associated with Rear Admiral Grace Hopper, who designed a predecessor called Flow-matic Specifically for business Extremely popular

6 IDENTIFICATION DIVISION.
PROGRAM-ID. "Fibonacci". ENVIRONMENT DIVISION. DATA DIVISION. WORKING-STORAGE SECTION. 01 ix BINARY-C-LONG VALUE 0. 01 first-number BINARY-C-LONG VALUE 0. 01 second-number BINARY-C-LONG VALUE 1. 01 temp-number BINARY-C-LONG VALUE 1. 01 display-number PIC Z(19)9. PROCEDURE DIVISION. * This is the start of the program START-PROGRAM. MOVE first-number TO display-number. DISPLAY display-number. MOVE second-number TO display-number. PERFORM VARYING ix FROM 1 BY 1 UNTIL ix = 90 ADD first-number TO second-number GIVING temp-number MOVE second-number TO first-number MOVE temp-number TO second-number MOVE temp-number TO display-number DISPLAY display-number END-PERFORM. STOP RUN.

7 Algol Languages (1960s) Algol = Algorithmic Language
Algol 60 Example Algol = Algorithmic Language Influential set of languages designed by a group of computer scientists (including Backus and McCarthy) Pioneered many now- standard language features (and more) No longer popular in practice, but still very influential procedure Absmax(a) Size:(n, m) Result:(y) Subscripts:(i, k); value n, m; array a; integer n, m, i, k; real y; comment The absolute greatest element of the matrix a, of size n by m is transferred to y, and the subscripts of this element to i and k; begin integer p, q; y := 0; i := k := 1; for p := 1 step 1 until n do for q := 1 step 1 until m do if abs(a[p, q]) > y then begin y := abs(a[p, q]); i := p; k := q end end Absmax

8 SmallTalk (1970s) Developed by Alan Kay and his group at Xerox Parc
Helped popularize OOP, especially in North America Not the first object-oriented programming (OOP) language (that was SIMULA, from the 1960s) Squeak Code Example factorial "Answer the factorial of the receiver." self = 0 ifTrue: [^ 1]. self > 0 ifTrue: [^ self * (self - 1) factorial]. self error: 'Not valid for negative integers'

9 Prolog (1972) Prolog = Programming Logic
Quicksort in Prolog Prolog = Programming Logic Declarative, logic-based, constraint-oriented Developed by Alain Colmerauer (although many others helped develop the underlying ideas) Certain complex problems have beautifully simple Prolog solutions Certain easy problems have ugly and complex Prolog solutions partition([], _, [], []). partition([X|Xs], Pivot, Smalls, Bigs) :- ( Pivot -> Smalls = [X|Rest], partition(Xs, Pivot, Rest, Bigs) ; Bigs = [X|Rest], partition(Xs, Pivot, Smalls, Rest) ). quicksort([]) > []. quicksort([X|Xs]) --> { partition(Xs, X, Smaller, Bigger) }, quicksort(Smaller), [X], quicksort(Bigger).


Download ppt "Some Important Programming Languages"

Similar presentations


Ads by Google