1 / 15

CSCI 383

CSCI 383. Object-Oriented Programming & Design Lecture 2 Martin van Bommel. Why is OOP Popular?. OOP has been the dominant programming paradigm for more than twenty years. Why is it so popular? Proven record of success Scales well from small problems to large

Download Presentation

CSCI 383

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. CSCI 383 Object-Oriented Programming & Design Lecture 2 Martin van Bommel

  2. Why is OOP Popular? • OOP has been the dominant programming paradigm for more than twenty years. • Why is it so popular? • Proven record of success • Scales well from small problems to large • Nevertheless, programming is still a task that requires skill and learning CSCI 383 Lecture 2 M. van Bommel

  3. Disclaimer • Effective use of object-oriented principles requires one to view the world in a new way • The use of an object-oriented language does not make one an object-oriented programmer “Fortran programs can be written in any language” CSCI 383 Lecture 2 M. van Bommel

  4. A New Paradigm • Object-oriented programming is often described as a new paradigm. We start by considering the definition of this term: Paradigmn.1. A list of all the inflectional forms of a word taken as illustrative example of the conjugation or declension to which it belongs. 2. An example or model. [Late Latin paradigma, from Greek paradeigma, modern paradeiknunai, to compare, exhibit.] CSCI 383 Lecture 2 M. van Bommel

  5. Sapir-Whorf Hypothesis • In linguistics, there is a hypothesis that the language in which an idea or thought is expressed colors or directs in a very emphatic manner that nature of the thought CSCI 383 Lecture 2 M. van Bommel

  6. Sapir-Whorf Meaning • The SWH argues that we experience the world based on the words we have • In an experiment, people were asked to describe how many bands or stripes they saw in a rainbow • Since rainbows are a continuum of colors, no empirical stripes or bands • Nevertheless, people saw as many stripes or bands as their language possessed primary color words • Inuit language and snowArabic language and camels CSCI 383 Lecture 2 M. van Bommel

  7. Sapir-Whorf Implications • Is it true that the way we think is completely determined by the language we use? • This implies the words we have determine the things we can know • If we have an experience, we are confined not just in our communication of it, but also in our knowledge of it, by the words we have CSCI 383 Lecture 2 M. van Bommel

  8. Sapir-Whorf Counter-argument • People usually have trouble expressing themselves and are aware that the language is not adequate for what they mean • “That’s not quite what I meant to say…” • This provides evidence that what is being thought is not a set of words because one can understand a concept without being able to express it in words • Truth probably somewhere in the middle • language may not completely determine but can influence the way we think CSCI 383 Lecture 2 M. van Bommel

  9. Sapir-Whorf Application • What in the world does this have to do with computer programming languages? • What is true of natural languages is even more true of artificial computer languages “If all you have is a hammer, everything looks like a nail." CSCI 383 Lecture 2 M. van Bommel

  10. Example of SW • A student working in DNA research had the task of finding whether any pattern of length m (m fixed and small) is repeated in a given DNA sequence of length n (n very very large) ACTCGGATCTTGCATTTCGGCAATTGGACCCTGACTTGGCCA ... CSCI 383 Lecture 2 M. van Bommel

  11. Example (cont’d) • Wrote the simplest (and therefore, most efficient?) Fortran program: DO 10 I = 1, N-M DO 10 J = I+1, N-M FOUND = .TRUE. DO 20 K = 1, M 20 IF X[I+K-1] .NE. X[J+K-1] THEN FOUND = .FALSE. IF FOUND THEN ... 10 CONTINUE • Took a depressingly long time. Asymptotic time complexity? CSCI 383 Lecture 2 M. van Bommel

  12. A Better Solution • A friend writing in APL solved by rearranging the data and sorting • Reorganize in NxM matrix A C T C G G positions 1 to M C T C G G A positions 2 to M+1 T C G G A T positions 3 to M+2 C G G A T T positions 4 to M+3 G G A T T C positions 5 to M+4 . . . • Sort matrix on rows and find equal adjacent row • Ran surprisingly quickly, thesis saved CSCI 383 Lecture 2 M. van Bommel

  13. What lead to the discovery? • Why did APL programmer find better solution? • Fortran programmer was blinded by a culture that valued assignment, comparison, loops, and simple programs. • Fortran programmer thinks in terms of loops • Sorting is a built-in operation in APL, good programmers try to find novel uses for sorting. • APL programmer thinks in terms of manipulating sequences; sort is built-in, loops do not exist • APL is not a “more efficient” language than Fortran • The fundamental point is that the language you speak leads you in one direction or another CSCI 383 Lecture 2 M. van Bommel

  14. S-W & Computation • Sapir-Whorf hypothesis says there are some thoughts you can express in one language that you cannot express in another • However, in computation, we have the following assertion: • Church's Conjecture: Any computation for which there exists an effective procedure can be realized by a Turing machine language CSCI 383 Lecture 2 M. van Bommel

  15. Church's Conjecture • Anything can be done in any language, but it may simply be easier or more efficient to use one language or another. • Note that is almost directly opposite to the SWH • Would YOU want to write an event-driven GUI interface in Turing machine language? • Bottom line: Languages lead you, but do not prevent you from going anywhere you want CSCI 383 Lecture 2 M. van Bommel

More Related