Articles Comments

Boobs And Books » Computing, Language » What is Object Oriented Programming: It’s Not What You Think, It’s What You Think

What is Object Oriented Programming: It’s Not What You Think, It’s What You Think

getStringFromObj Thong
Photo courtesy of Martin Ng

Object oriented software has no bugs, has an infinite shelf life, and cures cancer…at least according to the marketing people.  Hey, they have to sell the shit you programmers write, so don’t judge.  And you programmers need them more than they need you.  They can always go sell SPAM.  That also has no bugs, has an infinite shelf life, and cures cancer.  What?  Not true you say?  You see, that’s the difference between marketers and programmers: programmers seek truth, while marketers make truth.

What is Object Oriented Programming?

Object oriented programming (or OOP) is a programming paradigm in which software is viewed as a bunch of interacting objects and is the dominant paradigm today.  The previous dominant paradigm was procedural programming, in which software is viewed linearly as a set of instructions.

A Brief History

Dinosaur computerBack when the dinosaurs were programming, they didn’t have any fancy paradigms to follow.  They wrote what is known as spaghetti code, which is highly error prone and unstable. Although scientists will tell you that a giant meteor killed them all, it was really the stress of managing all that spaghetti.  (There are other theories too.) They died of many stress related diseases such as heart attacks, brain aneurysms, and depression.  Some fossils even show dinosaurs that just dropped dead, head on their keyboard.  We can imagine that the ceaseless beeping this caused must have killed off the rest of their cube mates.

But there is a happy ending to this story.  One of the many bugs happened to creep into the dinosaurs’ gene replicator, and one of the dinosaurs gave birth to the first human programmer!  A descendant of this programmer would go on to invent OOP.

Objects Are In the Eye of the Beholder

In Nicklaus Wirth‘s paper, Good Ideas Through the Looking Glass, he writes of OOP:

“This paradigm closely reflects the structure of systems ‘in the real world’, and it is therefore well suited to model complex systems with complex behaviours.”

We have a human tendency to project our perception of things onto the things themselves (Wirth’s intention is unclear, but that might be the reason he put “in the real world” in quotes).   We do it all the time, without thinking about it.   Consider the sentence, “The apple is red.”  No, the apple is not red.   There is no “redness” about the apple at all.   If you look at the molecular structure of the apple, there are no “redness molecules”.

The skin of the apple has a certain molecular and physical structure such that it absorbs certain wavelengths of light and reflects others, so that light coming from the apple enters our eye and we experience that wavelength of light as colour.   To drive home the point that colour is an experience and not a property of the external world, we need to look no further than a rare genetic mutation that causes people to associate not only wavelengths of light with colour, but also letters or numbers.

Likewise, the world is not composed of objects.  The world is composed of atoms, molecules, subatomic particles, radiation, dark matter, dark energy and other weird things that are stuck together in complex ways.  There are no definite “objects” in the world.   We are the ones who impose the object concept on the mish-mashy Universe because those categorizations are useful to us.  A rock is mostly empty space, but we do not see the empty space.   We see a rock as a solid object because it effectively acts as a solid object to us and seeing it (modelling it) as a solid object is useful to our survival — our poor extinct cousins who saw rocks as mostly empty space didn’t last very long.

OOP does not closely reflect the structure of systems in the real world; it closely reflects our brain’s model of the real world.

OOP and the Human Brain

The Stuff of ThoughtOOP does not make a powerful tool because it is somehow intrinsically superior to a procedural paradigm or any other programming paradigm.  The machine that runs the code doesn’t care how the program was written.  Instead, OOP is powerful because it helps our puny brain understand complex systems.  And it actually fits our brain like a glove.

As it turns out, our brains are metaphor machines, and we do it so naturally that we sometimes take our metaphors to be literal — that is, until the metaphor clashes with the literal meaning in spectacular fashion.  Stephen Pinker in The Stuff of Thought, writes:

The opacity of everyday metaphors is also apparent in inadvertently tasteless expressions (such as the radio psychotherapist who said, “For some patients, cancer can be a growth experience”), ambiguous headlines (Chef Throws His Heart Into Helping Feed Needy), Goldwynisms (“an oral agreement isn’t worth the paper it’s written on”), and entry into the club called AWFUL – Americans Who Figuratively Use “Literally.”

The metaphors we use are so engrained in our brain that we find it difficult to think in terms of metaphors that originate in other people and other cultures.  For most of the world, going “forward” in time means going into the future and going “backward” in time means going into the past.  In the Aymara language, the metaphor is reversed.  When they say “going back in time”, they actually mean going into the future.  It may seem bizarre, but their metaphor makes a lot of sense.  Begin by imagining you are standing still.  You can see everything in front of you, just like we can see clearly everything that happened in the past (hind sight is 20/20, right?).  You can’t see anything behind you, just like the unknown future.  As you walk backwards, more of that future (that was behind you) comes into view.

Pinker also surmises that the happy mutations that allowed our brains to evolve a metaphor ability is what makes us humans so smart.  With metaphor, we are able to co-opt old solutions to old problems and use them to solve other isomorphic problems.

If all abstract thought is metaphorical, and all metaphors are assembled out of biologically basic concepts, then we would have an explanation for the evolution of human intelligence.  Human intelligence would be a product of metaphor and combinatorics.  Metaphor allows the mind to use a few basic ideas – substance, location, force, goal – to understand more abstract domains.  Combinatorics allows a  finite set of simple ideas to give rise to an infinite set of complex ones.

Indeed, an example of this ability can be found in our use of design patterns.

OOP is a Means to…What End?

When writing software, different people will choose different metaphors because each of us has had different experiences and have different cultural backgrounds — an Aymarian programmer might write a method Timer.windClockBack() to mean “wind the clock into the future”.  When we collaborate on projects, we learn about each other’s metaphors which, in a sense, is a form of cultural exchange.  So while OOP was conceived for us to better understand our software, the real prize may be that it helps us better understand each other.

Filed under: Computing, Language · Tags: , , , , , , ,

Leave a Reply

*