Does psychology provide an argument in favour of object-oriented programming?
November 21, 2007 8:58 AM   Subscribe

Does psychology provide an argument in favour of object-oriented programming?

Over the past year I've been learning, and teaching, object-oriented programming (Java). All my previous experience was in scripting languages. It occurs to me that the good thing about OOP is that it fits in well with the human instinct to understand the world in terms of entities/actors (objects) performing actions. It seems very natural to describe complex systems in this way and we do it all the time - "the computer is trying to connect to the internet". Similarly, when discussing code - "this line of code tells the button to change its colour to red". I've never studied psychology, but I'm guessing that this tendency (for people to think about things in this way) is probably a well-known phenomenon. Has anyone thought/written about programming in this way? I'd be fascinated to read any articles.
posted by primer_dimer to Science & Nature (16 answers total) 7 users marked this as a favorite
 
Best answer: maybe this is a starting point: Cognitive psychology reveals some of the thought-related benefits of object-orientation in computer programming. ... goes on to make a reference to Gerald Weinberg.
posted by jepler at 9:20 AM on November 21, 2007


Best answer: You probably want to look at Daniel Dennet - assigning goals and desires to entities in the way you describe is very like what he's on about.
posted by logicpunk at 9:25 AM on November 21, 2007


I think you might be suffering a bit of confirmation bias here. I could just as easily make the argument that my human instinct is to understand the world in terms of a narrative story - first this happens, then that, and finally the other thing. As further evidence, witness our species' love of fables, myths, movies, tv shows, plays, etc. - man, we love a good story! Functional programming captures this mental system quite well, yes?

Still, I think you're right in assuming that programming style paradigms are developed in an attempt to make the architecture of a program better mirror the architecture we see in our heads. The more intuitive we can make the architecture, the better. I'm looking forward to seeing what others have to say on the academic basis for thinking that OOP is a better model of a human's way of thinking about things.
posted by vytae at 10:11 AM on November 21, 2007 [1 favorite]


All I know is OOP is easier to understand than the component based paradigm.
posted by zorro astor at 10:28 AM on November 21, 2007


Not to derail this askme, but I've always been curious about the relationship between social structure and OOP/unix permissions. It seems that the nature of having public/private variables, and individual/group permissions is based on a social structure in which private property exists. What would be a Marxist/socialist programming language/operating system be like, in which there is no distinction between public and private, no permissions?

To return to your question, perhaps you could think that a commodity-based society has trained our selves to understand the world in terms of objects, values, and trade, and that the well-held idea of monetary transactions between parties is similarly applicable to a value/variable/parameter transaction between classes/functions. Just a thought.
posted by suedehead at 11:10 AM on November 21, 2007


suedehead, I imagine it would be a whole lot like Wikipedia or UNIX booted into single-user mode. However, I think your assumption that Marxism and socialism fail to distinguish between public & private may be flawed ... people do after all "own" things like clothes, automobiles, homes, etc., in those societies, and I'm sure they'd have an interest in attaching their own names to files or directories.
posted by migurski at 12:06 PM on November 21, 2007


This is a fascinating question.

I think there are aspects of OOP that map very well onto our instincts and other aspects that don't.

If you're working with a built-in class (as opposed to a class you create), and if you're only working with its properties and methods, I think everything seems very natural. And my experience as a teacher backs this up. Students get it instantly.

For instance, Javascript has a buil-in Math object that doesn't have to be instanciated. Like a TV, you can use it out-of-the box.

So Math.round(5.3) seems very much like TV.changeChannel(36). Easy to use, understand and explain.

But THIS is odd (from the point of normal human experience):

myDisplay = new Display();

You can map this onto the idea of a recipe or blueprint (Display) being used to create a specific item (myDisplay), but this is a very idealized version of real-life creation.

First of all, in real life, most of us don't create things all the time. We generally use stuff that's already there. And when we do use a blueprint or guide, we don't clone it verbatim into an object. A blueprint for a house is something different from the house itself. Whereas an instantiation of a class is pretty much the same thing as the class.

