Slashdot Mirror


Anthropomorphism and Object Oriented Programming

An anonymous reader writes: We've all been warned about how anthropomorphizing animals and machines can lead us astray. But Edsger Dijkstra once cautioned (PDF) developers against thinking of their programs that way as well. "I think anthropomorphism is worst of all. I have now seen programs 'trying to do things,' 'wanting to do things,' 'believing things to be true,' 'knowing things' etc. Don't be so naive as to believe that this use of language is harmless. It invites the programmer to identify himself with the execution of the program and almost forces upon him the use of operational semantics." A new article fleshes out Dijkstra's statement, providing a good example of where an anthropomorphized analogy for Object Oriented Programming breaks down when you push it too far.

22 of 303 comments (clear)

  1. Strawman by Anonymous Coward · · Score: 5, Insightful

    Dijkstra spends time building an analogy, then explains how it's flawed, and uses that to argue against 'anthropomorphizing'.

    That's nice, and I certainly agree that the analogy can only go so far, but he was the one to build that analogy in the first place. This is not a valid argument against anthropomorphizing at all.
    I do agree with the conclusion that anthropomorphising is not a reason to call OOP better than procedural.
    ---
    "I don't know how many of you have ever met Dijkstra, but you probably know that arrogance in computer science is measured in nano-Dijkstras"

  2. Summarizing by ofranja · · Score: 5, Funny

    Object oriented programming, the "crystal healing therapy" of computer science.

    --
    EOF
    1. Re:Summarizing by NoNonAlphaCharsHere · · Score: 5, Funny

      Don't anthromorphize your objects. They don't like that.

  3. Procedural vs OO by NoNonAlphaCharsHere · · Score: 5, Funny

    I used to have a procedural toaster which cooked the bread until it became toast. Then I upgraded to a much more elegant OO toaster, which simply sends a "toast yourself" message to the bread. Unfortunately, bagels don't have a self.toast() method, so i still have to have a backup procedural toaster to handle the older API.

    1. Re:Procedural vs OO by quenda · · Score: 4, Funny

      Hardware analogies are fraught with peril but ...
      the object-oriented toaster never burns bread, because the slices/bagels etc set their own cook time. You don't need to upgrade the toaster every time you get a new kind of bakery product to toast.

      And best of all, you never need to empty the crumb tray, because of the built-in garbage collection.

    2. Re:Procedural vs OO by kjots · · Score: 5, Insightful

      By the same token, now you have to implement pie.toast() and cake.toast() and lots of other useless and irrelevant methods, even though you're never ever going to use them, simply because they extend the isBakeable() interface.

      Unnecessary, since the IsBakeable interface provides a default implementation of the toast() method that throws an exception if you attempt to toast something that is not toastable.

      The real issue is why the IsBakeable interface has a toast() method in the first place...

  4. Ya, Sure. by wisnoskij · · Score: 5, Insightful

    Ya, sure. It is so much better to use the phrase: "The program contains a variable that stores your name", instead of: "The program knows your name". English, ect. all was not designed to work that way. Unless you want to take a week to describe a single program, it really helps to anthropomorphise it.

    --
    Troll is not a replacement for I disagree.
  5. Encapsulation by mrflash818 · · Score: 4, Insightful

    For me, I prefer OO programming (c++/java) to functional programming (C-lang), just due to encapsulation. I like having an object, with methods for its attributes, public/private methods, and such. Then having the objects interact in my program. It kinda makes sense to how I think.

    However, I also think that if a team or individual programmer can release software that serves a useful purpose, and is maintainable, then those are the only things that matter. Which language, functional or object-oriented 'way' that was used to get there? Seems less important.

    --
    Uh, Linux geek since 1999.
  6. Don't anthropomorphize your programs... by Chris+Mattern · · Score: 4, Funny

    ...they hate that.

  7. Missing the point by pushing-robot · · Score: 5, Insightful

    OO isn't about anthropomorphism, it's about isolation and providing a clear API. If this was a large scale project with fifty people working on code that could move students, I don't want them implementing fifty different versions of move_student that will break whenever the Student or Classroom model changes.

    I know it's trendy to hate on things that have been around a while, and OO indeed isn't the answer to everything, but it's still a useful way of keeping a complex program from getting out of control.

    --
    How can I believe you when you tell me what I don't want to hear?
    1. Re:Missing the point by phantomfive · · Score: 4, Insightful

      OO isn't about anthropomorphism, it's about isolation and providing a clear API.

      Believe it or not, isolation and 'providing a clear API' existed before OOP, so you can't say that's it. In general, object oriented programming means that the functions go with the data.

      --
      "First they came for the slanderers and i said nothing."
  8. Calling poor code organization OOP is flawed by RhettR · · Score: 4, Interesting

    Dijkstra makes an argument about what he calls object oriented programming, but doesn't really use OOP. That he happens to base his argument around two styles of coding, one that is clearly procedural, and one that happens to use objects, is merely accidental. His argument is centered around poor code organization, plain and simple. He passingly slaps down some code modeling Student as an object, neglecting to mention anything about why one would do that (e.g. encapsulation), and completely fails to even mention other OOP ideas such as composition, inheritance, polymorphism, etc. In short, he bashes horrendous code organization, and calls that OOP, without addressing a single reason typically given in favor of OOP. Frankly, that article was awful.

    1. Re:Calling poor code organization OOP is flawed by gnasher719 · · Score: 4, Insightful

      Just saying: It's not Dijkstra talking rubbish. Dijkstra is died 12 years ago. There is a handwritten article by Dijkstra which probably made sense in 1983 when it was written. In 1983 Dijkstra didn't know about C++. Stroustroup didn't know about C++ in 1983.

  9. stupid by Tom · · Score: 4, Insightful

    One of the more stupid blog-level postings I've read. I use "blog-level" as an insult, btw. because blogs are generally a source of shallow thinking, because it just is too convenient to publish some thoughts. When it is more trouble, you're also forced to polish them more.

    Firstly, to understand the difference between trying to do and "trying to do", read some Dennett. If correctly understood, anthropomorphisms like the attribution of intention to a non-intentional entity can be extremely helpful.

    Secondly, not even his example is anywhere near what he's trying to explain. Yes, the analogy breaks down but it has nothing to do with the convulted reasoning he's applying. The cause for the analogy to break down is that there's no equivalent to walking to the classroom in his example. All of his code simply assigns a classroom number, without any equivalent of the walking part. As soon as you add that - magic ! - the analogy works again.

    --
    Assorted stuff I do sometimes: Lemuria.org
  10. Toaster DRM by tonywestonuk · · Score: 4, Funny

    Oh FFS. Look on the bloody Bagel packet before you buy. If it doesn't say 'implements toastable' then don't buy em. Yeh , they may be a few bucks more, but thats your own fault for getting a toaster that is made by the same people who make the bagels.

    1. Re:Toaster DRM by tonywestonuk · · Score: 4, Funny

      What you can buy is an 'Toast Decorator' - its a Chinese import, probably not the most legal thing as they've cracked the DRM........ what you do is just slip your generic, non toastable bagels in this toasting bag, and then shove it in your toaster. It accepts the 'self.toast()' method, and does whats required to make sure your bagels are toasted to perfection every time. Result!

    2. Re:Toaster DRM by anchovy_chekov · · Score: 4, Funny

      You insensitive clod. I bought one of these recently, in an effort to reflow the solder on my failing Mac Book Pro. Now all I have is a dead laptop and a toaster that smells of Apple.

  11. This is why I like Python so I can use OOP or not by caseih · · Score: 4, Interesting

    This is why I like Python. Python allows object-oriented programming styles or procedural, or a mix. Python has a lot of warts, but it's really refreshing to me to use. Every time I look at Java, I'm turned off by the forcing of class-based object-oriented programming for everything, even when the program is really just procedural with a static main. Perhaps this tends to make programmers try to shoehorn OOP when it's not the best fit.

  12. Less accurate statement by SuperKendall · · Score: 4, Insightful

    "The program doesn't know to check for" is in fact more accurate than "The program wasn't designed to check for". The second statement could mean that it wasn't designed to do something, but might do it anyway - what the program ACTUALLY does is left somewhat ambiguous (this is a technique lawyers will often use answering in court). In the first instance the statement makes it quite clear the program DOES NOT KNOW HOW to do what you are talking about.

    You can shorten something so far for clarity, but if you go to far you end up with less clarity.

    The "thinks" part at the end could go though, removing that does no harm to clarity.

    The thing is, writing clearly is just plain hard - being able to use anthropomorphic kinds of terms helps make it simpler to add clarity to description at the cost of somewhat wordier sentences... kind of like how sometimes you make a program a little more verbose so that a different programmer coming across the code later can understand it.

    --
    "There is more worth loving than we have strength to love." - Brian Jay Stanley
  13. Longstanding Precedent by nuckfuts · · Score: 4, Funny

    This has been going on since before object-oriented programming existed. In Unix, for example, processes have "parents", "children", and can be "killed".

  14. What? by matunos · · Score: 4, Funny

    An analogy that breaks down if you push it too far?

    Ridiculous! You cannot push analogies. They are not tangible things.

  15. Re:Programming languages are not really "language" by skids · · Score: 5, Interesting

    What gets me is this:

    If you don't draw analogies (like anthropomorphism), or abstractions, how the hell do you choose your names in a way that lends itself to understandable code? The author should take his own argument one step further and realize that calling a string of bits a "student" is likewise anthropomorphising the data, and calling another memloc a "Classroom" is applying an anology to what is really going on. Then he could reduce is argument ad-absurdium to requiring that all identifiers be randomly chosenstring to avoid installing unintentional meaning into data structures and procedures/functions.