cobol, lisp, and python
DESCRIPTION
COBOL, LISP, and Python. Joseph Hoeppner. COBOL Background. Released in 1959 Grace Hopper Industry, universities, and government collaboration Cold War pressures 80% of business transactions 65% of all code is in COBOL. COBOL – Why?. Software Lifecycle Cheaper to maintain Y2K - PowerPoint PPT PresentationTRANSCRIPT
![Page 1: COBOL, LISP, and Python](https://reader035.vdocuments.site/reader035/viewer/2022062315/56815c3e550346895dca3b7a/html5/thumbnails/1.jpg)
COBOL, LISP, and Python
Joseph Hoeppner
![Page 2: COBOL, LISP, and Python](https://reader035.vdocuments.site/reader035/viewer/2022062315/56815c3e550346895dca3b7a/html5/thumbnails/2.jpg)
COBOL Background
Released in 1959 Grace Hopper Industry, universities, and government collaboration Cold War pressures
80% of business transactions
65% of all code is in COBOL
![Page 3: COBOL, LISP, and Python](https://reader035.vdocuments.site/reader035/viewer/2022062315/56815c3e550346895dca3b7a/html5/thumbnails/3.jpg)
COBOL – Why?
Software Lifecycle Cheaper to maintain
Y2K
Self-documenting code Verbose
“IF a < b AND > c …” Divisions
![Page 4: COBOL, LISP, and Python](https://reader035.vdocuments.site/reader035/viewer/2022062315/56815c3e550346895dca3b7a/html5/thumbnails/4.jpg)
COBOL – Why?
Divisions Identification Division Environment Division Data Division Procedure Division
![Page 5: COBOL, LISP, and Python](https://reader035.vdocuments.site/reader035/viewer/2022062315/56815c3e550346895dca3b7a/html5/thumbnails/5.jpg)
COBOL – Data Division
Data Division Pictures
9 = digit X = any character A = alphabetic character V = decimal point position S = sign
Repeats PIC 9 (4) = 9999
![Page 6: COBOL, LISP, and Python](https://reader035.vdocuments.site/reader035/viewer/2022062315/56815c3e550346895dca3b7a/html5/thumbnails/6.jpg)
![Page 7: COBOL, LISP, and Python](https://reader035.vdocuments.site/reader035/viewer/2022062315/56815c3e550346895dca3b7a/html5/thumbnails/7.jpg)
COBOL – Groups and Elementary data
![Page 8: COBOL, LISP, and Python](https://reader035.vdocuments.site/reader035/viewer/2022062315/56815c3e550346895dca3b7a/html5/thumbnails/8.jpg)
![Page 9: COBOL, LISP, and Python](https://reader035.vdocuments.site/reader035/viewer/2022062315/56815c3e550346895dca3b7a/html5/thumbnails/9.jpg)
COBOL
Reliability Stood test of time Has “ALTER X TO PROCEED TO Y” (a negative) Uses GOTO statements (a negative)
Today Cross platform: OpenCOBOL C translation IDEs (Net Express)
![Page 10: COBOL, LISP, and Python](https://reader035.vdocuments.site/reader035/viewer/2022062315/56815c3e550346895dca3b7a/html5/thumbnails/10.jpg)
COBOL - Summary
Readability
Writability
Reliability
Portability
![Page 11: COBOL, LISP, and Python](https://reader035.vdocuments.site/reader035/viewer/2022062315/56815c3e550346895dca3b7a/html5/thumbnails/11.jpg)
LISP
LISt Processing List-based language
2nd High-level language
1958 – John McCarthy for MIT
![Page 12: COBOL, LISP, and Python](https://reader035.vdocuments.site/reader035/viewer/2022062315/56815c3e550346895dca3b7a/html5/thumbnails/12.jpg)
![Page 13: COBOL, LISP, and Python](https://reader035.vdocuments.site/reader035/viewer/2022062315/56815c3e550346895dca3b7a/html5/thumbnails/13.jpg)
LISP - Syntax
Function call: “(fun arg1 arg2)” (+ 1 2 3)
Lists (list ‘3 ‘7 ‘apples)
(3 7 apples)
(list ‘13 list(‘3 ‘5)) (13 (3 5))
![Page 14: COBOL, LISP, and Python](https://reader035.vdocuments.site/reader035/viewer/2022062315/56815c3e550346895dca3b7a/html5/thumbnails/14.jpg)
LISP – Innovations
Garbage Collection
If else statements
Recursion
![Page 15: COBOL, LISP, and Python](https://reader035.vdocuments.site/reader035/viewer/2022062315/56815c3e550346895dca3b7a/html5/thumbnails/15.jpg)
LISP – Linked Lists
Car (first)
Cdr (rest)
![Page 16: COBOL, LISP, and Python](https://reader035.vdocuments.site/reader035/viewer/2022062315/56815c3e550346895dca3b7a/html5/thumbnails/16.jpg)
![Page 17: COBOL, LISP, and Python](https://reader035.vdocuments.site/reader035/viewer/2022062315/56815c3e550346895dca3b7a/html5/thumbnails/17.jpg)
LISP - Examples
If then else (if nil
(list ‘2 ‘3)(list ‘5 ‘6))
One line variant: (if nil (list ‘2 ‘3) (list ‘5 ‘6))
![Page 18: COBOL, LISP, and Python](https://reader035.vdocuments.site/reader035/viewer/2022062315/56815c3e550346895dca3b7a/html5/thumbnails/18.jpg)
LISP - Examples
Factorial (defun factorial (n)
(if (<= n 1)1(* n (factorial (- n 1)))))
One line variant: (defun factorial (n) (if (<= n 1) 1 (* n (factorial (- n 1)))))
![Page 19: COBOL, LISP, and Python](https://reader035.vdocuments.site/reader035/viewer/2022062315/56815c3e550346895dca3b7a/html5/thumbnails/19.jpg)
LISP - Examples
Recursive List Size (defun recursiveSize (L)
(if (null L)
0
(1+ (recursiveSize(rest L)))))
![Page 20: COBOL, LISP, and Python](https://reader035.vdocuments.site/reader035/viewer/2022062315/56815c3e550346895dca3b7a/html5/thumbnails/20.jpg)
LISP - Examples
Recursive List Sum with “LET” (defun sum (L)
(if (null L)
0
(let
((S1 (first L))
(S2 (sum (rest L))))
+ S1 S2)))
![Page 21: COBOL, LISP, and Python](https://reader035.vdocuments.site/reader035/viewer/2022062315/56815c3e550346895dca3b7a/html5/thumbnails/21.jpg)
LISP- Summary and Comparison
Readability
Writability
Reliability
![Page 22: COBOL, LISP, and Python](https://reader035.vdocuments.site/reader035/viewer/2022062315/56815c3e550346895dca3b7a/html5/thumbnails/22.jpg)
Python
Developed early 1990’s Guido van Rossum ABC language
Python 2.0 2000 Community-supported -> reliability
Modular; community expandable
Python 3.0 2008
![Page 23: COBOL, LISP, and Python](https://reader035.vdocuments.site/reader035/viewer/2022062315/56815c3e550346895dca3b7a/html5/thumbnails/23.jpg)
Python – Readability is Key
Design goal One way to do things Clarity over clever code Whitespace over braces “pass” for No-Op
![Page 24: COBOL, LISP, and Python](https://reader035.vdocuments.site/reader035/viewer/2022062315/56815c3e550346895dca3b7a/html5/thumbnails/24.jpg)
Python
Writability Similar to other OO languages Verification support
Interpreted, assert, no statements in conditions Clean style Few keywords Simple grammar -> few ways to do something
![Page 25: COBOL, LISP, and Python](https://reader035.vdocuments.site/reader035/viewer/2022062315/56815c3e550346895dca3b7a/html5/thumbnails/25.jpg)
Python
Comparisons == tests values, not references
A < b <= C works properly
Ternary operator readable “a if b else c”
![Page 26: COBOL, LISP, and Python](https://reader035.vdocuments.site/reader035/viewer/2022062315/56815c3e550346895dca3b7a/html5/thumbnails/26.jpg)
Python
System Requirements Cross platform Python Interpreter
Simplicity Small core language Large libaraies
![Page 27: COBOL, LISP, and Python](https://reader035.vdocuments.site/reader035/viewer/2022062315/56815c3e550346895dca3b7a/html5/thumbnails/27.jpg)
Python - Examples
a = 15
if(a < 10):
print(“input less than 10”)
elif(10 < a < 20):
print(“input between 10 and 20”)
else:
print(“input greater than 20”)
![Page 28: COBOL, LISP, and Python](https://reader035.vdocuments.site/reader035/viewer/2022062315/56815c3e550346895dca3b7a/html5/thumbnails/28.jpg)
Python - Examples
Function definitiondef greatest(a, b, c):
largest = a if a > b else b
largest = largest if largest > c else c
print(largest)
Function callgreatest(7, 3, 14)
14
![Page 29: COBOL, LISP, and Python](https://reader035.vdocuments.site/reader035/viewer/2022062315/56815c3e550346895dca3b7a/html5/thumbnails/29.jpg)
Python - Examples
Determine if primedef isPrime(num):
prime = True
for i in range(2, (num / 2) + 1):
if num % i == 0:
prime = False
return prime
![Page 30: COBOL, LISP, and Python](https://reader035.vdocuments.site/reader035/viewer/2022062315/56815c3e550346895dca3b7a/html5/thumbnails/30.jpg)
def tenPrimes():
list = []
count = 0
current = 2
#store the first 10 primes in a list
while count < 10:
if isPrime(current):
count += 1
list.append(current)
current = current + 1
#print the list
for element in list:
print(element)
![Page 31: COBOL, LISP, and Python](https://reader035.vdocuments.site/reader035/viewer/2022062315/56815c3e550346895dca3b7a/html5/thumbnails/31.jpg)
Python - Summary and Comparison
Readability
Writability
Reliability
![Page 32: COBOL, LISP, and Python](https://reader035.vdocuments.site/reader035/viewer/2022062315/56815c3e550346895dca3b7a/html5/thumbnails/32.jpg)
Python - Examples
Demo