Also, I think the event model used in most OOP systems in unnatural. Other than with magazines, cable tv and a few other contrived systems, we don't normally need to "subscribe" to be able to know if something has changed. We're not that consciously aware of what we're paying attention to and what we're not. And even if we're not subscribed to something, if it's loud enough, we'll become aware of it.

I'm not saying these unnatural qualities are bad. I just think they're particular to OOP more than they are to being human.
posted by grumblebee at 12:12 PM on November 21, 2007


Migurski, good call about ownership - you're right. And Wikipedia is an excellent, excellent example.
posted by suedehead at 12:21 PM on November 21, 2007


Check out the specifics of human vision, specifically how the representation of optical information progresses from V1 to V5. If I remember well enough from my cog. psych classes, it's optimized first towards points, then bounded objects, then moving bounded objects.

That doesn't imply that visualization always makes programming easier, only that OOP probably makes visualization easier.
posted by Laugh_track at 12:28 PM on November 21, 2007


It seems to me that encapsulation is a workaround for the limits of how much stuff we can hold in our heads at one time.
posted by callmejay at 1:21 PM on November 21, 2007


Best answer: Hah, I just read a cognitive science paper last night that explicitly compared the two. It was the first essay in this collection. You can hit the "search inside" button; the relevant section is on page 17.

Briefly: one of the debates in cognitive science concerns how modular the mind is. Modules are supposed to be encapsulated and inaccessible -- that is, they are black-boxed... other processes can't see in, they can't see anything except what they get as (domain-specific) inputs. Some people think that the brain is massively modular, and others think that the role of modules is relatively limited: much work is done by a general reasoning device. This black-boxing is similar to what goes on in OOP. I don't know if the analogy runs any deeper than that, however.

Another place to look might be work on pretense (simulation theory, psycholinguisitic work on pragmatic presuppositions, etc.).
posted by painquale at 2:23 PM on November 21, 2007


Two further thoughts on rereading your question:

1) I really doubt that human psychology is going to provide an argument for OOP. We know exactly how OOP works, but we have no idea how the mind works. Rather, OOP might inspire and eventually provide arguments for the architecture of the mind. (By the way, what would it mean for OOP to require an argument? For some tasks, it's appropriate, for others it's not. If we discovered that the human mind was "object-oriented", would or should that change the way that we code?)

2) I missed, on first reading, that this question was inspired because lines in object-oriented code are easier to attribute psychological states to than lines in non-object-oriented code. Logicpunk was right: Daniel Dennett is the person to read here. He thinks that, as you start decomposing the mind, you get various systems that you can attribute semi-psychological states to, and those can be decomposed into systems with demi-semi-psychological states, and those can be decomposed into hemi-demi-semi-psychological states, until you get to the extremely simple firing of neurons. It's pretty hierarchical. But off the top of my head, I can't think of anywhere that he discusses OOP specifically.
posted by painquale at 2:45 PM on November 21, 2007


On further review, this guy talks a lot about "Agent-Oriented Programming", and relates it both to OOP and Dennett - you can find stuff at his website and maybe also on Google Books.
posted by logicpunk at 3:06 PM on November 21, 2007


Just don't anthropomorphize your objects. They hate that!

This guy wants me to give him a pointer to an array of these guys, whatever! There's no guy. They're not people. They're arbitrary abstractions that may or may not map well onto the problem you're trying to solve.
posted by evariste at 3:35 PM on November 21, 2007 [1 favorite]


Best answer: I think you're going to want to read Brian Cantwell Smith's "On the Origin of Objects"
posted by zap rowsdower at 6:34 PM on November 21, 2007


You might also want to look into functional programming, which is basically the opposite. It can give you an interresting perspective, and you should find essays trying to defend one paradigm or the other which should give you more ideas.
posted by arnoooooo at 2:23 AM on November 22, 2007


« Older Telemarketing?   |   And her name was Polly Ann Newer »
This thread is closed to new comments.