Exploring the world of software development, technology, data science, and life

Musings of an Object Oriented Apostate

Like probably most software developers of my generation, I was taught from the very beginning of my education that Object Oriented Programming is the ideal programming paradigm for any significantly large application.  C++ was the first language I learned way back in high school (well, not counting the TI-Basic language on my TI-82 calculator), so OOP has been there from the start.  In college there was an comparative languages class that discussed different programming paradigms, but since I had already been convinced of the superiority of object oriented languages like Java I opted to take the numerical methods class instead.  I was a full fledged member of the Church of Object Oriented Programming.

Now here I am, a little six years out of school, and seriously questioning the faith.  The one thing that probably began my conversion was concurrency.  No, I don’t mean the type of concurrency needed for parallelized applications running on the massive multi-core systems we have been promised that will push out Moore’s law for another decade or so.  I mean the type of concurrency needed for any system operating with multiple threads.  The issues surrounding concurrency in OOP have been discussed many times before, so I won’t go over them here.  But since I’ve began playing with functional languages such as Clojure and Erlang, not only have I found concurrent programming easier, but many aspects of program design that would have been awkward in the OO world now seem, well, easy.  If you are like I was just a few years ago you might scoff at that idea (I know I would have).  I really don’t have a irrefutable argument that is guaranteed to convince you of this, but my best advice would be to try it yourself if you are not convinced.

Steve Yegge’s Kingdom of Nouns essay painted a good (and humorous at times) picture of why the functional abstraction is advantageous over the pure object oriented abstraction.  But even after reading that essay, part of me still felt that an object model, while maybe not the most accurate way to model software, was still the most natural.  When I looked at the world, for instance, I tend to see objects first, not actions.  I see a bird flying.  I see a traffic sign in front of me.  I see a car whose driver is honking at me.  Ok, maybe while driving to work is not the best place to contemplate the advantages of different programming paradigms.  But the fact remains, when I model the real world, I start with the objects.  Its only natural to feel a desire to do the same with software.

But then something occurred to me.  That may be how I internally model the real world around me, but it is certainly not the frame of mind I am in when I interact with it.  When I’m on the on ramp to the highway, I think “Step on the gas pedal”, or at a higher abstraction level, “Speed up“.  If the car in front of me suddenly stops, I think “Step on the break pedal”, or “Stop“.  At least if enough of my brain is still paying attention to the traffic and not thinking about computer programming, of course.  When I’m viewing the world I may think in objects first, but when interacting with it, the verbs get my attention.  Maybe that’s why OOP does such a good job at creating intricate UML diagrams, but fails so miserably when it comes to actually writing software that does something.

Now I brought this analogy up in a Java mailing list once, and almost immediately I had people responding saying I was modeling (that word again) it wrong.  I wasn’t thinking “Step on the gas pedal”, I was really thinking “Right foot, step on the gas pedal”.  Well, let me assure you, that’s not how I think.  Certainly you can model it that way, I never said there was not an object in play.  It just does not have my complete focus.  To be honest, I don’t really care what it is that steps on the gas pedal, I just want something to do it.  My right foot is just the part of my body that has been accustomed to being in charge of the gas and break pedals due to the configuration of modern automobiles. Now you can argue that some people, who having been brought up on OOP and who are still devout followers, may have a view of reality in which they really do think in terms of objects first, and thus when performing an action they mentally must first identify what it is that will perform that action.  Thats just not how I think, and I strongly suspect is not how most people naturally think.

Leave a Reply

Your email address will not be published. Required fields are marked *