Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>Well. With all due respect to the lecturer, these are slightly fishy definitions of both "OOP" and "functional programming". Both terms are consistently used, well, inconsistently, both in industry and academic contexts, not to mention informal use. If you dig a bit deeper, what's really going on is that there are several orthogonal concepts--different axes along which a choice is made in how to approach a program--that are being conflated, with one set of choices being arbitrarily called "OOP" despite not having anything else tying them together.</p> <p>Probably the two biggest distinctions involved here are:</p> <ul> <li><p><strong>Identity vs. value</strong>: Do you model things by implicit identity (based on memory location or whatnot) and allow them to change arbitrarily? Or do you model things by their value, with no inherent notion of identity? If you say <code>x = 4</code> does that mean that <code>x</code> is an alias to the timeless Platonic ideal of the number 4, or is <code>x</code> the name of a thing that's currently a four, but could be something else later (while still being <code>x</code>)?</p></li> <li><p><strong>Data vs. behavior</strong>: Do you work with simple data structures whose representation can be inspected, manipulated, and transformed? Or do you work with abstracted behaviors that do things, representing data only in terms of the things you can do with it, and let these behavioral abstractions operate on each other?</p></li> </ul> <p>Most standard imperative languages lean toward using identity and data--pointers to C <code>struct</code>s are about as purely this approach as possible. OOP languages tend to be defined largely by opting for behavior over data, often leaning toward identity as well but not consistently (cf. the popularity of "immutable" objects).</p> <p>Functional programming usually leans more toward values rather than identity, while mixing data and behavior to various degrees.</p> <p>There's a lot more going on here as well but I think that's the key part of what you're wondering here.</p> <hr> <p>If anyone's curious I've elaborated a bit on some of this before: <a href="https://stackoverflow.com/questions/3124511/newbie-question-how-to-model-class-hierarchies-in-haskell/3124870#3124870">Analyzing some essential concepts of many OOP languages</a>, <a href="https://stackoverflow.com/questions/4113138/oop-in-a-purely-fp-context/4114440#4114440">more on the identity/value issue and also formal vs. informal approaches</a>, <a href="https://stackoverflow.com/questions/2807629/handling-incremental-data-modeling-changes-in-functional-programming/2808181#2808181">a look at the data/behavior distinction in functional programming</a>, probably others I can't think of. Warning, I'm kind of long-winded, these are not for the faint of heart. :P</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload