IMHO this is a pretty poor rant. Let me argue each point:<p>* Data structure and functions should not be bound together<p>In some cases encapsulation works really well. For example GUI elements. It is less true for "process-oriented" components. But the arguments he makes don't seem very well thought out.<p>* Everything has to be an object<p>I actually agree here. To my mind, the biggest problem with OOPS is that is slowly devours all other concepts until we are left trying to force-fit all problems into <i>the</i> OOPS mould.<p>* In an OOPL data type definitions are spread out all over the place<p>This just ignorance.<p>* Objects have private state<p>This is also a good point. Having state actually tends to being a "bad" thing to do. Of course, the entire purpose of the object is to capture some invariant, but an object doesn't make that clear. Many objects contain instance variables that should actually be parameters.<p>* Why is OOPS popular?<p>Because it makes it easier and safer to get programmers working together as a group. The vocabulary of available objects is a simple and somewhat elegant way of communicating.<p>(EDIT: Corrected layout.)
This article is easier to appreciate if you view it as a window into the thinking style of a another programmer, rather than an actual argument about what is right or wrong. (That is, patch your local branch of the headline to "Why OO Sucks For My Way Of Thinking".)<p>The impressions I get are that Armstrong likes to stay close to a core set of raw data structures; he's more about the flows than the stocks; he finds delegation and specialization more frustrating than helpful; and he would rather build a combustion engine than an office building.<p>(He's probably an ISTP personality type at work but has put on his ISTJ hat for the purpose of writing this article.)
As a disclosure, I've been using Ruby for the past three years, and it's about as object-y as you can get. However, Ruby opened my eyes a bit to exploring other languages. Point is, as I started looking at other languages in depth, I found myself using objects a little bit less, especially in the design pattern sense. Some problems in the traditional 23 design patterns just disappear in dynanmic languages. After programming in Lua and Javascript, I find objects nice, but optional.<p>Nowadays, I sort of just use classes to scope and namespace. I keep state in classes when it makes sense.<p>To counter the point about state, Erlang programs do have state. They're just contained locally within a function. Since Erlang has tail recursion, you just call the same function recursively and pass the state variable you want to keep at the very end of the function for the lifetime of the program. Because it's tail recursion, there's no stack overflow. Also, Erlang threads can keep 'state' inside of the Mnesia database that comes with Erlang.<p>State is only evil when it's shared. Because state is contained locally in a function, a single Erlang thread can do whatever it wants, whenever it wants with those variables. Threads communicate through message passing. Therefore, no need for locks, mutexes or semaphores. Along with the low overhead of thread creation (~300 bytes) they're part of the reason why Erlang has great concurrency properties.
<i>Objection 1 - Data structure and functions should not be bound together</i><p>This is not true of "OO", it's just true of OO in languages like C++ and Java. These languages got OO horribly, horribly wrong; so if you use them and dislike OO, it's possible that you dislike the language -- not OO.<p>If you use CLOS, you'll see that functions are functions and data are data. CLOS just gives you some tools for calling different functions depending on the type of the data and for specializing subtypes. This is OO done right, and it is not what the author of this article is referring to.<p><i>Objection 2 - Everything has to be an object.</i><p>Everything has to have a type, yeah. But the line between "built-in type" and "object" should be blurry, and in CLOS it is. Again, if you are hating OO because of Java's implementation quirks...<p><i>Objection 3 - In an OOPL data type definitions are spread out all over the place.</i><p>I am not sure what the problem is here. Unless your code is all in one file, this is going to be a problem regardless of the programming "paradigm" you choose.<p>When writing Lisp, I often put all my class and method definitions for one chunk of the app in the same file. I think this is what the author wants to do, and it is do-able and commonly done in CLOS. In Java, yeah, you have to put each class in its own file. That is irritating, but the problem is not OO.<p><i>Objection 4 - Objects have private state.</i><p>This is true. I prefer to write OO code that maps one object to another, rather than mutating an object's internals. The sad reality is that this approach is slower and uses more memory than the mutation approach, but I think it's easier to reason about and maintain. Computers are fast, anyway.<p>So while it's possible to misuse OO, whatever that means for your particular tastes, it's also possible to not misuse it. If you hate OO, it is possible that you are doing it wrong.
I have to say that I agree with this only as long as we're talking about languages that don't have excellent OO capabilities. C++, Java, C#, and most others failed to impress me with their approach to OOP. But then I got to work in Smalltalk, and it dawned on me: "<i>this</i> is what OOP is supposed to be like."
<i>"Data structures just are. They don't do anything. They are intrinsically declarative. 'Understanding' a data structure is a lot easier than 'understanding' a function. "</i><p>I'm possibly damaged from a few years of OOP but how do you separate a data structure from its functions? e.g. How can a B-tree mean anything separate from its search/insert/delete operations?
If people get angry while reading this article, there must be some truth in what he says. Dissing OO is still swearing in the church.<p>I programmed for a long time not knowing OO and it was fine, there are other ways of encapsulation/isolation of code that works just as well. I don't really see that there's a big difference, and there's a certain element of religion about OO vs Functional. Both have their own merits in different types of applications. Still it's nice with someone who stands up for the functional approach.
Von Neuman architecture sucks. From our educated and elevated point of view I think we can all agree on that. At least if we transcribe to "programming in machine language sucks". Perhaps one day we may elevate to agreement on "OO architecture sucks".
OO is a successful technology measured by what has been accomplished with it. The von Neuman architecture is even more successful. The one and only architecture behind all general purpose computers. But no sane programmer would touch machine code directly.
I have always thought that OO was wrong, in some sense at least. But I have to touch it. There is no higher and better level. There are alternatives but on the same level. So they suck in their own ways.
I remember when I started forming my mental pictures of what programming in the large was all about. How to think about it. How to structure it in my mind. I read Object-Oriented Modeling and Design by Rumbaugh et.al. Even if the authors didn't succeed in explaining it fully, I got the vivid impression, that they wanted me to believe, that a computer model should be structured along three dimensions: data, functionality and events. A space with a recording axis, data, an activity axis, functions, and a time axis, events. Though a somewhat fuzzy picture, I "saw" these three dimensions as orthogonal and of equal importance in structuring and building the complex structures called programs. I find OO to intermingle the data-function-plane but leaving timing in the cold. A skewed space.
I'm looking forward to the tools and technology, that will support my clean and "right" design model in a non-skewed concrete "code" space. Well, if they ever arrive, I might then have an even better mental model and find my self stuck with the new and better but sucking tools.
<i>In an OOPL I have to choose some base object in which I will define the ubiquitous data structure, all other objects that want to use this data structure must inherit this object.</i><p>Obviously not if you use composition and if some objects are just your wrapper for your data structures.
Several comments have objected to this as if it were stupid:<p><i>In an OOPL data type definitions belong to objects. So I can't find all the data type definition[s] in one place.</i><p>The point is that OO programs consist of many type declarations scattered everywhere. As complexity grows, it gets harder to understand what all the types are and how they are related. The textbook "shape" and "animal" examples never come close to revealing this problem: they're oversimplified and they refer to things already familiar from the world. In other words they rely on OO's roots in simulation, where it works ok. In any complex system, though, you have to go far beyond ready-at-hand concepts. You end up declaring all sorts of arbitrary types that exhibit the problem Armstrong is talking about. There isn't even an easy way to see what they all are.<p>It gets harder and harder to change such programs because changing one type definition entails changing others. You can change how the internals of a class work (where it reduces to functions operating on private state), but significant overhaul of the class hierarchy itself is an order of magnitude harder than it should be (than it is in a program where you just have functions).<p>Armstrong's reference to keeping everything in a single file is not because he believes everything should be kept in a single file. That should be obvious, since he's obviously not an idiot. His point is how much easier it is in certain non-OO languages to understand a program's type system.<p>I think this is a valid criticism of OO because it cuts to the core of what people claimed was great about OO: that it helps to organize complex programs better and that it makes complex programs easier to change.<p>Edit: Armstrong is obviously smart, and Erlang is a real contribution, but it is also true that he is not a very good writer. I find he's the kind of writer that I have to make an effort to understand, which in his case is worth it because his intuitions are worth paying attention to. Of course not everyone need feel that way. But some of the comments in this thread seem a little knee-jerk to me.<p>Edit 2: Smalltalk is pretty clearly an exception to all of this. This has puzzled me for a long time. It just hit me maybe why: <i>Smalltalk is actually not an OO language.</i> Not in the sense we talk about OO nowadays. We've all been misled by the fact that it was the original OO language and that its creator introduced the term. Smalltalk's greatness comes from another place entirely, which is why no other OO language has equalled it.
Why don't erlang people understand that erlang processes are objects?<p>- You can send them messages<p>- Their state can be mutated through receipt of messages<p>- They have private state<p>- Their functions are associated with the data that they operate on
Erlang is a functional language specially designed (and suitable) for concurrent programming.<p>His rant is partially correct (at best), especially looking at OOP from a functional programming point of view.<p>However, developers in the real world who doesn't focus on concurrent programming have different needs.<p>I'll comment his objections from a C++ perspective (which is a multi-paradigm language, not purely OO):<p>Objection 1 - Data structure and functions should not be bound together
- you are free to store all your data structures in a single file, and access them from anywhere. However, using classes will let you hide some of the data structures which are not necessary globally, reducing the cognitive load.<p>Objection 2 - Everything has to be an object
- Not in C++. You use classes where appropriate, and ordinary functions elsewhere. I agree that everything shouldn't be an object.<p>Objection 3 - In an OOPL data type definitions are spread out all over the place.
- similar to objection 1. You CAN store all definitions in a single include file, but for large projects this can be a LOT of data definitions, where many/most of them are only relevant for parts of the applications. Hiding data definitions in separate classes will make it easier to focus on the RELEVANT data depending on which class/function you use.<p>Objection 4 - Objects have private state.
- again, similar to 1 and 3. "State is the root of all evil". If you store all data in a single file, then you have one giant global mess. By assigning them to a class, you clearly state the responsibility and scope of the variables. A private state is nobody's business but the class. You don't HAVE to have private state for objects,but then you either need to pass all data to each function, or use global variables instead.<p>For Erlang (functional programming) these objections make (some) sense since you DON'T want any state whatsoever to facilitate concurrency.<p>However, saying that OO sucks is stupid, and the four reasons for why OO was popular is not even worth responding to. I don't think functional programming will become more popular due to this rant....
I won't go so far as to say OO sucks, but I have noticed in my own code, that I have tended to use OO concepts a little bit and functional concepts a lot.<p>Over time, I'm using less and less OO and more and more functional, so... that tells me OO wasn't all it was cracked up to be.<p>The biggest problem I see with OO is that it doesn't map well to relational models and OO databases aren't that popular.
For once, just once, I would like to see someone compare apples to apples: OO vs corresponding encapsulation techniques in functional languages (abstract data types, ML-style modules/functors, Haskell-style typeclasses).<p>In case anyone was wondering, yes, the functional community loves namespacing, encapsulation, and creation of new data types with functions specifically intended for use on them.<p>The real question is: How do we express relationships between data types...<p>Do we use subtyping? (OO yes, functional no).<p>How do we allow multiple types to see each others privates? (Friends/inheritance in OO, modules in Haskell and ML).<p>How do we do polymorphism over static data/functions? (Basically, doesn't exist in OO... functors in ML and typeclasses in Haskell).<p>The immutability debate is another discussion entirely.
Isn't this rather like saying than since a five pound sledge hammer can't fix watches, tools suck?<p>I find it best to use the tool that is appropriate for the task. This is true even though you might be able to force fit a particular tool to a mismatched task. Saying that there is only one true way is always wrong. Especially since any of the ways we have are at best only good enough for some tasks, mediocre for many, and really horrible for others.<p>The title should be translated to "Why One True Ways Suck" or on a really bad day "Everything Sucks".
If the author wants to explain to us why he thinks OO sucks, that is a legitimate criticism, even if for some of us it would be hard to swallow. However, the fact that the author does not acknowledge the advantages of OO, (even if he believes they are less significant that the disadvantages,) is a good enough reason to ignore his criticism.
If the people who got upset of the article should unite of what OO is we could read that one comment.<p>In the meantime read <a href="http://www.paulgraham.com/reesoo.html" rel="nofollow">http://www.paulgraham.com/reesoo.html</a><p>Be neutral. Think. Could Joe have some valid arguments ?
As someone said, patch your brain into Net Neutral.
OO works becuase it roughly matches how we think. We see the world as objects at a basic level. As others mentioned, this makes coding more productive. It's a choice for the programmer, not the computer.<p>If you need really fast code, use assembler. You have that choice. Code at the level required for the task.
Summary: I don't understand programming much, I don't understand OO, I don't know how to do OO properly, and so I think OO sucks.<p>This article is Not Even Wrong. It's not close enough to even being wrong to warrant a thought through response. The author needs to go and learn how to do OO properly before making wild declarations about "Why OO sucks".<p>================<p>Edit: worth clarifying this as I've just realised that this guy is supposed to be the author of a programming language (quite worrying if he is!)<p>As I said, this is too far from even being wrong to be worth really debating point by point, so I'll just poke a few holes to demonstrate that I'm not just flaming:<p>1) <i>functions and data structures belong in totally different worlds</i><p>Anyone who's even glanced at SICP knows that the distinction between data and functions are vague at best. Certainly they are tightly coupled concepts.<p>------------<p>2) <i>Functions are understood as black boxes that transform inputs to outputs. If I understand the input and the output then I have understood the function. This does not mean to say that I could have written the function.</i><p>How does that have anything to do with the age of the captain? Not only the author's main point doesn't make sense, but he feels the latitude to make tangents about unrelated things that don't really have an impact on his obviously controversial main point.<p>--------------<p>3) The "time" example that he gives...<p>In this example, he basically creates an ad-hoc object made of methods that return data. The only difference between this and proper OO is that this structure doesn't benefit from all the advantages of OO. But it's still a tightly coupled structure made of data (the values) and functions (the methods to access those values).<p>--------------<p>4) <i>In an OOPL data type definitions belong to objects. So I can't find all the data type definition in one place. In Erlang or C I can define all my data types in a single include file or data dictionary.</i><p>So now language design should be driven by whether you have a decent editor that allows you to manage more than 1 file? Seriously, the "Everything in 1 file" anti-pattern is not even worth arguing about... When someone makes such a dumb point, how can you take the rest of the article seriously?<p>--------------<p>I could go on, but I think I'm proven my point. Either this article was not written by Joe Armstrong, or it casts severe doubt on the sanity of Erlang, or he's written it to troll the OO community.
I'm seeing a trend here:<p>1. X used to be regarded highly but turns out to be imperfect or suboptimal for certain problem domains.<p>2. Write "why X sucks" blog post.<p>3. Profit!
OO concepts are occasionally cool and useful. Note the use of the word <i>occasionally</i>.<p>90+% of the time, when you create an object, what you really want is a struct/record. Most methods should really be static. Most of the power that does come from OO comes from its ability to foster a hierarchical type system in an extensible way.<p>OO smells like something that was invented to give "business" types the illusion that they can understand code without reading it in detail. "This is 'like a' Chair."
Knowing how many fuckups and bugs which have happened trough the years because of incorrect handling of times and dates, I can't believe he advocates that they should be<p><pre><code> "ubiquitous ... data structures representing times (which)
can be manipulated by any function in the system."
</code></pre>
Obviously the thought of a one single encapsulated DateTime class which manipulates time and dates (correctly) for us is a horrible idea.
Programmers are talking about ideas, while coders are talking about tools. =)
I'm personally prefer the description of mr. Booch - OOA/OOD/OOP is the way to manage the complexity of a problem.
Unfortunately the rest of his book is an advertisement of the RUP and UML - yet another tools.
In my experience, OO is a good thing when you are able to imagine the 'objects' in some real-life representation (like GUI elements which are generally represented as 3 dimensional physical objects). Otherwise OO tends to be too abstract to help you, and already gets in your way.<p>This is very simple to prove: give a group of experienced coders the same 2 problems to solve: one taken from a real world object, and the other purely theoretic; both to realize in OO. This experiment would show that the real world object problem is solved in a similar manner, and the theoretic one in all different ways...<p>And yes, I use OO, but only with the libraries written in OO style, and never in my own code.
Christ, THANK YOU!!! Finally someone with the balls to say what needed to be said!! The object oriented emperor has no clothes. It creates problems and creates an industry to solve problems it created. Kind of like Christianity. It creates guilt so it can solve guilt by making people donate to the Church to relieve themselves of guilt the Church itself put on to them. Great scam, and so is OO. They will crucify you my friend, but you have spoken the TRUTH, and the history will adjudicate you accordingly!!<p>Princeps autum justice, ille in parce est.