Is OOP a branch to nowhere?

By | April 20, 2008, 10:26am PDT

Summary: No one would consider the COBOL MOVE statement to represent object oriented programming - but on close inspection it meets the criteria and that fact both undermines the entire basis for the OO religion and suggests a key reason the application of OO ideas to reality has so rarely been successful.

To continue the discussion about development languages, I want to ask a potentially embarrassing question: has the whole object orientation business been both a functional and a conceptual failure?

One of the odd things about the OO movement is that no two proponents understand it to mean the same things; but, in the abstract, the generic sales pitch comes in two parts. First is the conceptual part: if you build sufficiently general, sufficiently self-contained, and sufficiently flexible widgets that individually do something predictable to externally supplied data, then you can construct entire applications by using messaging to link these widgets into sequences without having to care about anything that’s internal to any of them. The second part consists of a list of desirable consequences including better overall application design control, the ability to assign multiple parallel work teams, easier debugging, and the benefits of widget re-use.

Imagine, however, what would happen to the claims of modernity and the one right way associated with the OO movement if it could be shown that something as archaic as the original 1957 COBOL MOVE statement and syntax meets the definition? If one could lay a reasonable foundation, in other words, for the proposition that OO has been all been about using new words to label old ideas? - and has, therefore, fundamentally amounted to little more than a chimeric branch to nowhere.

The argument for seeing MOVE as OO compliant is simple: MOVE completely abstracts a complex set of procedures; nicely encapsulates a series of data transforms; has an obvious class/object framework; clearly supports both inheritance and polymorphism (buy a new machine, apply an existing procedure); returns a result based entirely on external operands; is fully reusable; and, is completely non procedural in use.

Notice that the questionable part is messaging: object widgets are characterized by the ability to send, receive, and act on messages. MOVE receives messages as operands and acts on them without affecting external data, but arguably doesn’t send any because there’s no explicit returned value. Internally, however, it does: completion (with or without notification) is itself a message - explicit where a check register is set and implicit where it isn’t.

It sounds absurd, but it’s actually true. MOVE is a label for a set of working procedures developed during the early 1920s for transferring and verifying count totals from one tabulating machine or batch to another. In those days an application consisted of running multiple card batches on multiple machines in just the right sequence and some steps required the operator to copy the end of batch register readings on one machine to one or more start of batch registers on the same or another machine. Since people make mistakes, the procedures for this usually included error checks and since the process inherently required many steps it became known on process flow charts simply as MOVE (values from one or more registers, on one or more machines, to one or more registers, on one or more machine).

In those days, therefore, the MOVE procedure fit today’s class/object hierarchy because different machines had different attributes and thus required different methods to do the same things - and polymorphism because new machines usually combined new functionality with backwards compatibility - meaning that existing procedures worked but could often be usefully extended.

In those days managers wrote procedure sheets including MOVE instructions for clerks to act on - and today’s programmer does exactly the same thing: writing “MOVE XXX to YYY” in lieu of a long series of machine specific steps he doesn’t really care about.

Bottom line? Logically, MOVE is a classic OO widget - and if that sounds absurd, it’s only because this is 2007 and we see MOVE as a very low level operation - something that was not true for a 1925 IBM data processing manager dealing directly with clerks, cards, and tabulators to whom it appeared to be a high level instruction abstracting significant work procedures.

Personally, of course, I agree that this is absurd, but unfortunately it’s also right -meaning that the fundamental underpinnings for the OO movement simply don’t hold up - and consequentially that once you remove the hand waving, the mumbo jumbo, and the modeling religions invoked in any OO application what you have left is 1960s programming by functional decomposition.

And if you don’t know how that turned out, just look at any large scale OO project today.

Kick off your day with ZDNet's daily e-mail newsletter. It's the freshest tech news and opinion, served hot. Get it.

Topics

Paul Murphy (a pseudonym) is an IT consultant specializing in Unix and related technologies.

Disclosure

Paul Murphy

I do not work for, or otherwise receive anything from, any of the companies I write about. I have some money in a number of funds that bet on the markets, including the technology market, but have no direct control over how these funds are administered or what investments are made. I use Sun and Apple technology both at home and at work.

Biography

Paul Murphy

