1 / 32

COBOL, LISP, and Python

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

eryk
Download Presentation

COBOL, LISP, and Python

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. COBOL, LISP, and Python Joseph Hoeppner

  2. 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

  3. COBOL – Why? • Software Lifecycle • Cheaper to maintain • Y2K • Self-documenting code • Verbose • “IF a < b AND > c …” • Divisions

  4. COBOL – Why? • Divisions • Identification Division • Environment Division • Data Division • Procedure Division

  5. 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

  6. COBOL – Groups and Elementary data

  7. 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)

  8. COBOL - Summary • Readability • Writability • Reliability • Portability

  9. LISP • LISt Processing • List-based language • 2nd High-level language • 1958 – John McCarthy for MIT

  10. 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))

  11. LISP – Innovations • Garbage Collection • If else statements • Recursion

  12. LISP – Linked Lists • Car (first) • Cdr (rest)

  13. LISP - Examples • If then else • (if nil (list ‘2 ‘3) (list ‘5 ‘6)) • One line variant: • (if nil (list ‘2 ‘3) (list ‘5 ‘6))

  14. 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)))))

  15. LISP - Examples • Recursive List Size • (defunrecursiveSize (L) (if (null L) 0 (1+ (recursiveSize(rest L)))))

  16. LISP - Examples • Recursive List Sum with “LET” • (defun sum (L) (if (null L) 0 (let ((S1 (first L)) (S2 (sum (rest L)))) + S1 S2)))

  17. LISP- Summary and Comparison • Readability • Writability • Reliability

  18. Python • Developed early 1990’s • Guido van Rossum • ABC language • Python 2.0 • 2000 • Community-supported -> reliability • Modular; community expandable • Python 3.0 • 2008

  19. Python – Readability is Key • Design goal • One way to do things • Clarity over clever code • Whitespace over braces • “pass” for No-Op

  20. 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

  21. Python • Comparisons • == tests values, not references • A < b <= C works properly • Ternary operator readable • “a if b else c”

  22. Python • System Requirements • Cross platform • Python Interpreter • Simplicity • Small core language • Large libaraies

  23. 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”)

  24. Python - Examples • Function definition def greatest(a, b, c): largest = a if a > b else b largest = largest if largest > c else c print(largest) • Function call greatest(7, 3, 14) 14

  25. Python - Examples • Determine if prime defisPrime(num): prime = True for i in range(2, (num / 2) + 1): if num % i == 0: prime = False return prime

  26. deftenPrimes(): 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)

  27. Python - Summary and Comparison • Readability • Writability • Reliability

  28. Python - Examples Demo

More Related