Live data from Hacker News

Why OO Sucks by Joe Armstrong (2000)

cs.otago.ac.nz

311–320 of 396 posts

Re: Why OO Sucks by Joe Armstrong (2000)

#311
post #86
post #77

A few notes: Binding data and functions together beats operating on global data visible to everything. One of the big wins of OOP is less exposed global data. A big problem with OOP in C++ was that it wasn't opaque enough. The headers needed to use an object contain info only useful to the object's private functions. This creates recompile hell. Multiple inheritance is seldom worth the headaches. Overriding a member…

> Binding data and functions together beats operating on global data visible to everything. One of the big wins of OOP is less exposed global data. “Passing state as parameters” is what solved the “everything operating on global state” problem. Binding functions and state permitted polymorphism/abstraction. > Multiple inheritance is seldom worth the headaches. Single inheritance is never worth the headaches. :) > Obj…

'why inheritance sucks' is a good topic

Re: Why OO Sucks by Joe Armstrong (2000)

#313
post #241
post #72

Earlier quoted context omitted.

Admittedly I'm somewhat of a FP fanboy, but I seriously cannot disagree with you more on this. Functional Programming (and Logic Programming) are better than other paradigms because, unlike Java (or C++, or C#...) there is an emphasis on correctness , and the people working on FP compilers (like Haskell and Idris) are utilizing mathematics to do this. No idea on your opinion on mathematics, but to me Math/Logic reign…

You could be doing instead ((if (null? x) ;..... ))

If this were clojure, I'd probably use a (some->...) or (some->> ...) macro, so it would be a non-issue.

Re: Why OO Sucks by Joe Armstrong (2000)

#314

Earlier quoted context omitted.

Isn't a method call a message, and the return value a message back? Or is it that "true OO" must be asynchronous?

I think the spirit of OO, an object has agency over how the message is interpreted in order for it to be considered a message. If the caller has already determined for the object that it is going to call a method then the object has lost that agency. In a 'true OO' language an object may choose to invoke a method that corresponds to the details within the message, but that is not for the caller to decide. Consider th…

What is the advantage of doing that instead of using an IObservable that can filter on the event name in C# or, even better in F#, having an exhaustive pattern match that automatically casts the argument to the expected type and notifies you at compile time if you forgot to handle some cases?

Re: Why OO Sucks by Joe Armstrong (2000)

#315
post #299

Earlier quoted context omitted.

> You could also make a class of global functions and use that I'm not sure I understand your issue with doing this. You need to put your global (i.e. public static) functions in classes not because Java is forcing OO practices into everything, but because classes effectively serve as Java's translation units. I think they serve this purpose pretty well in practice.

Classes being Java's only translation units are one of the downsides that I'm mentioning. Really my objection is more that it doesn't allow use of the right tool for the job (which is not always an object).

I'm not sure I see where objects enter into this. I mean, you seem to be asking for something like this,

  public unit Util {
      public void foo() {
          // do things
      }
  }
which would compile down into a bytecode-containing artifact which we could call a unit file, which the JVM would load at runtime using some sort of unit loader. Callers could import the Util unit and then invoke foo with the statement

  Util.foo();
But then, I don't see the diffence between the above and the following,

  public class Util {
      public static void foo() {
          // do things
      }
      // If we're really pedantic, we can ban construction of Util instances
      private Util() {}
  }
which compiles down into a bytecode-containing artifact called a class file, which the JVM loads at runtime using a class loader. Callers can import the Util class and then invoke foo with the statement

  Util.foo();
What's this downside you speak of? Is there something a different kind of translation unit would do that a class currently doesn't?

Re: Why OO Sucks by Joe Armstrong (2000)

#316
post #31

Well, I disagree with 99% of this... I'm a guy that started with C, moved to functional programing, added C++, and now do all 3. > Objection 1. Data structure and functions should not be bound together Well, in my experience, in every almost every code-base (either from functional, or imperative programing), we end up with modules, witch are a set of function taking the same type as a parameter. This is very close to…

> Objects can have a private state. This a problem with mutability, not oriented object programming.

That seems to be the crux of it - I remember reading a post by Paul Graham where he said something similar about object oriented programming. His core thesis seemed to be that functional programming does a better job of organizing things than object-oriented programming does, and once you have the core of functional programming in place (closures, first-class functions, whatever the hell a "monad" is), you don't need object orientation any more. I've never gotten deep enough into pure functional programming to really see things this way, but I've gotten deep enough to at least understand why these pure FP guys might think that.

Re: Why OO Sucks by Joe Armstrong (2000)

#317

Earlier quoted context omitted.

Isn't a method call a message, and the return value a message back? Or is it that "true OO" must be asynchronous?

In Kay's OO the only way to interact with an object was through method passing. It was important the the internal state of an object was kept private at all times. Getters/setters are technically message-passing methods, but they undermine the design goal because they more or less directly expose internal state to the public world. But we see getters/setters used constantly . People don't use OO in the way Kay intend…

I have seen side effects for completely unrelated fields in setters. Heck, I’ve even witnessed side effects in bloody getters. This is the reason why now I’m a huge fan of immutable objects. Actually nowadays I became a fan of functional languages with first class immutability support.

Re: Why OO Sucks by Joe Armstrong (2000)

#318
post #163

Earlier quoted context omitted.

In my experience, getter/setter abuse is always an attempt to use classes as a structs/records. I wonder if we had different syntax for those cases we'd have less of them. But then, again, it's very convenient to be able to add a method to a class that was previously a dumb struct.

Maybe I am a complete philistine but is that really a bad thing or just something which goes against their categorism? I get that there are some circumstances where setters would break assumptions but classes are meant to be worked with, period.

It’s a different semantic in my opinion. Even in mutable objects it’s better to have setters that act only on the field that they are supposed to mutate and do absolutely nothing else. If you need a notification you can raise an event and then the interested parties will react accordingly. By mutating directly an unrelated field, or even worse, call an unrelated method that brings complete havoc to the current object state, in the setter you are opening yourself to an incredible amount of pain.

Re: Why OO Sucks by Joe Armstrong (2000)

#319
The "problem" with OOP is that it was originally oversold for the wrong reasons, and it took the industry a while to learn when and where to use it and where not to.

Around the late 1980's OOP was hyped as a way to do domain modelling. That is, modelling the nouns and verbs of the subject at hand (employees, invoices, etc.) While some still defend it for domain modeling, most have found it a poor fit for any non-trivial model.

But it did turn out a handy way to present and manage APIs to "external" libraries or services. This is largely how it's used today.

The lessons:

1. Use the right tool for the job, and no one tool is right for everything.

2. Test an idea in production for a while before drawing conclusions about what its good at and what its not.

Microservices is currently making similar mistakes, I would note. Those who don't learn history are bound to repeat it.

Re: Why OO Sucks by Joe Armstrong (2000)

#320

It really should be noted that years later Joe changed his mind about OO and came to the realization that perhaps Erlang is the only object-oriented language :) From a 2010 interview: ..."I wrote a an article, a blog thing, years ago - Why object oriented programming is silly. I mainly wanted to provoke people with it. They had a quite interesting response to that and I managed to annoy a lot of people, which was par…

That speaks to one of the things that bothers me about OOP's intellectual traditions: there are two different ideas of what "object" can mean, and most object-oriented languages and practices deeply conflate the two. On the one hand, "object" can mean a unification of data structures with the procedures that act on them. In this view, the ideal is for everything to be an "object", and for all the procedures to actual…

dont forget inheritance. its either orthogonal or essential to what it means to be 'object oriented' depending on who you are talking to.
Post reply on HN