the variety of programming languages
DESCRIPTION
The Variety of Programming Languages. D Goforth COSC 3127. 1. Grouping Languages by Paradigm. imperative functional logical object.oriented scripting??. Imperative Languages (Procedural). since 1940’s, high level since 1950’s statement-oriented closest to underlying machine model - PowerPoint PPT PresentationTRANSCRIPT
![Page 1: The Variety of Programming Languages](https://reader035.vdocument.in/reader035/viewer/2022081821/5681316d550346895d97e87a/html5/thumbnails/1.jpg)
The Variety of Programming Languages
D GoforthCOSC 3127
D GoforthCOSC 3127
![Page 2: The Variety of Programming Languages](https://reader035.vdocument.in/reader035/viewer/2022081821/5681316d550346895d97e87a/html5/thumbnails/2.jpg)
1. Grouping Languages by Paradigm imperative functional logical object.oriented scripting??
![Page 3: The Variety of Programming Languages](https://reader035.vdocument.in/reader035/viewer/2022081821/5681316d550346895d97e87a/html5/thumbnails/3.jpg)
Imperative Languages (Procedural) since 1940’s, high level since 1950’s statement-oriented closest to underlying machine model e.g. Fortran, COBOL, Algol, Pascal, c
![Page 4: The Variety of Programming Languages](https://reader035.vdocument.in/reader035/viewer/2022081821/5681316d550346895d97e87a/html5/thumbnails/4.jpg)
ALGOL 60 example: (see p. 60, Sebesta)(part of program, read in array and find sum)comment input integers into array and find sum;begin integer array intlist[1:99]; integer listlen, counter, sum; sum = 0; readint(listlen); if (listlen>0) ^ (listlen < 100) then begin comment loop to read values; for counter := 1 step 1 until listlen do begin readint(intlist[counter]); sum := sum + intlist[counter] end; printint(sum) endend
![Page 5: The Variety of Programming Languages](https://reader035.vdocument.in/reader035/viewer/2022081821/5681316d550346895d97e87a/html5/thumbnails/5.jpg)
Functional Languages (Applicative) since 1950’s based on mathematical concept of function data storage is a ‘side-effect’! Command-line interpreter model e.g. LISP, APL, Maple, unix, DOS BASIC is an imperative/functional hybrid
![Page 6: The Variety of Programming Languages](https://reader035.vdocument.in/reader035/viewer/2022081821/5681316d550346895d97e87a/html5/thumbnails/6.jpg)
LISP example: (in a pseudo-lisp dialect)
(function to add all numbers in a list ‘lis’; lis may not be a list, or, when it is a list, may contain items others than numbers that can be added
? (define (sumnum lis)
(if ((not (list? lis))
( 0 ))
((number? (firstOf lis))
(plus (firstOf lis)(sumnum (restOf lis))))
( true (sumnum (restOf lis)))))
sumnum
? (sumnum ‘( 4 w (u n 66) 5 3))
12
![Page 7: The Variety of Programming Languages](https://reader035.vdocument.in/reader035/viewer/2022081821/5681316d550346895d97e87a/html5/thumbnails/7.jpg)
Logic Languages
since 1970’s based on logical implication expressions (=>) programs determine what combinations of
data make expressions true e.g. Prolog
![Page 8: The Variety of Programming Languages](https://reader035.vdocument.in/reader035/viewer/2022081821/5681316d550346895d97e87a/html5/thumbnails/8.jpg)
Prolog example:
(program to find the greatest common divisor of two integers U, V; result is value of W)
gcd(U, 0, U).
gcd(U, V, W) :- not(V=0),
R is U mod V,
gcd(V, R, W).
?- gcd(10, 15, W).
W = 5
?- gcd(20,30,7).
no.
![Page 9: The Variety of Programming Languages](https://reader035.vdocument.in/reader035/viewer/2022081821/5681316d550346895d97e87a/html5/thumbnails/9.jpg)
Object-oriented Languages
since 1970’s abstract data types manipulated by
messages invoking methods e.g. Smalltalk, Actor C++, java are imperative/object-oriented
hybrids
![Page 10: The Variety of Programming Languages](https://reader035.vdocument.in/reader035/viewer/2022081821/5681316d550346895d97e87a/html5/thumbnails/10.jpg)
Smalltalk example: (see p. 481, Sebesta)
(method to replace two arrays of objects with longer arrays;
the arrays ‘names’ and ‘codes’ are instance variables)
grow | oldNames oldCodes|
oldNames <- names.
oldCodes <- codes.
names <- Array new: names size + 1.
codes <- Array new: codes size + 1.
names replaceFrom: 1 to: oldNames size with: oldNames
codes replaceFrom: 1 to: oldCodes size with: oldCodes
![Page 11: The Variety of Programming Languages](https://reader035.vdocument.in/reader035/viewer/2022081821/5681316d550346895d97e87a/html5/thumbnails/11.jpg)
Scripting Languages
since 1950’s based on large libraries of routines e.g. JCL, AWK, Perl
![Page 12: The Variety of Programming Languages](https://reader035.vdocument.in/reader035/viewer/2022081821/5681316d550346895d97e87a/html5/thumbnails/12.jpg)
2. Grouping Languages by Kinship Sebesta, p. 39 languages are related to others developed
before many languages mix programming paradigms
![Page 13: The Variety of Programming Languages](https://reader035.vdocument.in/reader035/viewer/2022081821/5681316d550346895d97e87a/html5/thumbnails/13.jpg)