Live data from Hacker News

Joe Is Wrong (2009)

goran.krampe.se

61–70 of 86 posts

Re: Joe Is Wrong (2009)

#61
post #48

When I started programming in Pascal in the early 90s, my procedures/functions and my data were decoupled, spread all over the place. Then I started learning (Turbo)Pascal with OOP. It was godsend. All of a sudden I could structure my code in a way I wasn’t able to do before. Now thirty years later I know how to structure my (Python) code without OO: Via modules. I hardly use OO anymore. And I am drawn to FP more and…

I'm a recent FP convert after 15ish years of OO. I don't hate OO now or anything, but maybe a little? It adds so much more to think about for what I now consider to be no benefit, at least for the types of systems I've worked on in my career. A big thing I've realized is that everything I've worked on has modelled things that are already abstract. For example, I'm working on a scheduling app right now. In real life, a schedule is an abstract concept realized on paper. Our app certainly doesn't have a Paper class. That may seem knit-picky to some people but it's true: the whole "model the real world" breaks down there. My apps also always have way more behaviour than they do things. FP is much easier to model a lot of behaviour around a generally fixed set of things than OO is.

This is not to say there aren't good use-cases for OO (video games come to mind) but for my day-to-tasks, I've found FP much simpler (and immutability is a god-send... it's like, "Hey, you know that foot gun you've been carrying around? You don't need that anymore!"). I would encourage any OO zealots to give FP a honest try.

Re: Joe Is Wrong (2009)

#62
post #38

Yes I oslo agree : For me, the the OO programming gets me close to the design of the problem I try to solve. I mean before even programming. Then when I feel ready to program my solution, Actors become classes naturally. I tend to believe OO langage simply gives us less work to design & program solutions.

There's another interesting takeaway from that.

It should be alright for us to accept that different brains prefer different ways of working.

To me, functional paradigm is closer to how I see and understand things. "It gives us less work to design & program solutions." :D

Re: Joe Is Wrong (2009)

#63

Earlier quoted context omitted.

Not necessarily: C#, for example, has a lot of FP like moments. Its not particularly relevant how are those internally implemented.

Not op, but I think you missed his / her point. Let's take static void main as example. It's a series of operation called at the beginning (at least during my era), does not need to be in a class. The very reason we put it on class (let's say) Start, feels like language limitation. The same with class Math, such as Math.floor and Math.ceil. Is Math a class or is it more suitable as a namespace? Since no object instan…

There are now Top level statements in C# 9.

- https://docs.microsoft.com/en-us/dotnet/csharp/whats-new/tut...

> Top-level statements enable you to avoid the extra ceremony required by placing your program's entry point in a static method in a class.

Re: Joe Is Wrong (2009)

#64
post #12

These discussions tend to boil down to OOP vs FP. That's a false dichotomy. The alternative to OOP is not FP, it's pre-OOP imperative programming with various techniques a la carte. Should data and functions be together? That's a choice you can make on a case-by-case basis. It makes total sense that a HashMap has an insert() method. On the other hand, maybe your Player object is just some data which is interpreted by…

The meaningful alternative to OOP is modular, object-based programming based on composition instead of inheritance. That encompasses both "pre-OOP" and "post-OOP", mainly functional-based idioms. Simple imperative programming does not really scale to larger software systems, modularity and compositional thinking are essential.

Your statement seems to imply that imperative programming does not have modularity. In my experience, I have worked on programs written before OOP was in vogue, in imperative languages, that I consider to have had good modular design. These programs had millions of lines of code and I felt they were easy to understand and modify.

What do you mean when you say that imperative programs lacked modularity?

Re: Joe Is Wrong (2009)

#65
After many years of a lot of OOP, many people have realized, that putting behavior and state together into one entity might not be a good idea. We can see modern languages moving away from such practices. For example in Clojure one has defmethod, which defined a method separately. In Rust one has structs and implements traits for them separately. In some languages OO systems are libraries, which are optional, opt-in, not part of the core language. Think GOOPS and CLOS. Usually those languages define functions for data structures separately and you will have something like vector-length.

So it seems wisdom is slowly sinking in and we are progressing away from bundling state and behavior together.

Why is this done? For example to avoid having to subclass loads of stuff. For example in Rust one uses composition over inheritance and one can add behavior later by implementing traits, that make use of the parts of the structs. This way one does not need to subclass everything to add a new behavior. Similar for defmethod in Clojure. With Erlang this is raised to a whole new level, by defining the behavior in separate actors, which process messages, which are the data, which travel around without the behavior part. Overall it makes it possible to actually have encapsulation. A similar thing happens when we leave the boundaries of one machine and look at the web and REST, where we basically pass messages, conceptually similar to what happens between actors. For details about how encapsulation is broken in mainstream OOP read the article "Goodbye, Object Oriented Programming" by Charles Scalfani: https://medium.com/@cscalfani/goodbye-object-oriented-progra... (Sorry for the medium link. Does anyone know a better link?)

Next I'll address some things in the article, which I see problematic and questionable.

> Putting them together creates a boundary around this group of data and functions - encapsulation. Sure, you may call that a “module” but an object is IMHO slightly different since objects have identity, a life cycle and we can hold them, send them around etc.

That is not, what a module usually is. A module usually groups things, which are independent from each other, but are used in the same context. For example a module could contain a definition of a math functions. It does not track state or data. It might contain data structure _definitions_, but not their instances. A module is not a class or object replacement.

> So in some sense objects can probably be viewed as modules but often more fine granular. And we can combine such “modules” into larger modules (since objects have identity and can be referenced etc) and we can create and kill them dynamically (life cycle).

See above for the differences of objects and modules. It is not about being "more fine granular". It is different in character and should be used in different scenarios.

Re: Joe Is Wrong (2009)

#66

Earlier quoted context omitted.

I love this take. Programming techniques are that, tools on our belt. One should neither fall in love with a particular one, nor try to use it exclusively. Either it fits, meaning it provides advantages that outweigh the added complexity, or it doesn't.

Python balances this well. You are never forced into an OO hierarchy for your own code.

On the other hand Python often nudges you towards OOP, because its FP features are a bit lacking.

Re: Joe Is Wrong (2009)

#67

Imagine being a Smalltalker and still missing the underlying context of Joe's article - specifically, around the actor model (as used extensively in Erlang) being substantially closer to OOP as intended by e.g. Smalltalk than to the popularized inheritance-heavy brand of "OOP". You can see this in the objections: > Objection 1 - Data structure and functions should not be bound together ...and yet the usual way to sto…

Joe himself once said on stage (it was a video with him and Kay on stage, not sure of the name), that Erlang is either the most OOP lang or the least. I think he meant, that it depends on what OOP you look at. If you look at Smalltalk and message passing, as Kay highlights as the prominent ideas, then it might be the most OOP (or somewhere close to), while it is a 180 from mainstream OOP, when we look at the actor system and how distributed systems work.

Re: Joe Is Wrong (2009)

#68
I gave up after his comments on the first OO objection. This blatant ad hominem and sweeping generalizations pass for good criticism? Not in my book at least.

Re: Joe Is Wrong (2009)

#69

Earlier quoted context omitted.

The meaningful alternative to OOP is modular, object-based programming based on composition instead of inheritance. That encompasses both "pre-OOP" and "post-OOP", mainly functional-based idioms. Simple imperative programming does not really scale to larger software systems, modularity and compositional thinking are essential.

Your statement seems to imply that imperative programming does not have modularity. In my experience, I have worked on programs written before OOP was in vogue, in imperative languages, that I consider to have had good modular design. These programs had millions of lines of code and I felt they were easy to understand and modify. What do you mean when you say that imperative programs lacked modularity?

Modularity in imperative programming is ad hoc. It's not part of the paradigm itself like in modern functional programming, or object-based programming with interfaces and composition.

Re: Joe Is Wrong (2009)

#70
To OO or not OO seems like more of a religious preference about functional containment: either at the module level or at the type level. This is why neither seems to satisfy everyone and why there are flame wars about it.

On one side there is loose coupling between types and functions, and the other side has strong coupling. On one side, types can be composed simply and the other involves inheritance, overloading, and polymorphic rules.

Go, Haskell, and Idris are arguable examples of good type systems whereas languages like Python and Erlang have weak type systems. I wouldn't wish C++ on my worst enemy, but that's a religious preference not shared by all. Pascal without OO had a nice type system.

Post reply on HN