the beauty and joy of the beauty and joy of computing
play

The Beauty and Joy of The Beauty and Joy of Computing Computing - PowerPoint PPT Presentation

The Beauty and Joy of The Beauty and Joy of Computing Computing Lectur Lecture #5 e #5 Programming Paradigms Pr ogramming Paradigms UC Berkeley EECS UC Berkeley EECS Sr Lectur Sr Lecturer SOE er SOE Dan Gar Dan Garcia cia Story


  1. The Beauty and Joy of The Beauty and Joy of Computing Computing Lectur Lecture #5 e #5 Programming Paradigms Pr ogramming Paradigms UC Berkeley EECS UC Berkeley EECS Sr Lectur Sr Lecturer SOE er SOE Dan Gar Dan Garcia cia Story details the move to Digital of many things precious to us – music, photos, videos. Is there something lost in the process? and what happens when that data is deleted. YOUR backup solution? http://www.nytimes.com/2012/01/29/magazine/what- happens-when-data-disappears.html �

  2. Programming Paradigms Lecture § What are they? ú Most are Hybrids! § The Four Primary ones ú Functional ú Imperative ú Object-Oriented  OOP Example: Skecthpad ú Declarative § Turing Completeness § Summary Gar Garcia cia UC Berkeley “The Beauty and Joy of Computing” UC Berkeley “The Beauty and Joy of Computing” : Pr : Programming Paradigms ogramming Paradigms (2) (2)

  3. en.wikipedia.org/wiki/Programming_paradigm What are Programming Paradigms? § “The concepts and abstractions used to represent the elements of a program (e.g., objects, functions, variables, constraints, etc.) and the steps that compose a computation (assignation, evaluation, continuations, data flows, etc.).” § Or, a way to classify the style of programming. Garcia Gar cia UC Berkeley “The Beauty and Joy of Computing” : Pr UC Berkeley “The Beauty and Joy of Computing” : Programming Paradigms ogramming Paradigms (3) (3)

  4. Most Languages Are Hybrids! § This makes it hard to teach to students, because most languages have facets of several paradigms! ú Called “Multi-paradigm” languages ú Scratch too! § It’s like giving someone a juice drink (with many fruit in it) and asking to taste just one fruit! Gar Garcia cia UC Berkeley “The Beauty and Joy of Computing” UC Berkeley “The Beauty and Joy of Computing” : Pr : Programming Paradigms ogramming Paradigms (4) (4)

  5. en.wikipedia.org/wiki/Functional_programming Functional Programming (review) § Computation is the f(x)=(x+3)* x evaluation of functions ú Plugging pipes together x ú Each pipe, or function, has exactly 1 output ú Functions can be input! x � x 3 § Features ú No state + f  E.g., variable assignments ú No mutation  E.g., changing variable values ú No side effects * § Examples (tho not pure) ú Scheme, Scratch BYOB Garcia Gar cia UC Berkeley “The Beauty and Joy of Computing” : Pr UC Berkeley “The Beauty and Joy of Computing” : Programming Paradigms ogramming Paradigms (5) (5)

  6. en.wikipedia.org/wiki/Imperative_programming Imperative Programming § “Sequential” Programming f(x)=(x+3)* x § Computation a series of steps ú Assignment allowed  Setting variables ú Mutation allowed  Changing variables § Like following a recipe. E.g., § Procedure f(x) ú ans = x ú ans = ans ú ans = (x+3) * ans ú return ans § Examples: (tho not pure) ú Pascal, C Garcia Gar cia UC Berkeley “The Beauty and Joy of Computing” : Pr UC Berkeley “The Beauty and Joy of Computing” : Programming Paradigms ogramming Paradigms (6) (6)

  7. en.wikipedia.org/wiki/Object-oriented_programming Object-Oriented Programming (OOP) § Objects as data structures ú With methods you ask of them  These are the behaviors ú With local state, to remember  These are the attributes § Classes & Instances ú Instance an example of class ú E.g., Fluffy is instance of Dog § Inheritance saves code ú Hierarchical classes ú E.g., pianist special case of www3.ntu.edu.sg/home/ehchua/ musician, a special case of programming/java/images/OOP-Objects.gif performer § Examples (tho not pure) ú Java, C++ Garcia Gar cia UC Berkeley “The Beauty and Joy of Computing” : Pr UC Berkeley “The Beauty and Joy of Computing” : Programming Paradigms ogramming Paradigms (7) (7)

  8. en.wikipedia.org/wiki/Sketchpad OOP Example : SketchPad § Dr. Ivan Sutherland ú “Father of Computer Spent the past Graphics” few years doing ú 1988 Turing Award (“Nobel research @ Berkeley prize” for CS) in EECS dept! ú Wrote Sketchpad for his foundational 1963 thesis § The most impressive software ever written § First… ú Object-oriented system ú Graphical user interface ú non-procedural language Garcia Gar cia UC Berkeley “The Beauty and Joy of Computing” : Pr UC Berkeley “The Beauty and Joy of Computing” : Programming Paradigms ogramming Paradigms (8) (8)

  9. OOP in BYOB Gar Garcia cia UC Berkeley “The Beauty and Joy of Computing” UC Berkeley “The Beauty and Joy of Computing” : Pr : Programming Paradigms ogramming Paradigms (9) (9)

  10. en.wikipedia.org/wiki/Declarative_programming Declarative Programming § Express what computation desired without specifying how it carries it out ú Often a series of assertions and queries ú Feels like magic! § Sub-categories ú Logic Anders Hejlsberg ú Constraint “The Future of C#” @ PDC2008 channel9.msdn.com/pdc2008/TL16/  We saw in Sketchpad! § Example: Prolog Garcia Gar cia UC Berkeley “The Beauty and Joy of Computing” : Pr UC Berkeley “The Beauty and Joy of Computing” : Programming Paradigms ogramming Paradigms (10) (10)

  11. Declarative Programming Example § Betty § Five schoolgirls sat for an ú Kitty was 2 nd examination. Their ú I was 3 rd parents – so they thought § Ethel – showed an undue ú I was on top degree of interest in the ú Joan was 2 nd result. They therefore § Joan agreed that, in writing ú I was 3 rd home about the ú Ethel was last examination, each girl § Kitty should make one true ú I came out 2 nd statement and one ú Mary was only 4 th untrue one. The following § Mary are the relevant passages ú I was 4 th from their letters: ú Betty was 1 st Garcia Gar cia UC Berkeley “The Beauty and Joy of Computing” UC Berkeley “The Beauty and Joy of Computing” : Pr : Programming Paradigms ogramming Paradigms (11) (11)

  12. en.wikipedia.org/wiki/Programming_paradigm Ways to Remember the Paradigms § Functional § Object-oriented ú Evaluate an expression ú Send messages and use the resulting between objects to value for something simulate the temporal evolution of a set of real world phenomena § Imperative § Declarative ú First do this ú Answer a question via and next do that search for a solution www.cs.aau.dk/~normark/prog3-03/html/notes/ paradigms_themes-paradigm-overview-section.html Garcia Gar cia UC Berkeley “The Beauty and Joy of Computing” : Pr UC Berkeley “The Beauty and Joy of Computing” : Programming Paradigms ogramming Paradigms (12) (12)

  13. Summary § Each paradigm has its unique benefits ú If a language is Turing complete, it is equally powerful ú Paradigms vary in efficiency, scalability, overhead, fun, “how” vs “what” to specify, etc. § Modern languages usually take the best from all ú E.g., Scratch  Can be functional  Can be imperative  Can be object-oriented  Can be declarative Gar Garcia cia UC Berkeley “The Beauty and Joy of Computing” UC Berkeley “The Beauty and Joy of Computing” : Pr : Programming Paradigms ogramming Paradigms (13) (13)

Download Presentation
Download Policy: The content available on the website is offered to you 'AS IS' for your personal information and use only. It cannot be commercialized, licensed, or distributed on other websites without prior consent from the author. To download a presentation, simply click this link. If you encounter any difficulties during the download process, it's possible that the publisher has removed the file from their server.

Recommend


More recommend