Originally a Math/Physics graduate who couldn't cut it in his own field, Paul Murphy (a pseudonym) became an IT consultant specializing in Unix and related technologies after a stint working for a DARPA contractor programming in Fortran and APL. Since then he's worked in both systems management and consulting for a range of employers including KPMG, the government of Alberta, and his own firm. In those roles he's "been there and done that" for just about every aspect of systems management and operation.

37
Comments

Join the conversation!

Just In

Goofed
Mark Miller 26th Apr 2008
The 2nd line of code should have read:

server := Webserver atURL: 'http://data.bls.gov/cgi-bin/srgate'.
0 Votes
+ -
I agree
croberts 20th Apr 2008
And furthermore, it is not self-evident that OOP is inherently more efficient than procedural programming.

Your decomposition implies that even the earliest OO concepts existed only as transitional elements in large complex procedural workspace.

At a machine-language level OO creates massive stack manipulations for even the most trivial programs.

And even syntactically, the constant need to add references to accomplish something trivial is somehow annoying.

Procedural: fart()
OO: Body.Intestine.Anus.Fart()

And at the end, is the quality of the code any better? Fundamentally, after all the religion, that should be the only measure that matters.

And in case there is a question, "quality" means "reliable and able to accomplish the intended task without error", not "more readable" as is the standard classroom definition.
0 Votes
+ -
It does have its good points though.
odubtaig 20th Apr 2008
Not so much in my experience with Java (which isn't much) but with C++ which really comes into its own for me when overloading overloaded operators. It's not necessarily that great for execution speed but it's usually designed more for development speed and being able to just say

a *= (b+5)/e;

with a bunch of objects makes things flow very nicely.

Sure, the actual result is going to look a lot like

a.operator*=(operator/((b.operator+(5)), e);

which is slightly abusing the stack, but for business applications no-one cares. Sometimes the cost of development outweighs to running costs.

Of course, I'm not sure that can't be avoided with some compiler optimisations which create temporary objects/variables for the returns so that the stack is more or less avoided. It'd make the program larger, but most speed optimisations do.

Not really my problem with OO languages though. My main problem with OO languages is they're so sodding difficult to teach. Not the languages mind, just the basic concepts. Most people who think C is harder than C++ have usually never written a class, are still fuzzy on what an object is, wouldn't know inheritance if it bit them and program very procedurally in the style that is sometimes referred to as C+.

Really, they're just too abstracted for most people to grasp easily. A language which reads like a straightforward list of instructions fits much more easily into the way people think.
0 Votes
+ -
to correct your argument...
Erik Engbrecht 20th Apr 2008
You defined the procedural version of fart() incorrectly. It
should be either:
fart(anus)
...assuming there are references on the anus struct to the
linked intestine and containing body, in which case you
need to be super-careful to maintain a valid data structure
representing the important parts of the body. Given that
you have no way to encapsulate that logic, you are
basically stuck either constantly checking the validity of
the structure or rolling dice with reliability.

If they aren't linked, it should be:
fart(body, intestine, anus)
...and now you have a check your arguments to ensure that
the specifed body, intestine, and anus all go together.
Either that or roll the dice...

What OO gives you is:
1. A means of defining contexts other than "procedure"
and "global."
2. A means of ensuring valid state
3. A means of (potentially constrained) runtime binding

Runtime binding in constrained by specified interfaces in
statically typed languages and unconstrained in
dynamically typed languages.

There are ways to achieve these three elements other than
OO, and indeed languages exist that do. But languages
like C don't provide them.

OO gets a bad rap because #1 is basically taken for
granted, #2 is systematically ignored (damn JavaBeans),
and #3 turned out to not be as much as it's cracked out to
be, because people are bad at making reusable
components - good theory, bad practice.
0 Votes
+ -
There is no guarantee of "efficiency" in either OOP or functional programming. It all depends on the skills of a programmer and the quality of his work.

Although there is no guarantee for anything, there is two things that OOP excels over any functional language: reusability and maintainability. Good object oriented code is more reusable than any functional code. By having more reusability, that makes maintainability less troublesome. You fix errors in one place, instead of many.

But OOP can also create problems, when the developer insist on using "features" that add unnecessary overhead and complicate the designs. Not all OOP features are acceptable for all jobs. In projects where speed and memory footprint is important, developers should avoid using exceptions and minimize dynamic allocation.

Also, OOP is not right for all jobs. There are some things that can only be develop with functional code, because the overhead of the OO language is too much for the job.
0 Votes
+ -
procedural vs functional
Erik Engbrecht 21st Apr 2008
I don't believe we're discussing functional languages (e.g. Haskell, OCaml, Lisp, Scala, etc) relative OO languages (e.g. Java, C++, OCaml, Lisp, Scala, etc). We're discussing procedural languages (C, Pascal w/o OO extensions, etc) versus OO languages.
0 Votes
+ -
correction
super_J 21st Apr 2008
"Procedural: fart()
OO: Body.Intestine.Anus.Fart()"

But with the OO example, you can eliminate that long dot-notated string to get to the Fart() method by using an Import (or in C# Using) statement at the top of the class file, like so ...

Import Body.Intestine.Anus.*;

Public Class BodilyFunctions(){
public DoFart(){
Fart();
}
}

And since in this example I included the .* after the Anus, all of the methods and fields of the Anus library are available, such as

Poop()
ReceiveTissueWiping()
GoDiarrhea()
ReceiveColonoscopy()

... etc
0 Votes
+ -
OOP was a branch to somewhere!
fr0thy2 20th Apr 2008
I'd say that the paradigm of "web/Saas/Internet" overcomes/changes much of it. We're heading towards an _almost_ protocol (messaging) based way of doing things - perhaps a tilt towards the Erlang way of doing things (eek!).

We need objects. We need procedural. We need messages.

Picture the old text adventure games....

What now? Draw chart
You cannot draw a chart now.

What now? Take summary of financial performance
Summary of financial performance taken.

What now? Draw chart
I don't know how to draw a chart here.

What now? Take charting module
Charting module taken.

What now? Draw chart
I don't know what a chart is

What now? Draw my fcuking chart will you, you fcuking bsatard computer
I don't understand

What now? Draw summary of financial performance chart
Ok.

================================================

Something along those lines anyway wink
0 Votes
+ -
Looking to deep
storm14k 20th Apr 2008
As with alot of things I believe people look too deeply into a subject. OOP was not sold to me as the savior of all things code and I never looked at it in that way. Its simply a way of organizing things. It probably creates more overhead for both development and execution and it certainly does not miraculously produce better code. However it does allow a team of developers to divide up work and concentrate on implementing their own piece while trusting that calls to their teammates piece will work without knowledge of how. I believe the "black box" principle is its greatest strength. It also allows for easier debugging as you can track bugs down to separate components and their interactions.

Procedural coding has its benefits as well but I definitely would not go back to that wholesale. I will say though that the combination of OOP and "Intellidummy" code completion are breeding poor developers that just type a word and hit "." to see what the IDE will suggest. The "black box" isn't good when you look over all the low level stuff and don't truly understand whats happening underneath.
0 Votes
+ -
Another, more annoying, way to phrase it is "Copy/Paste" without knowing what is being Copied.

Accepting the tool's structure can be like a requirement that business processes change in order to use the software efficiently.

At least with Windows et al when you point at something and click on it, there seem fewer degrees of separation beween you and the clicked upon. wink
0 Votes
+ -
speaking from experience
zzz333 21st Apr 2008
Just a set of minor things in C++ allows for a much bigger projects than its C equivalents:

1. Just plain isolation of public and private interface at compile time goes a very long way toward writing more maintainable/modifiable code.

2. Constructors and destructors add yet another order of magnitude towards the max size of maintainable code.

3. Auto initialization of the components through static constructors helps a lot too.

IMHO, C++ allows at least two orders of magnitude in max maintainable size of the application.
0 Votes
+ -
RE: An oop or an oops?
murph_z 20th Apr 2008
This blog was scheduled to appear tomorrow morning at 12:15 AM PST - obviously it didn't. So...

My oop(s)?
zdnet's oops oriented ops?

Zoom! (as in David Brin, not as in somebody's car ads).
0 Votes
+ -
OOP is a means of expression
T1Oracle 20th Apr 2008
The most important part of software development is not writing code that a computer can understand, that part is easy. The important part is code that humans can understand. OOP helps individuals other than the original developer to reach the same understandings about how a given system works.

This communication may not always work perfectly, but OOP allows us to describe things with a higher level of abstraction. This abstraction lends better to describing the big picture than details oriented procedural code.

OOP does not allow us to make anything that wasn't possible before, but it does give us yet another often more descriptive way of expressing it.

Furthermore, the better human beings understand the code, the more likely they are to develop something more complex and advanced.

OOP has given us expression, expression gives us understanding, and understanding increases our potential to create more advanced systems.
0 Votes
+ -
Maintainability is always important
wackoae 20th Apr 2008
OOP provide better options to improve the maintainability of a product, but it does not guarantee it. It all depends on the skills of a developer and the quality of his work.
0 Votes
+ -
Good post!
DevGuy_z 21st Apr 2008
NT
0 Votes
+ -
Sort of algebraic logic
Anton Philidor 21st Apr 2008
Someone else has made this observation in another post here, but a significant number of people have difficulty with the sort of logic that substitutes symbols for values. If that's not a problem for someone, the first time observed in an algebra class can be startling.

And the greater abstraction brings people closer to a diagrammatic overview of the logic. That, too, can be uncomfortable. The use of examples in an explanation is often a way to change the aspect.

As with all computer languages, the interaction is at least as important as the action.
0 Votes
+ -
OOP is mostly about organization.
CobraA1 20th Apr 2008
OOP is mostly about organization.

"First is the conceptual part: if you build sufficiently general, sufficiently self-contained, and sufficiently flexible widgets that individually do something predictable to externally supplied data, then you can construct entire applications by using messaging to link these widgets into sequences without having to care about anything that?s internal to any of them."

Yeah, this is the theoretical "let's push these concepts to the limits" view of OOP.

From a more practical standpoint, it's just a way of organizing code. Instead of one huge, monolithic, hard to maintain structure, you've got everything wrapped up in easy to use (and hopefully reuse) pieces. Then you can make large scale changes to the software with little difficulty.

COBOL is a good example of a language designed specifically with certain needs in mind, and it does some things very well. If I remember correctly, its primary purpose is essentially to perform large batch transactions on records.

Of course, not all software will serve that purpose, so COBOL is not suited to everything. In fact, no language really suits itself to all purposes. OOP is great for some things, functional languages are great for some things, and so on and so forth. It's just a matter of choosing the right tool for the job.

I don't think OOP is a branch to nowhere. It's actually quite useful.
0 Votes
+ -
Nailed it. Good post!
DevGuy_z 21st Apr 2008
Very good post. Only a developer with experience would understand this!
0 Votes
+ -
The error is in the title.
TheTruthisOutThere@... 21st Apr 2008
Programming paradigms are not a destination, but a means to get us to our desired destination. Don't make the tools more important than the things we are building with them

As with the discussion about Java, if you view one paradigm as "the one true" way, you're asking for trouble.

Anyway, if you don't like OOP, Murph, what is your preferred paradigm?

(And if you like the idea of multi-paradigm tools, try to put your revulsion of .Net to one side and have a look at F#. As it supports functional programming, it's use in building apps that scale across multiple cores is interesting.)
0 Votes
+ -
...or OCaml
Erik Engbrecht 21st Apr 2008
...if you don't want to taint yourself too much with .NET. Although I personally prefer Scala's merger of OO and functional (Scala compiles for both JVM and CLR, but the majority of the community uses the JVM).
0 Votes
+ -
RE: Is OOP a branch to nowhere?
DevGuy_z 21st Apr 2008
In the early days of OOP there was a lot of hype. No one really talks about re-use anymore.

The main thing OOP give is a way to achieve high cohesion (does one main thing) and low coupling (as independent of other code as possible). By binding data and function to produce a self-contained thingy. We now have a way to express things in a more organized way and achieve this goal. I'm not saying that this cannot be achieved with a non-OO language but you have to work at it much harder. OO makes it easier.

IOW, OOP is all about dealing with complexity. High level languages make development easier but in the end it ends up machine code. OOP makes it easier to organize complexity such that it can be handled by our finite minds.

BTW it is easy to confuse OOP which is code related with components which are binaries. In our development world we don't see a whole lot of code re-use but we make extensive re-use of binary components, in our case COM/ActiveX components. Widgets are another example
0 Votes
+ -
Agreed.
TheTruthisOutThere@... 21st Apr 2008
I just get some kind of unhealthy pleasure suggesting Microsoft solutions to Murph.
0 Votes
+ -
he deserves it...
Erik Engbrecht 21st Apr 2008
...and I think MS deserves props for their language research efforts. So does Sun, although MS seems better as converting it into useful products. Hegemony does have its advantages.

What I'm wondering is: Where are HP and IBM in the programming language research game?

I think programming language research is the most important area of research for the long-term advancement of technology. It seems odd that two such huge players, for whom the research would barely even be noticeable in their financials, would seem so absent from it.
0 Votes
+ -
Mass market
Anton Philidor 21st Apr 2008
What are IBM and HP selling? Expertise.

What is a major goal of language research? Ease of use, less need for expertise.

Corporations rarely make efforts likely to diminish rather than increase their potential markets. So this seems a reasonable conjecture.
0 Votes
+ -
Wisdom of the ages
Yagotta B. Kidding 21st Apr 2008
"You can write a FORTRAN program in any language"

As I learned back when OOP was first getting academic attention, it's a methodology. When first exposed to the name, I'd been doing object-oriented programming for years (in assembler, no less!)

Since then, language designers have been adding support for OOP to various languages with varying success (note that C++ suffers from horrible baggage.)

So there's nothing new about the observation that it's possible to write an object-oriented program in COBOL. I suspect that by now many have.
0 Votes
+ -
Why do you hate reuse?
Erik Engbrecht 21st Apr 2008
First you rail against all the software reuse that happens in the enterprise Java world in the form of frameworks and libraries.

Now you rail against OO for enabling such software reuse.

...or...wait...you said OO failed to enable reuse.
0 Votes
+ -
Reuse? what reuse?
murph_z 21st Apr 2008
I'd love to see effective re-use. However...

1 - I know lots of people who consistently re-use their own code. This produces eight line C programs that have 200 lines of includes - none of which can be understood or debugged by anyone else.

2 - java re-use is both often practiced and impractical. What happens in large corps is that the mandatory frameworks take longer to learn than anything else and then turn out to be not quite right for what you need - so you add a tiny bit. WHich the next guy never learns about until it trashes his bit of the application and he spends a month finding it.

So yes, java frameworks often let you avoid re-inventing the wheel, but re-inventing the wheel is often faster and safer than finding the existing wheel.

3 - Any use of a standard lib is re-use - as is any use of a single 2nd generation or higher (remember: generation refers to compiler steps, not ancestry) language. So the real question is when to stop: i.e. at what level re-use makes sense.

The mess pretending to be Java in most big bus environments is what you get when you apply OOP re-use ideas at impractical levels.

So no, I don't hate re-use (although I do believe in throw-away code) but I don't think OOP (and thus Java) have it working right.
0 Votes
+ -
Conflating Issues
Erik Engbrecht 21st Apr 2008
You're judging an entire class of technologies to be a failure because organizational incompetence leads to non-sensical architectures woven together in an ad-hoc manner.

If this were a technology you "liked," you'd be ranting about how organizations screw it up - i.e. MSCEs doing a Unix deployment.
0 Votes
+ -
LOL - ya, probably (NT)
murph_z 21st Apr 2008
happy
0 Votes
+ -
Murph said....
bportlock 21st Apr 2008
"I don't hate re-use (although I do believe in throw-away code)"

Just as well, because the alternative of reinventing the wheel over and over and over and...... (repeat ad infinitum) is just plain dumb.


" but I don't think OOP (and thus Java) have it working right."

OOP has it working fine, you just don't understand it well enough. And reflect on this, if COBOL has OOP features it doesn't mean OOP is bad, it means that COBOL was very well designed and implemented. Who knows, that might even explain the phenomenal success of COBOL.


"The mess pretending to be Java in most big bus environments is what you get when you apply OOP re-use ideas at impractical levels."

No - this is the mess you get when someone over-complicates a solution and it is as possible in C as in C++/Java/Erlang/Smalltalk/etc. Any code in any language can be messed up beyond maintainability and if you doubt that then just look at the tons of unmaintainable C, Perl, Assembler and Basic code out there. All non-OOP and just as messed up as any other comp sci language.
The problem isn't reinventing the wheel. It's that the base class Wheel won't do for every instance of wheel everyone needs. Every car manufacturer can inherit Wheel, but the customisation of Wheel for all the various necessary instances is a whole lot bigger than Wheel itself. So where's the savings in reusing Wheel?

That's the Catch-22 of OO: the only things worth reusing are big, complicated, objects that are hard to write from scratch, but big, complicated, objects generally don't customise well or are made even bigger and more complicated, hence more fragile and harder to maintain, by supporting a lot of different capabilities.

OO is one of those CompSci utopian ideas that sound great in the research papers but rarely meet the hype.
0 Votes
+ -
That's not the purpose of OO
Erik Engbrecht 21st Apr 2008
The purpose of "Wheel" and its abstract subclasses, is to be able to create code that can generically deal with Wheels, not to provide all sorts of reusable machinery associated with wheels.

So, for example, I can have a "WheelBalancer" and "WheelAligner" that will work with any wheel, and so that I can connect multiple types of Wheels to the same car.

The interface is more important than the implementation. Implementation can usually be more effectively reused through composition than inheritance.
0 Votes
+ -
So many levels of wrong.
odubtaig 22nd Apr 2008
I don't think I've ever come across 200 includes in anything, if only because hierarchical includes should mean you have a small number of header files including other header files as necessary.

If someone manages to have that many includes (assuming you're not exaggerating for emphasis) then they're possibly the worlds worst developer. That's just plain inability to structure the code.

As for the second part. On of the core points of OO languages is that the class code may change but the interface must remain the same. If you want to change the interface, use inheritance. If you want to change it in such a way that it relies on something only your dept has access to or replace a method, use inheritance. Either way, if you do something in an OO language that breaks something for someone else, you're doing it wrong.
0 Votes
+ -
Good troll
parasubvert 21st Apr 2008
I feel like I'm in a time warp and it's 1996 again.

"... consequentially that once you remove the hand waving, the mumbo jumbo, and the modeling religions invoked in any OO application what you have left is 1960s programming by functional decomposition. And if you don???t know how that turned out, just look at any large scale OO project today."

I've worked on crappy OO projects, good OO projects, and projects built around functional decomposition. They're three different ways of thinking about things, and result in three different sorts of designs.

OO isn't about functional decomposition, it's about responsibility decomposition. That's not hand waving.

OO certainly isn't the end of history with regards to software devleopment mindsets, but I'm curious what your alternative would be. My sense is that the future alternatives may be pro-OO, anti-OO, likely cannot be "non-OO".
It is quite amazing when you write a C program and it compiles into a tiny executable with massive functionality that runs at lightning speed.
If you know how the compiler works (you can learn by reading the assembler source it produces), you can really make it fly.
(especially if you look hard at the casting in your code). You can also rewrite some library routines to be less functional and smaller (like printf for example).

Typically C++ libraries are fatter, so when you inherit from them, your classes end up making a bigger payload in memory.

There was a recent metric that .Net/Java runtimes are 200 times slower than traditional compiled results. Of course you can't really say that about Java itself, because you can compile java native using Excelsior Jet, or gcj. gcj runs pretty darned fast too.

I think that .net/jvm typically run time compile to native machine code on class load time (and on fancier JVMs the machine code is cached), so for internet servers and so on, Java can run pretty close to the speed of C (at least in theory).

It is interesting that most programs written for Puppy linux are written in C.
This did use to be the distinction between KDE and Gnome as well (and Gnome - the C one, seems to run faster than KDE - the C++ one).

I think bad coders can murder any language though, but also that the speed of current machines is very forgiving. (perhaps that's a bad thing overall).

I like the idea of a tool that can discover unbound pointers and things rather than a full JVM style solution.

You can implement any design pattern in either language, so it's really a moot thing overall.

C++ libraries tend to be much richer (which is why they are fatter).

Personally I love the way you can take a C/C++ program, wrap it in SWIG and then use it in Python or whatever. amazing.
It's such a long time since I first saw this now, and yet I still think it's very very cool.

So you could do your fast dirty work in C or C++, and have a pluggable glue layer where Python gives an easily customisable interface between the parts.
0 Votes
+ -
Oh god not again
tonymcs@... 21st Apr 2008
Recycling again Murph? We've been through this before.

The fact that you can't really understand OO or write it, I think disqualifies you from an opinion. I went from old style to new style in the 90s and I can only say the benefits have been immense. Do I want my projects without classes ans objects - not any more.

Keep your slide rule and 8 track cartridges and your vinyl records Murph and your little programming skill as well, because while they may be useful in the museum, they have little use in the real world.
0 Votes
+ -
OOP has been compromised
Mark Miller 25th Apr 2008
Darn, wish I had found this topic earlier. Now nobody's going to read this. Maybe Murph will.

OOP has been a mixed bag, but I say this only because like with the PC, a lot of the vision was lost (others can read here: http://blogs.zdnet.com/Murphy/?p=1088). As you probably know, Murph, I've been studying the ideas of Alan Kay, and he was probably the earliest evangelizer of what's come to be called OOP. He invented the term, so this is a safe bet. The thing is if you want to find out what his original vision was you still basically have to read up on Kay, because only a relative few really got it. The OOP evangelism you've heard is likely some bastardized version of the original vision. I just got done reading "The Early History of Smalltalk" (at http://www.smalltalk.org/smalltalk/TheEarlyHistoryOfSmalltalk_Abstract.html) written by Kay, and it gives you an idea of how he came up with the ideas in OOP, and what he intended to accomplish with it.

He wanted to create a "live" system, one where objects existed all the time in a system environment. In a speech Kay gave in 1997 he likened objects in such a system to processes in Unix. When I looked at it, it actually does kind of bear out. If you look at Squeak, or just about any Smalltalk system you'll see what I mean.

Kay wanted to create a tight coupling between code and data, and avoid the situation you have in most software today, which is code acting on data. By "code acting on data" he meant that you have code, and then in some other separate memory store you have data. You have data structures to optimize access to the data. Your code manipulates the data in the separate store.

In his scheme of OOP no data, as we know it, exists. Instead every representation of information is an object. What this means is that every piece of information has meta-information as well. In addition, every object has certain things it knows how to do, either with itself, or in conjunction with other objects.

A simple expression, like 2 + 2, is in fact a method call in Smalltalk, and an example of co-operation between objects using message passing. It's not like in C++ where it treats this like a scalar addition. The way it works is the system looks for "+" in 2's (really SmallInteger's) table of messages it can receive. "2" (SmallInteger) is an object. It finds "+", and then executes its corresponding method, which receives the other "2" (again a SmallInteger object) as an argument. The operation in this case is executed as what's called a "primitive" (ie. it's implemented and optimized in the VM).

The second pillar of Kay's vision was, as you correctly identified, message passing. Every object can send and receive messages. I think however your conception of OOP has been colored by languages like C++. You said first of all that data values were messages to MOVE. The mistake you made is that in MOVE the data that's passed to it is just that, data, not other objects with the same qualities that MOVE has. This waters down the concept of message passing in OOP. The vision Kay had was that objects would communicate and co-operate with each other using messages. Nothing exists that's just data.

Most systems today, however, even ones developed using OOP, don't use this scheme, so the vision has become compromised via. the data processing mindset.

I think what you're saying is understandable. You see how it's used and say to yourself, "This looks like data processing", and indeed it is. The reason you see this though is not because of OOP, but because this is the way people think it has to be done: Data must be separated from code. Data must be processed. Yet there's confusion, because you have this schizophrenic thing going on in OOP practice where for brief periods of time data and code are tightly coupled in business objects. So I can see why one would have the reaction, "What's the point of having objects? You're really just fooling yourself," because we kind of are. We use OOP to manage the complexity of the business computing model, and the data interactions, but we're not using its full power. We're doing data processing with "OOP glasses on" to pretend we're doing something different than we did before. I'd like to think we're getting efficiencies out of it, though from your tone I suspect you think not. This wouldn't surprise me. I've heard complaints from fellow developers that most programmers today don't understand OOP concepts, and so their code in OOP languages is crap. I think the way OOP is implemented now is an improvement (I'm thinking of .Net here, not Java) over the way things were done before with C and C++, but it's a conservative baby step. I like the idea of Linq in .Net, but it'd be nice if they'd allow programmers to make their own DSLs more easily. I haven't experienced the 4GL's you've talked about, so I have no way to compare this with them.

I've mentioned this to you before, Murph. If you want to see a system that really tries to be object-oriented (as much as possible) I'd encourage you to take a look at Gemstone. Disclaimer: I do not work for them, and am in no way compensated by them for saying this.

Let me give you a glimpse of the kind of power that Kay was talking about with message passing, because I think it'll show you what a lot of people are missing. One of the principles that Kay talked about with OOP is that each object is in essence a computer in software. So, as we are used to with computers, objects can emulate anything we want. When looked at this way, OOP as Kay envisioned it begins to resemble the internet a little bit: computers passing messages to each other.

In Smalltalk you can take advantage of a feature of all objects that traps an exception called "doesNotUnderstand" ("DNU" for short). What this stands for is "I looked up the message you sent in the object's list of pre-defined messages and I couldn't find it." The default implementation is to show an error dialog to the programmer to this effect. You can set up the class for your objects to override the default implementation of DNU to set up your own message parsing. The example I'll show is based on something Alan Kay said about objects on the internet in his speech, "The Computer Revolution Hasn't Happened Yet", from 1997.

What I'll create is a proxy object for a web server. I define a class called Webserver that has a couple methods:

atURL - This instantiates a new Webserver object, which internally points to a real web server represented by the URL that is passed in. It's basically a constructor.

doesNotUnderstand - I implement this to implicitly pick up any messages I want to pass to the server, and return the response I get from it, which is a MimeDocument object. Parameters are automatically marshalled to strings for the purpose of being compatible with the CGI protocol.

Rather than setting up a situation where I'm forming a CGI string explicitly in my application code, opening an http connection with a web server through an API call, and making an API call to post the string to the server, I do this:

| server document |
server := Webserver atAddress: 'http://data.bls.gov/cgi-bin/srgate'.
document := server format: #block html_tables: #no catalog: #no delimiter: #tab print_line_length: 400 level: 1 series_id: 'CES0000000001' year: '2001-2008'.

The parameters with hashes in front of them are symbols. The parameters format:, html_tables:, catalog:, etc. and their corresponding values all represent CGI parameters, both in name and value, that are passed to the web server, as such: "http://data.bls.gov/cgi-bin/srgate?format=block&html_tables=no&catalog=no...". Get the idea? You can think of the web server as an object on a network, represented by the URL (think of it as an object reference). The message I'm passing to the (web server) object is represented by my (CGI) parameters. So I have mapped OO message passing to the message passing that's used in a web protocol. This is no setup either. I haven't defined a method that explicitly takes these parameters. The parameters in the message passed to "server" can be anything (both the parameter names and values), because the server object automatically parses them, forms them into CGI strings and sends them to the server. I am communicating with the server inside my own program without the cognitive dissonance of having to jump through hoops to do it. Also notice that I can use whatever types of objects I think best represent the information I'm passing to the server.

This is an example of OOP at its essence, but I challenge anyone to try implementing this same scheme with any of the popular OO languages out there today. You might be able to pull it off, but I think you will have made yourself a little balder in the effort. Have a nice day...
0 Votes
+ -
Goofed
Mark Miller 26th Apr 2008
The 2nd line of code should have read:

server := Webserver atURL: 'http://data.bls.gov/cgi-bin/srgate'.

Join the conversation!

Formatting +
BB Codes - Note: HTML is not supported in forums
  • [b] Bold [/b]
  • [i] Italic [/i]
  • [u] Underline [/u]
  • [s] Strikethrough [/s]
  • [q] "Quote" [/q]
  • [ol][*] 1. Ordered List [/ol]
  • [ul][*] · Unordered List [/ul]
  • [pre] Preformat [/pre]
  • [quote] "Blockquote" [/quote]
ie8 fix

The best of ZDNet, delivered

ZDNet Newsletters

Get the best of ZDNet delivered straight to your inbox

Facebook Activity

White Papers, Webcasts, & Resources
ie8 fix