News for hackers. Stuff that matters.
Re:The Case Against OOP Is Wildly Overstated by lgessler on Friday July 31, 2020 @10:24AM (#24008839)
This doesn't speak to what I consider some of the most dangerous parts of OOP, which include the assumptions that tightly binding data and code is helpful, and that statefulness is fine to freely sprinkle throughout your program.
Re:The Case Against OOP Is Wildly Overstated by zozbot234 on Friday July 31, 2020 @01:16PM (#24010909)
"Tightly binding data and code" allows you to maintain complex invariants via code, and to abstract away from the specifics of any single implementation. Statefulness per se is quite manageable; what's not manageable is shared, mutable state that isn't isolated to a single, modular, highly cohesive "unit" of code that can be understood in its totality. The real issues with OOP have to do precisely with things that break these principles, viz. implementation inheritance.
Re:The Case Against OOP Is Wildly Overstated by lioeters on Saturday August 01, 2020 @01:02PM (#24022018)
> what's not manageable is shared, mutable state that isn't isolated to a single, modular, highly cohesive "unit" of code that can be understood in its totality

Well put. To turn it around, the ideal of state management is:

- Immutable, isolated state

- State operations are singular - I guess meaning centralized as well as atomic

- State operations are modular and cohesive units of code

- Can be understood in its totality - which implies centralized state management, where operations are not scattered thoroughout and intertwined with, for example, UI code

In my experience, I generally agree with the sentiment against "proper" OOP, as an accepted or preferred style of code organization. This is related to some fundamental truths and advantages that the rising popularity of functional programming is revealing.

Even in the world of UI and software for the web, the classic OOP patterns are getting "disrupted" in a healthy way, and it seems to be moving in the direction of composing immutable states, idempotent functions with no side-effects, where state changes and effects are centally managed in an isolated way.

Re:The Case Against OOP Is Wildly Overstated by hinkley on Friday July 31, 2020 @03:09PM (#24012618)
Not just invariants, covariants as well.

State and zip code always change together. Having had to fix code that passed 5 variables around for an address (which needed to go to 6 for “address 2”) I replaced it with an address object.

Re:The Case Against OOP Is Wildly Overstated by lmm on Friday July 31, 2020 @09:53PM (#24016633)
An address datastructure is a good thing. I'm not at all convinced that an address object - one with behaviour - is.
Re:The Case Against OOP Is Wildly Overstated by umanwizard on Saturday August 01, 2020 @11:10AM (#24021026)
You can have an address struct, and functions that manipulate it in controlled ways (like always updating the state when the ZIP changes), in every language, whether OOP or not.
Re:The Case Against OOP Is Wildly Overstated by HeyLaughingBoy on Saturday August 01, 2020 @12:10PM (#24021537)
That is OOP, regardless of what the language is.
Re:The Case Against OOP Is Wildly Overstated by umanwizard on Saturday August 01, 2020 @02:17PM (#24022667)
It’s an OOP technique, yes, but functions operating on structures predate OOP and are used in practically every program, so they’re not enough to claim that a program is written in OOP style without the term losing all meaning.

For me, true OOP requires some sort of inheritance and/or runtime method dispatch, at least.

Re:The Case Against OOP Is Wildly Overstated by HeyLaughingBoy on Sunday August 02, 2020 @01:15PM (#24029956)
OK, I'll go along with that. The description given doesn't contain a full "implementation" of what OOP is considered to be.

Can we at least agree that limiting operations on the structure to the code that controls that structure is following the definition of encapsulation, which is what I should have said anyway?

Re:The Case Against OOP Is Wildly Overstated by dnautics on Friday July 31, 2020 @09:24PM (#24016427)
Isn't this basically just namespacing? Not at all unique to OOP.
Re:The Case Against OOP Is Wildly Overstated by keithasaurus on Friday July 31, 2020 @01:50PM (#24011376)
> "Tightly binding data and code" allows you to maintain complex invariants via code

Not sure I understand what this means. Could you give an example?

Re:The Case Against OOP Is Wildly Overstated by AnimalMuppet on Friday July 31, 2020 @02:11PM (#24011685)
I'm not the one you're asking. But...

Here's a data structure that represents a bill of materials. It has a list of components, and a total cost, which is the sum of the costs of the components on the list. That's the invariant - that the total cost is the sum of the costs of the components in the list.

If it's just a structure, then someone can add or remove a component, and forget to update the total cost, and the invariant is violated. But if it's an object, if the code is bound to the data (in the way OOP normally calls encapsulation), then only the member functions can modify the structure. So if you want to add a component, you have to use the object's addComponent method, which (in a properly debugged object) isn't going to forget to update the total cost.

Now, you could say that the structure could have a code library to go with it, and that could have an addComponent function. That's true. But the user doesn't have to use that function - they can mess with the list directly, if they think they know what they're doing. Whereas with OOP encapsulation, they have to use the existing function. That function can guarantee that the object's invariants are maintained.

Re:The Case Against OOP Is Wildly Overstated by correct_horse on Friday July 31, 2020 @04:17PM (#24013443)
This is generally accurate, but I want to highlight the awesomeness of opaque structs. In C you can declare a struct in a header file, but not its fields ie struct point;. Then in the corresponding c file you can write out the whole definition ie struct point {x: float; y:float;};. Any code that includes the header can pass pointers to struct point (or pointers to pointers, etc) but can't directly pass points around because the compiler doesn't know their size.

All this said, this is basically OOP in C, and the code is still bound to the data, only it is bound by naming (point_add()) not by a scope (point.add()).

Re:The Case Against OOP Is Wildly Overstated by thebruce87m on Saturday August 01, 2020 @08:25AM (#24019943)
Isn’t this the way C++ operates under the hood, with the “this” pointer hidden?

I love opaque structures, but the one downside in embedded is they can’t be truly opaque since you want to avoid dynamic memory allocation - and therefore the place you instantiate the struct needs to know the size, and therefore members of the struct.

Re:The Case Against OOP Is Wildly Overstated by mhoad on Friday July 31, 2020 @06:45PM (#24015124)
This might sound stupid but I have ONLY ever known OOP in the Ruby / C++ / Java sense before but this idea blew my mind as such an interesting and different way of thinking about it and I can't tell if it is just my own bias but my initial thought is that it seems like such an additional level of mental overhead that you would always have to carry around on top of everything else you already have to think about. I assume that becomes easy with time?
Re:The Case Against OOP Is Wildly Overstated by lmm on Friday July 31, 2020 @09:59PM (#24016668)
It's the opposite - you can spend less time worrying about the details because you know they're opaque. It's like how in Java it can actually be easier to work on a generic datastructure (e.g. a tree) than a more concrete implementation (e.g. a tree of integers) - the generics force you to cleanly separate the structure-specific parts and the value-specific parts and not get them mixed up.

You can achieve the same kind of hiding in Java by using an existential type. E.g. you could have a library that looked like:

    interface Cursor<T> {
      T start();
      T nextStep(T currentState, int move);
      void finish(T);
    }
    class DataStructure {
      Cursor<?> traverse();
    }
And then you don't know what the internal state of the cursor is because the T type is hidden from you, but the compiler checks that you always call nextStep() with the same state you got back from start(), and you can't possibly mix up the state from two different cursors.
Re:The Case Against OOP Is Wildly Overstated by thu2111 on Saturday August 01, 2020 @06:53AM (#24019461)
It's just an attempt to make C slightly more OOP without using C++. A very common design pattern in GNOME, for instance.
Re:The Case Against OOP Is Wildly Overstated by ghayes on Friday July 31, 2020 @02:32PM (#24012006)
For what it’s worth, with ADTs and non-exposed constructors you can achieve the same result (i.e. only the creating module can actually _build_ such a list but other modules can read the data).
Re:The Case Against OOP Is Wildly Overstated by zozbot234 on Friday July 31, 2020 @03:06PM (#24012569)
"Abstract data types and non-exposed constructors" is enough to give you object-based code, which is not too far from a definition of "the good parts" of OOP. Though some could quibble that "object-based" doesn't include sensible ideas such as composition, interface inheritance, delegation etc.
Re:The Case Against OOP Is Wildly Overstated by chriswarbo on Friday July 31, 2020 @03:42PM (#24013021)
Classes can be used as modules, as namespaces, as datatypes, for encapsulation, etc. The problem is they're not particularly great at those things, and those concerns often become conflated.
Re:The Case Against OOP Is Wildly Overstated by tsimionescu on Friday July 31, 2020 @02:55PM (#24012399)
Sure, there are usually equivalent mechanisms in all languages, because it is a good pattern. And yes, especially in OOP purism, it can also go over board, but there are absolutely use cases where tightly binding data and code is very useful (whether you do it with private members, ADTs, forward structure declaration, name mangling etc is less relevant, I think).
Re:The Case Against OOP Is Wildly Overstated by camgunz on Friday July 31, 2020 @03:35PM (#24012937)
I think people in general are pretty OK with the data hiding part of encapsulation. Scattering application state across objects as part of encapsulation, and polymorphism and inheritance are the source of a lot of debate though. Bob Nystrom wrote the best description of the polymorphism vs. pattern matching tension I've ever read [1], and I think problems w/ inheritance are all pretty well known (method resolution, programmers becoming taxonomists, etc.)

[1]: https://craftinginterpreters.com/representing-code.html#the-...

Re:The Case Against OOP Is Wildly Overstated by joshuamorton on Friday July 31, 2020 @02:35PM (#24012070)
Actually my response would be that you just have a plain-ish vanilla list of `Component`, and a function `TotalCost(List[Component]) -> float`, which is implemented as, approximately, lambda arr: sum(x.cost for x in arr). This maintains the invariant without state.

There's a potential performance cost here, but that usually doesn't matter a whole lot.

Re:The Case Against OOP Is Wildly Overstated by TimMurnaghan on Friday July 31, 2020 @02:51PM (#24012350)
That's true - but where do you put the function? In a complex system I can end up with loads of these totalling functions scattered about. I might have gross and net versions of the total and, given human nature, they get created near the use of them. The variants then get duplicated. The objects give you a modular structure which means you can see the interface.There is a disconnect when you have to shift to the object - but you can also see when to refactor.
Re:The Case Against OOP Is Wildly Overstated by joshuamorton on Friday July 31, 2020 @03:08PM (#24012596)
There are a few answers for this: you might include common ones in the same file as the struct (see rust for how this looks, usually).
Re:The Case Against OOP Is Wildly Overstated by zozbot234 on Friday July 31, 2020 @03:09PM (#24012607)
> This maintains the invariant without state.

Yes, but this is not possible in general. For instance, what if you want to endow your List with a "MaxTotalCost", set at creation. You can't ensure that your list respects that invariant, other than by encapsulating it behind some custom interface.

Re:The Case Against OOP Is Wildly Overstated by joshuamorton on Friday July 31, 2020 @03:24PM (#24012814)
That's true, although it raises a question: is the maximum you're willing to spend a trait of your bill of materials (I'd argue no), or of some other thing, for example your overall project. In that case you could have a method that validates your BOM against your project requirements.
Re:The Case Against OOP Is Wildly Overstated by fdupress on Friday July 31, 2020 @02:03PM (#24011559)
A good example would be a complex state machine, where you rely on the fact that the state is only modified by the state machine code to make sure it remains well-formed, and the control-flow itself heavily relies on the state being well-formed (think of a TLS session, for example).

But then again, what you want there is modularity, which OOP provides, but is also well-supported in other paradigms.

Re:The Case Against OOP Is Wildly Overstated by Gibbon1 on Friday July 31, 2020 @04:32PM (#24013640)
Yeah but you don't need OOP to do that. See opaque pointer's in a number of non OOP languages.
Re:The Case Against OOP Is Wildly Overstated by billisonline on Saturday August 01, 2020 @03:27PM (#24023189)
You don't need OOP to do anything! But in the state machine example, it provides a coherent and readily understandable metaphor (object modifies its own private state; callers can tell it what to do but not how) for the task at hand. Isn't that the goal of a programming paradigm?
Re:The Case Against OOP Is Wildly Overstated by augustk on Friday July 31, 2020 @05:07PM (#24014108)
These are called Abstract Data Types.
Re:The Case Against OOP Is Wildly Overstated by garethjrowlands on Saturday August 01, 2020 @09:40AM (#24020355)
This paper describes the differences between objects and ADTs, https://www.cs.utexas.edu/users/wcook/papers/OOPvsADT/CookOO...
Re:The Case Against OOP Is Wildly Overstated by lkrubner on Friday July 31, 2020 @01:01PM (#24010723)
I was about to write exactly this. In 2014 I wrote an essay that has been discussed here on Hacker News several times [1]. When I re-read it now, parts of it seem very subtle, parts of it seem to be matters of opinion, but what jumps out is how really dangerous it is to tightly bind data with behavior, especially because this then leads to the problem of initiation (which I devote a lot of time to talking about in the essay).

[1] Object Oriented Programming Is An Expensive Disaster Which Must End

http://www.smashcompany.com/technology/object-oriented-progr...

Re:The Case Against OOP Is Wildly Overstated by cellularmitosis on Friday July 31, 2020 @06:13PM (#24014837)
Thank you for this. I am so tired of this exchange:

    A: OOP isn't so bad, actually.
    B: But what about all these terrible messes?
    A: Oh, that's not a problem with OOP,
       they're just doing it wrong.
I'm sorry, but when 80% of the industry (and 100% of new grads) are "just doing it wrong", it isn't helpful to no-true-scotsman the critics.

The only way I see out of this endless game of semantics is for someone to canonize the tightrope of practices which are "OOP done right", and then give it a different name.

Re:The Case Against OOP Is Wildly Overstated by Ace17 on Saturday August 01, 2020 @03:57AM (#24018626)
> The only way I see out of this endless game of semantics is for someone to canonize the tightrope of practices which are "OOP done right", and then give it a different name.

Our industry has a naming problem when it comes to practices, especially when the practice is subtle and complex but its name is simple and trendy (maybe it's not specific to software, IDK).

Dev teams are mislead into thinking that they can deduce the practice from the name (and maybe a 1h training with a self-proclaimed expert in the practice).

This is how we got aberrations like: - "TDD" devs writing their tests afterwards - "Agile" teams with 6-month release period - "SCRUM" masters that act as classic managers

New names referring to "good/right/trendy" practices are doomed to get claimed by "80% of the industry", in a way that doesn't respect the original practice.

Alan Kay recently said that maybe he should have called it "Message-oriented programming" ( instead of OOP ). While not having "object" mostly eliminate the risk of the "one-class-per-real-world-object" antipattern, we might as well had ended up with other anti-patterns based on wrong interpretation of what constitutes a "message".

This is why I think changing the name of any practice is inefficient. The misunderstanding isn't accidental, it's systemic (Moreover, renaming a practice would probably create even more confusion)

Names that refer to common mistakes wouldn't get claimed ; no team is going to proudly explain to their customer that they're using the "big ball of mud" antipattern, the "scrum but" team organisation, or the "debug later" dev practice.

So maybe we should better canonize OOP antipatterns?

Re:The Case Against OOP Is Wildly Overstated by saurik on Saturday August 01, 2020 @08:36AM (#24020001)
Is the problem better than 80% with other paradigms though? Even after controlling for "only smart programmers bother working in less popular paradigms"?
Re:The Case Against OOP Is Wildly Overstated by dzonga on Friday July 31, 2020 @01:54PM (#24011444)
I enjoy reading your takes, e.g the Case against Docker. It's good to have sane minds still around in the industry.
Re:The Case Against OOP Is Wildly Overstated by garethrowlands on Friday July 31, 2020 @11:15AM (#24009430)
A typical microservice tightly binds code and data, and it communicates via messages. So when a microservice is useful, it's an example of binding data and code being useful.

Though when a microservice mutates something, it's typically persisted in a database or similar (and, you'd hope, not sprinkled throughout its code). But, yeah, a bunch of communicating microservices are a lot like communicating objects - for better or worse. Same with Erlang-style actors.

Re:The Case Against OOP Is Wildly Overstated by addicted44 on Friday July 31, 2020 @01:11PM (#24010832)
Eventually data has to be bound to code. Otherwise you'd have apps where you either have functional code running and other apps that are displays of raw data.

The engineering question is what layer is it appropriate to do so. Under traditional OOP (your pre functional forward Java/C#/OOP C++), the answer was that code is almost always bound to data.

Haskell style functional programming binds code to data at the last moment possible.

The best answer is likely somewhere in the middle, depending on your application and usage. I find, for example, that UI controls work well with OOP, but most other stuff I tend to default to functional style programming.

Re:The Case Against OOP Is Wildly Overstated by demux on Friday July 31, 2020 @07:31PM (#24015593)
Declarative programming is also an option, where data is directly encapsulated into state, and programming entails describing the state transitions. SQL is a basic example of this, but it's also generally possible in other languages (eg template metaprogramming in C++). Prolog is a really cool language that operates solely on this principle.
Re:The Case Against OOP Is Wildly Overstated by mark-r on Friday July 31, 2020 @02:18PM (#24011785)
Yes, it does seem like OOP and functional are on opposite sides of a spectrum. OOP is all about having and controlling state, while functional is about being stateless. I think my own code would benefit from being more functional, but that's hard to do in a OOP infrastructure.
Re:The Case Against OOP Is Wildly Overstated by garethjrowlands on Saturday August 01, 2020 @09:22AM (#24020251)
Maybe try to aim for functional core, imperative shell, see https://www.destroyallsoftware.com/screencasts/catalog/funct...
Re:The Case Against OOP Is Wildly Overstated by Guvante on Friday July 31, 2020 @12:59PM (#24010702)
Tightly binding code and data works as long as a useful abstraction is created. Keeping the structure of a person and how to interact with that person together is a fine paradigm. Usually the issue with OO is that the abstraction isn't there and it is just half the functions to interact with the person and/or there is an expectation that certain fields are manipulated by calling code instead.

Microservices require every action you take be a message and enforce that messages are the only way to communicate which makes it easier to avoid indirect (and thus hard to track) dependencies.

For instance if the person's age is updated when you calculate their hours worked, in OO that might be hidden from view but in message passing you would at least see that a new person object came back that replaced the one you had.

None of this stops you from doing evil unobvious things with your hidden information (updating everyones age whenever anyone gets overtime) but it is usually harder to accidentally do that.

To be clear while I like microservices I think they have many problems just like OO. For instances caching becomes super complicated and there is a real cost of going over the network for everything you do. The tradeoffs are just a different set of tradeoffs.

Re:The Case Against OOP Is Wildly Overstated by jayd16 on Friday July 31, 2020 @11:20AM (#24009486)
Objects are essentially structs with namespaces and methods with implicit this params. If you can't have state then you throw structs out too.

If you're going this far, you're essentially throwing away typing as well.

Are you actually just opposed to private fields?

Re:The Case Against OOP Is Wildly Overstated by winstonewert on Friday July 31, 2020 @12:39PM (#24010434)
I think the key differentiater is that OOP (in some versions) wants to hide the data and not just implementation details.

For example, a hash map data structure hides the details of how the hash map is implemented, but it doesn't hide the data. In some versions of OO, the object should not only hide the implementation details but also the data. Any function that needs that data MUST be a method of that object. That's where things go haywire.

Re:The Case Against OOP Is Wildly Overstated by jayd16 on Friday July 31, 2020 @12:54PM (#24010628)
Hash maps hide lots of internal state though. I think the difference is hash maps have a clear, battle tested API and its obvious what should be promised by the interface and what should be internal implementation.

Devs aren't clairvoyant so when we're making a new type we might sometimes get this wrong. But this is a fundamental issue with type systems in general and not OOP, is it not?

Re:The Case Against OOP Is Wildly Overstated by MasonOfSpoons on Friday July 31, 2020 @02:02PM (#24011554)
It really isn't, as OOP languages don't traditionally provide robust mechanisms around immutability. And why would they? The core design of OOP is to wrap mutable state behind methods which control that mutation. OOP was in many ways a reaction to C; shared mutable structs are harmful, so let's invent privacy.

Most of the languages which are suggested to be superior alternatives to OOP in this thread have immutable data records and algebraic data types as core building blocks. These are very different than C-style structs, as they can provide stronger safety guarantees without a massive ream of boilerplate.

A class or method interface promises unfortunately little around essential topics like mutability, concurrency, or termination.

Re:The Case Against OOP Is Wildly Overstated by jayd16 on Friday July 31, 2020 @03:35PM (#24012934)
>The core design of OOP is to wrap mutable state behind methods which control that mutation.

That is the mechanism for immutability that is traditionally provided. It is easy to opt out of that protection.

Java and C# are getting records. They're a convenience but are in no way opposed or counter to OOP.

Re:The Case Against OOP Is Wildly Overstated by pjmlp on Friday July 31, 2020 @02:14PM (#24011717)
You can already do that via modules or fake modules in C translation units.

What OOP offers on top of modules is extendability and polymorphism.

And these two capabilities are possible to achieve in various ways.

Re:The Case Against OOP Is Wildly Overstated by addicted44 on Friday July 31, 2020 @01:22PM (#24010996)
Hash maps also don't (usually) have external effects.

There arent many hash map methods that will actually modify the data.

Standard OOP, on the other hand, seems to encourage such behavior. So, for example, a Company object could contain a bunch of Department objects, each of which contained a bunch of Employee objects.

These people objects could also be referenced in areas outside of the company object.

If I called a company.giveFinanceDepartmentARaiseInDollars(10000) function on the Company object, it would have an unpredictable impact on the Department/Employee objects. It may also have cascading effects in other parts of the application that may not be clear.

On the other hand, if you represented this as a company hashmap, with the keys the department structs, you would have to do something like the following instead:

company["finance"].employees.forEach(x => x.salary = x.salary + 10000); company["finance"].base_salary = company["finance"].base_salary 10000

This contrived example shows some of the pros/cons. OOP allows us to hide a lot of behavior/changes, which may mean less repetitive code. OTOH, it hides a lot of behavior/changes.

Re:The Case Against OOP Is Wildly Overstated by meheleventyone on Friday July 31, 2020 @02:13PM (#24011711)
I think the problem is that your example is too contrived and you can hide implementation details by just having a function giveFinanceDepartmentARaiseInDollars(company, dollarAmount) that exhibits the same issues as the “object oriented version”.

More generally the issue of global mutable state and keeping your own sanity as a developer is a problem across paradigms.

Re:The Case Against OOP Is Wildly Overstated by addicted on Friday July 31, 2020 @04:44PM (#24013785)
The real problem with my example was that I modified the strict instead of returning a new one.

My “functional” code wasn’t actually functional.

If I had written that correctly, by returning a modified copy using a map instead of modifying the strict in a loop, your example would also be covered, because the function you’re describing would not modify any of its inputs, but instead would return a new copy. And the function wouldn’t have any side effects either, so it would once again be completely clear what’s happening.

Re:The Case Against OOP Is Wildly Overstated by meheleventyone on Friday July 31, 2020 @05:19PM (#24014269)
But now you have a stale data problem.
Re:The Case Against OOP Is Wildly Overstated by garethjrowlands on Saturday August 01, 2020 @09:56AM (#24020442)
Creating a new value only gives you a stale data problem if you had pointers to the old value. You don't have to have pointers like that, it's a choice.

To take an obvious example, you might load a value from a database (company or employees, say), create a new value (with the higher salary, say), then write the new value to the database.

Re:The Case Against OOP Is Wildly Overstated by winstonewert on Saturday August 01, 2020 @11:15AM (#24021068)
I think the point being made here was that alternative approach don't eliminate the difficulties of global state. Simply using immutable object doesn't make all your problems go away, it makes them different. I think it makes them better, but let's not pretend that all the challenges of dealing with state can be eliminated.
Re:The Case Against OOP Is Wildly Overstated by garethjrowlands on Tuesday August 04, 2020 @06:12AM (#24048426)
Quite so. I was just trying to make some small suggestions on how to handle the consequences of making that object immutable.

Here are some links along the same lines:

* _Aggregate Roots_ in DDD limit pointers, https://martinfowler.com/bliki/DDD_Aggregate.html * Guidance on where to mutate, _Functional core, imperative shell_, https://www.destroyallsoftware.com/screencasts/catalog/funct...

> using immutable object doesn't make all your problems go away, it makes them different

Yes, and here is a concrete example of the kind of 'different' problems you get: nested immutable structures, say `a.b.c.d`, become harder to update than simply `a.b.c.d = newValue`. The functional solution for this is 'lenses' (and other 'optics'). My favourite Kotlin framework that I use in my day job provides lenses for HTTP - URL query parameters, request and response bodies and so on - which work very well.

Re:The Case Against OOP Is Wildly Overstated by winstonewert on Friday July 31, 2020 @02:21PM (#24011849)
Sure, hash maps hide lots of internal state which isn't relevant to outside code.

Where things would get silly is if you tried to make all state internal. But that's what some purist OO approaches would do for business objects.

Re:The Case Against OOP Is Wildly Overstated by karpierz on Friday July 31, 2020 @01:18PM (#24010930)
In what versions of OO does a hash map hide the data? The definition of a map requires that you can access the data.
Re:The Case Against OOP Is Wildly Overstated by tsimionescu on Friday July 31, 2020 @01:54PM (#24011438)
'the data' is a vague concept. Usually, a hash map doesn't expose, for example, the bu met array, or the length of the bucket array. Sure, you can ask the hash map to give you the contents associated with a hash key, but you can't access the entire data structure that the hash map represents.

By contrast, in an 'extreme procedural' style, you would have a struct that is an array of buckets and an integer, and functions that can take such a struct and return information from some particular place inside it. In normal use you would just use the function, but if you're passing your hash map to someone else, there is no longer a guarantee that the length field still matches the actual buckets, or that objects are still arranged into buckets based on their hashes.

Re:The Case Against OOP Is Wildly Overstated by winstonewert on Friday July 31, 2020 @02:17PM (#24011769)
A hashmap wouldn't hide the data. But say, a Customer object might. A purist OO might insist that you shouldn't have a GetName() method because any code which needs the Customer's name should be method on Customer.
Re:The Case Against OOP Is Wildly Overstated by UnFleshedOne on Friday July 31, 2020 @11:23PM (#24017140)
This particular example is probably a bad illustration, with all the recent rage about PII and privacy. In some cases (such as this) you want to make sure data doesn't leak all over the place and anything accessing it follows a strict path.

Anybody modifying Customer object would hopefully be in the right mindset regarding personal information, but once it gets out as a string from GetName or GetEmail, all bets are off, it gets into all kind of logs.

Anything security related is the same.

Re:The Case Against OOP Is Wildly Overstated by winstonewert on Saturday August 01, 2020 @11:12AM (#24021040)
I'm having a hard time seeing how OOP style data hiding could be effective at controlling PII. Is this a method you've put into practice?
Re:The Case Against OOP Is Wildly Overstated by mypalmike on Friday July 31, 2020 @02:54PM (#24012380)
The data is accessed through an interface, a set of functions associated with the data structure. You don't dig through internal memory structures to get the data - you call these functions. That is what "hidden" means in this context.

A better example might be a linked list. With information hiding, you manipulate the list through functions like push and pop. Without information hiding, you manipulate the pointers directly. For instance, I've worked on C codebases where linked list manipulation isn't even hidden behind macros.

Re:The Case Against OOP Is Wildly Overstated by jayd16 on Friday July 31, 2020 @03:38PM (#24012966)
Almost all hashmaps hide the internal references/pointers to the backing arrays. That's implementation state just like any other internal data. It's just so mundane, well executed and common that you forget it exists.
Re:The Case Against OOP Is Wildly Overstated by JackMorgan on Friday July 31, 2020 @11:49AM (#24009883)
Separating functions and state has nothing to do with the type system. Otherwise how could you put types on the parameters to static functions? Check out F#, OCaml, or Haskell for plenty of examples of how you can have strong static types without mixing state and functions in a scope together.
Re:The Case Against OOP Is Wildly Overstated by jayd16 on Friday July 31, 2020 @12:49PM (#24010552)
>Otherwise how could you put types on the parameters to static functions?

Object methods are just sugar for this, so whats the difference to you? When you say "separate" do you mean you just want it in different files? Different curly braces? Different namespaces?

Is it inheritance and virtual functions?

Re:The Case Against OOP Is Wildly Overstated by waffletower on Friday July 31, 2020 @01:15PM (#24010897)
It is important to note the difference between state and mutable state as I believe you are conflating the two here. There is no reason that you cannot have structs.
Re:The Case Against OOP Is Wildly Overstated by lmm on Friday July 31, 2020 @10:08PM (#24016725)
You should have data structures, but not mutable state or reference identity (two sides of the same coin). Having a bundle of structured data with functions is great. Having those functions secretly change other data somewhere else in your application (you wanted a banana but got the gorilla holding the banana and the whole jungle) is not great.
Re:The Case Against OOP Is Wildly Overstated by agumonkey on Friday July 31, 2020 @12:50PM (#24010572)
OOP was a (too) big response after an era of semi-wildness.. I believe nobody mastered the whole cake and it was rarely applied fully. Most of it is simply mental logistics convenience (most related methods are one dot away) and of syntax. car_start(&car) is noisy; car.start() a tiny bit less so.
Re:The Case Against OOP Is Wildly Overstated by tgflynn on Friday July 31, 2020 @10:52AM (#24009158)
So what is your preferred solution for programs that intrinsically need to deal with a lot of state ? Global variables ?

I used to see that type of approach in some complex Fortran simulation programs where every function referenced a huge common block. I really don't think that leads to easier to manage solutions.

Re:The Case Against OOP Is Wildly Overstated by tabs_masterrace on Friday July 31, 2020 @03:00PM (#24012476)
Ideally you want to have all your state in one place, the "single point of truth", in tightly modeled data structures, keeping it as lean and immutable as possible. The program is then just a function of the state, consisting mainly of self-contained functions, that take arguments and produce a result, without causing side effects. Realistically, that doesn't mean there are no classes or objects with internal vars, but these are more of ephemeral nature, and can be created predicatively and deterministically from your centralized global state. In the best case you can have complex applications with tens of thousands LoCs that feed from just a few dozen state variables.
Re:The Case Against OOP Is Wildly Overstated by mhoad on Friday July 31, 2020 @06:54PM (#24015205)
I must admit that does sound like a really nice code base to work inside of.
Re:The Case Against OOP Is Wildly Overstated by lgessler on Friday July 31, 2020 @11:01AM (#24009279)
Essentially, yes, but in a way that sounds more careful than what you saw in that Fortran program. If it absolutely has to be stateful, like with a db connection for example, then there's no getting around that, but what you can do is (1) not bury it in a bunch of stateful objects that didn't have to be stateful, which can cause cascading errors when either one of them misbehaves and also makes it difficult to isolate any one stateful component for testing or re-use, and (2) use special wrappers around it that will make the statefulness easier to deal with. (For examples of (2), see Clojure atoms and the Clojure library mount: https://github.com/tolitius/mount )
Re:The Case Against OOP Is Wildly Overstated by nostrademons on Friday July 31, 2020 @01:09PM (#24010814)
More concretely, for every bit of state in the program I'm interested in two big questions, each with two subquestions:

1.) Who can access this state, and which of those accesses allow writes vs. which are read-only?

2.) What is the lifetime of that state, and what portion of that lifetime is mutable vs. read-only?

Java-style OOP can control #1, but makes no distinction between reads & writes. C++ const correctness and the val/var distinction in Kotlin/Ocaml/ES6/etc. can make that distinction, but only C++ forces you to think in terms of lifetimes. Rust borrowing probably comes closest to answering all 4.

I'm still waiting for a language feature that lets you say "This field of this struct is only mutable while this module is running, and once it completes it will never be changed", though. A lot of data structures are initialized in passes and then passed along as constant data: you construct the basic object structure with nothing but a few IDs, then you compute extra fields as necessary, then you're done and the object is never written to again. If you could keep the fields mutable during initialization (which may be a longer process than just constructor calls) and then seal them off once that's complete, you eliminate a whole class of bugs where a read-only client decides to mutate a field that should only be mutated from designated initializer.

Re:The Case Against OOP Is Wildly Overstated by lmm on Friday July 31, 2020 @10:04PM (#24016699)
> I'm still waiting for a language feature that lets you say "This field of this struct is only mutable while this module is running, and once it completes it will never be changed", though. A lot of data structures are initialized in passes and then passed along as constant data: you construct the basic object structure with nothing but a few IDs, then you compute extra fields as necessary, then you're done and the object is never written to again. If you could keep the fields mutable during initialization (which may be a longer process than just constructor calls) and then seal them off once that's complete, you eliminate a whole class of bugs where a read-only client decides to mutate a field that should only be mutated from designated initializer.

Why do you want to think of it as "the same" struct? It seems to me that the way to achieve this is having the partially initialised thing be a different type than the fully initialised thing, along with a linear type system that makes sure the partially-initialised one is consumed in the process of making the fully-initialised one.

Re:The Case Against OOP Is Wildly Overstated by nostrademons on Saturday August 01, 2020 @02:36AM (#24018222)
You can do this, but unless all the intermediate types are auto-generated by the compiler, it's going to be a lot of typing (of the keyboard type). Many structs that require multi-pass initialization have many, many fields. Each field that isn't late-initialized is going to be duplicated for each following pass. That's the type of maintenance headache that compilers are meant for.
Re:The Case Against OOP Is Wildly Overstated by lmm on Saturday August 01, 2020 @04:04AM (#24018661)
If you have higher-kinded types and a working record system you can do it by transforming your existing types. Even in more limited languages you might be able to make it manageable with phantom types, e.g. Java's "type-safe builder pattern".
Re:The Case Against OOP Is Wildly Overstated by MasonOfSpoons on Friday July 31, 2020 @02:52PM (#24012357)
Pure functional languages are capable of this, although they likely aren't modeling it as you envision. Pure record constructors let you do perform arbitrary mutation on the stack (e.g. calling other functions to build field values), but once the constructor is called the returned reference is immutable.

This is likely cleaner than sharing a reference which is sometimes mutable and sometimes not. Rust of course allows for both mutable and immutable borrows, and that's a very powerful tool but it'd be complex if all you needed was field initialization.

The consensus across languages that's emerged is that initialization shouldn't be a group effort, with references escaping in various stages of partial initialization. Be it RAII in C++ or functional record constructors, the common theme is that initialization should be a single operation that can succeed or fail as a whole.

Re:The Case Against OOP Is Wildly Overstated by nostrademons on Friday July 31, 2020 @04:19PM (#24013471)
It's the consensus among languages, but I've got a pretty large collection of application code that does need to partially initialize in passes, and there's also a fairly long list of escape hatches in languages (eg. lateinit in Kotlin, friend in C++, builder pattern in Java) to let you do this. Languages are supposed to capture common patterns; I'd argue this is a common pattern that isn't captured all that conveniently by existing language mechanisms, though a number have tried.
Re:The Case Against OOP Is Wildly Overstated by bpolverini on Friday July 31, 2020 @01:34PM (#24011191)
That would be really cool, but I think enforcing that is undecidable. My gut tells me that having that language feature at compile time is the same as the Halting Problem.
Re:The Case Against OOP Is Wildly Overstated by nostrademons on Friday July 31, 2020 @04:14PM (#24013401)
In its full generality it's undecidable, but there are probably restrictions you can build into the type system to make it decidable. I was thinking something along these lines:

  class Symbol {
    @init(constructor) originalToken: Token
    @init(constructor) position: SourceLocation
    @init(Parser.parse) scope: SymbolTable
    @init(Parser.parse) declaredType: Type
    @init(TypeChecker.typecheck) inferredType: Type
    @init(DataFlowAnalyzer.computeLiveness) usages: List<Expr>
  }
And then the type system carries an extra bit of information around for whether a reference is fully-constructed or not, much like const-correctness. Fields marked with @init can only be written on a reference that's not fully-constructed. There's no compile-time enforcement for initialization order, though it'd be pretty easy to do this at runtime (convert them to null-checks or special not-initialized sentinel values). Newly-created references start out with the "initializing" bit set, but once they're returned from a function or passed into a function not in the list of legal accessors, they lose this bit unless explicitly declared.

It's basically the same way "mutable" works (in languages that support it), but with a separate state bit in the type system and extra access checks within the mutating functions to make sure they only touch the fields they're declared to touch. You can fake this now by passing mutable references into initialization functions and then only using const, but it's a bit less specific because many classes are designed to be long-term mutable through 1-2 specific public APIs but also need to be mutated internally for deferred initialization, and lumping these use-cases together means that deferred fields can be touched by the public API.

Re:The Case Against OOP Is Wildly Overstated by tgflynn on Friday July 31, 2020 @01:44PM (#24011318)
I suspect that the ideal language (at least for human use) is one that is just shy of Turing completeness. Once a program compiles and an initial configuration phase has passed all loops would be bounded and all recursions would be guaranteed to terminate. Except for the case of programs that aren't supposed to terminate for which there would be a single construct allowing wrapping everything inside one and only one infinite loop.
Re:The Case Against OOP Is Wildly Overstated by tgflynn on Friday July 31, 2020 @01:37PM (#24011226)
(2) sounds very similar to the way I have typically handled db access in C++. However the kind of state I was referring to is more about the internal computational data used by the program than about external resources.
Re:The Case Against OOP Is Wildly Overstated by fish45 on Friday July 31, 2020 @05:59PM (#24014696)
ECS architecture is IMO very frictionless no matter how much state you have
Re:The Case Against OOP Is Wildly Overstated by waffletower on Friday July 31, 2020 @01:00PM (#24010717)
You might want to consider examining another programming language for clues here. Perhaps look to a language that has a more modern approach to state such as Clojure.
Re:The Case Against OOP Is Wildly Overstated by tgflynn on Friday July 31, 2020 @01:33PM (#24011172)
My understanding is that Clojure is basically lisp implemented inside the Java ecosystem. I'm not sure how that makes it "modern" given that the only higher level language older than lisp is the original version of Fortran.
Re:The Case Against OOP Is Wildly Overstated by waffletower on Friday July 31, 2020 @02:58PM (#24012453)
Once you have some understanding of the state management facilities native to Clojure, you might be willing to concede the "modern" adjective.
Re:The Case Against OOP Is Wildly Overstated by dkersten on Friday July 31, 2020 @09:56PM (#24016652)
That like saying Go/Rust/Kotlin are just Algol, what’s so modern about them? Lisp isn’t a language anymore, it’s a category of languages and it’s members are rather different from each other besides some superficial syntax style. Common Lisp, Scheme and Clojure are three very different languages, certainly more different than Ruby is from Python IMHO.

Clojure, in 2020, is very very different from the Lisp of 50 years ago and is modern in many respects, even compared to other popular languages.

Re:The Case Against OOP Is Wildly Overstated by tsimionescu on Friday July 31, 2020 @03:04PM (#24012541)
Clojure has quite a few specific libraries. As far as I know, one of these implements a lot of persistent data structures - data structures that make it efficient to expose an API that returns a copy of the whole structure for any mutation (by sharing all of the unmodified substructure behind the scenes).
Re:The Case Against OOP Is Wildly Overstated by pjmlp on Friday July 31, 2020 @02:16PM (#24011750)
Modules with responsibility to handle the specific set of states, which are basically final classes.
Re:The Case Against OOP Is Wildly Overstated by dionian on Friday July 31, 2020 @10:54AM (#24009182)
I don't see why the Law of Demeter cannot be adhered to in OOP. I do it every day.
Re:The Case Against OOP Is Wildly Overstated by juniper_strong on Friday July 31, 2020 @08:51PM (#24016227)
Me too. I also violate it every day. Just this day I used System.out.println, for example.
Re:The Case Against OOP Is Wildly Overstated by hderms on Saturday August 01, 2020 @10:55AM (#24020884)
Yeah imo law of demeter shouldn't apply for namespace organization of static, globally relevant functionality. The amount of dots in that case is irrelevant to me because it doesn't really imply changing context in the same way. more like drilling down in a phonebook than calling your neighbor and telling them to call Bob for you
Re:The Case Against OOP Is Wildly Overstated by Barrin92 on Friday July 31, 2020 @10:36AM (#24008953)
The entire point of OOP is to encapsulate state within objects and to have objects communicate through messages, that is to say to 'program without a center'. Global or interconnected state is if anything a violation of OO principles.

In proper OO state is hidden and insofar as it causes issues it does so in a way that is handled by the object rather than the program overall.

Also treating code as data isn't a feature of OO, it's an old idea starting with Lisp and metaprogramming I suppose and it's present in functional languages as well. It basically just means that the language itself is a first class data type within the language.

Re:The Case Against OOP Is Wildly Overstated by throwaway894345 on Friday July 31, 2020 @10:45AM (#24009059)
> The entire point of OOP is ...

One problem is that every OOP advocate has a different perspective on "what the entire point of OOP is". Another problem is that irrespective of what any OOP advocate believes is OOP, the body of code that is commonly understood to be "OOP" is plagued with abuses of inheritance (I'm not even convinced there are legitimate uses), mutable state, the "banana with a reference to the gorilla holding it with a reference to the entire jungle" problem. OOP advocates are quick to say "that's not real OOP" in a very no-true-scotsman fashion, but that aspirational statement isn't comforting to people who have to deal with these problems day-in-and-day-out.

> Also treating code as data isn't a feature of OO, it's an old idea starting with Lisp I suppose and it's present in functional languages as well.

The parent specified that their objection was about tightly binding data to code, not about treating data as code.

Re:The Case Against OOP Is Wildly Overstated by tsimionescu on Friday July 31, 2020 @03:12PM (#24012652)
The problem with lookibg at bad X code and concluding X is bad is that X can be anything.

It's true that bad OO code suffers of different problems than bad FP code, and both are different from bad procedural code. But there is no guarantee that an organization which produced bad OO code would have produced good FP code, just as there was never a reason to imagine (though many did) that an organization that produced bad procedural code would produce good OO code if forced to switch to OO.

In general, there is no solver bullet. We can absolutely replace the problems specific to bad OO code with problems specific to bad FP code if we move from OO to FP, but we cant be sure of any other outcome.

More likely than not, we need to change more than the style of code we build if we want to take an org that has produced bad code and make it produce good code - we should change incentives, testing, goals, timelines etc.

And just to be clear, you're absolutely right that saying 'that's not good OO code' is no-true-Scotsman and not helpful in any way, other than pointing out that it is possible to produce good OO code (some people doubt that, I think).

Re:The Case Against OOP Is Wildly Overstated by throwaway894345 on Friday July 31, 2020 @03:42PM (#24013029)
> The problem with lookibg at bad X code and concluding X is bad is that X can be anything.

The difference is that FP, procedural, data oriented, etc are all pretty reasonably defined. No one seems to agree with what OOP is, and any objection to the kind of code that is typically considered "OOP" is that "that's not real/good/etc OOP code". It's a no true Scotsman.

When I talk with OOP proponents and point to issues about inheritance or the gorilla/banana/jungle problems, they say that these things aren't part of OOP. I think when you deduct from OOP these kinds of warts, you end up with something that looks almost indistinguishable from data oriented programming (something like what you would write in Go or Rust) and increasingly something that resembles functional programming specifically now that many OOP languages have support for first class functions and more functional abstractions in their standard libraries.

So if there is any truth in the "not true OOP" argument, I think it's that "good object oriented programming" is just another spelling of "data oriented programming".

Re:The Case Against OOP Is Wildly Overstated by tsimionescu on Friday July 31, 2020 @04:08PM (#24013325)
I think that there are two groups that try to claim OOP.

One is the Alan Kay camp, which usually defines OOP as primarily message passing, with Smalltalk as a beacon of what they consider good code. This is a very vocal group, but I think that it is extremely obscure in the industry.

The other group is mostly focused on SOLID and design patterns. I would say that Java's Swing is a good example of a usable library based on this style of code, inheritance-heavy but still principled.

I believe that this style of code is most reliant on garbage collection to actually be reasonable. Otherwise, you end up caring about ownership for every little object and it rapidly becomes a nightmare. I believe your banana/gorilla/jungle problem is related to this mostly.

For myself, I do believe that implementation inheritance is usually to be avoided, but I think that other OOP concepts, such as encapsulation and interface-style extensibility, using constructors to establish invariants, are frequently useful, especially in the high-level architecture of a program or module. I do prefer some kind of support for sum types and multiple dispatch, rather than traditional virtual dispatch.

Re:The Case Against OOP Is Wildly Overstated by humanrebar on Friday July 31, 2020 @10:47AM (#24009085)
I think you miss the point. The behavior and state of an object in OOP is the aggregation of the code and state of its classes (including ancestors), mixins (if applicable), and members.

Some of those things still apply in non-OOP style programming, but OOP certainly has a larger cognitive load for many nontrivial applications.

Keeping code and state more decoupled actually reduces cognitive load in many cases. In some of those, there is less encapsulation, but at least IMO OOP overshoots for how much encapsulation is productive.

Now, I am not religious about this and regularly approve OOP designs in reviews. But my general approach is to prefer modules and packages of functions for behavior, plain structures for state, and only dip into OOP style encapsulation when it seems the extra encapsulation and bundling is worth it. A class modeling a mutex or other resource would qualify there.

Re:The Case Against OOP Is Wildly Overstated by thom on Friday July 31, 2020 @10:43AM (#24009034)
I'm not sure you're responding directly to the point the parent made. Even if state is encapsulated, objects are mutable. Many people believe reasoning about programs in which lots of mutable objects coordinate is harder than some of the alternatives (e.g. pure functions, immutable data etc).
Re:The Case Against OOP Is Wildly Overstated by Barrin92 on Friday July 31, 2020 @11:06AM (#24009334)
depends on the domain. In anything that has say, a very structured 'data flow' in one direction, like in finance or accounting or versioning immutability works well as a concept. In other domains like say, game development it feels forced and out of place.

If actual usage of paradigms is an indication rather than belief then it doesn't look like functional programming really is intuitive, it tends to be very useful in certain niches.

Re:The Case Against OOP Is Wildly Overstated by thom on Friday July 31, 2020 @07:33PM (#24015613)
Is it a wild simplification to suggest that the inner loop of every game is the state now, some processing at the current time step, and a new state to be rendered?
Re:The Case Against OOP Is Wildly Overstated by jeffffff on Friday July 31, 2020 @11:49AM (#24009880)
game development seems to be moving away from OOP and towards entity component systems and data oriented design. i've heard arguments that OOP's killer application is desktop guis, which i could buy, but those become less and less relevant daily. (caveat: my experience is entirely in back end and low level software and anything i say about front end or ui development should be highly suspect)
Re:The Case Against OOP Is Wildly Overstated by dllthomas on Friday July 31, 2020 @02:08PM (#24011636)
> entity component systems

Nitpick, but I'm not sure this is the correct plural.

As you may very well know (but just in case, and for others), the "system" in ECS doesn't describe ECS as a whole, but another part of the model - you have entities, attributes of those entities, and systems that operate on those attributes.

That said, I'm not sure what I'd suggest instead. "Entity component system systems" is obviously terrible. Just not pluralizing probably works, here? or "towards the entity component system pattern"?

... shrug

Re:The Case Against OOP Is Wildly Overstated by tsimionescu on Friday July 31, 2020 @03:18PM (#24012715)
I think the point was that game development is an inherently stateful domain, which ECS recognizes (if anything, ECS is more stateful than OOP, not less). In contrast, using a pure FP language would probably create a lot of friction with many common styles and even algorithms used in games programming (think about how ugly and out of place actual quicksort looks in Haskell).
Re:The Case Against OOP Is Wildly Overstated by meheleventyone on Friday July 31, 2020 @01:07PM (#24010789)
You can still program in a data oriented manner using OOP. It is after all just about watching data access patterns in view of the hardware constraints and organizing along those lines.

What there actually is in game development is a definite wish for a simpler language than C++ and dislike of many of the newer parts of it.

Re:The Case Against OOP Is Wildly Overstated by chongli on Saturday August 01, 2020 @06:51AM (#24019444)
entire point of OOP is to encapsulate state within objects

And that’s the fundamental problem with OOP. State can’t be encapsulated. It’s highly radioactive. State should be kept to the boundaries of your application, where it interfaces with the real world, and minimized as much as possible. The core should be immutable.

Re:The Case Against OOP Is Wildly Overstated by wwright on Friday July 31, 2020 @02:38PM (#24012114)
I think "tightly binding data and behavior" is a less-ambiguous way of phrasing the pitfall. Obviously code goes great with data; no one wants to work with strings as raw buffers all the time!
Re:The Case Against OOP Is Wildly Overstated by AnimalMuppet on Friday July 31, 2020 @02:01PM (#24011538)
If your program has statefulness (worse, has to have statefulness), then it seems better to control where it is (encapsulate it), rather than letting it run all over the place in the program.

And, if you have code that is for working on a particular kind of data, why is binding it to the data problematic?

Re:The Case Against OOP Is Wildly Overstated by ysavir on Friday July 31, 2020 @01:19PM (#24010942)
Can you expand on your opinion? Do you consider all instances of binding data and code dangerous?
Re:The Case Against OOP Is Wildly Overstated by baryphonic on Friday July 31, 2020 @10:49PM (#24016935)
> This doesn't speak to what I consider some of the most dangerous parts of OOP, which include the assumptions that tightly binding data and code is helpful,[...]

I don't agree at all. It's much more dangerous to separate data representation from the code that manipulates the data. I can't tell you how many bugs I've found and had to fix in large codebases (most of which are procedural-code-in-"OOP"-languages) that result from some horrific evolving arrays-and-records structure not recording intent and validity constraints properly (since that would require, you know, code). Instead, each interaction with the Holy Data Structure requires the code to go to confession, recite ten Hail Marys and five Our Fathers before receiving the Almighty's state-changing grace, mercy and peace; failure to do so will result in immediate confinement in purgatory, and possibly damnation.

I'm not being hyperbolic albeit a bit facetious about this. "Data" itself is the problem: it is subjective, and so requires a lot of tinkering for a programmer to grok. That tinkering transforms it into information, but only in the programmer's head, which is less than ideal since it's outside of the program. If that information fades away, it must again be rebuilt (or worse, be short circuited so a hotfix can go out to prod).

> and that statefulness is fine to freely sprinkle throughout your program.

I agree much more with this, with the condition that shared statefulness sprinkled throughout is the problem. An object should be treated with the same respect we would show a VM or even a person: decent ones would not tolerate having an external entity reach in and manipulate things like memory, nor would they be so care-free as to depend on and trust literally everything they are told. I think the big problem here is that few or no OO languages are powerful enough to allow for this kind of arrangement to be the norm. But it is a valid criticism and should be taken more seriously by OO language designers.

EDIT: I wanted to add one more thought, which is that when I'm working on a new feature or new codebase, I tend to model the problem first in a procedural style. Then I rewrite it as objects. I've had very little luck trying to do objects first (though I think this is just me), because decomposing the problem space is just hard to do de novo. But once I understand the problem, it's easier to see the constraints and issues.

Also, certain code that doesn't need to worry about things like noisy channels (e.g. Dijkstra's shortest path algorithm) is probably a good candidate for non-OO code. OO is good for the large amount of software that interacts with people across multiple machines and environments, rather than isolated from everything in just a single machine.

Re:The Case Against OOP Is Wildly Overstated by mimixco on Friday July 31, 2020 @10:28AM (#24008858)
Agreed. The biggest problem with OOPS lies in its original premise: that code and data should be the same thing!

This is grevious error, IMHO, that leads to nothing but problems: endless boilerplate code, lots of "interfaces" that essentially do nothing (that couldn't be done directly with said data), and debugging nightmares.

I much prefer to work with systems where code and data are separate and never the twain shall meet.

Re:The Case Against OOP Is Wildly Overstated by michaelcampbell on Friday July 31, 2020 @10:35AM (#24008930)
OOPs original premise is homoiconicity? Really?
Re:The Case Against OOP Is Wildly Overstated by TOGoS on Friday July 31, 2020 @10:54AM (#24009199)
I'm pretty sure what was meant by 'code is data' is that a lot of OOP training encourages you to "bundle the code and the data in an object". People take that to heart, and...bundle code and data into objects. Whether or not those functions and that data really belong in the same object is an afterthought, if considered at all.
Re:The Case Against OOP Is Wildly Overstated by TheOtherHobbes on Friday July 31, 2020 @12:44PM (#24010494)
I'm not sure anyone really knows what OOP's original premise is.

There are various legends, and they mostly conflict with each other.

Re:The Case Against OOP Is Wildly Overstated by MasonOfSpoons on Friday July 31, 2020 @05:46PM (#24014567)
It feels a bit like a rhetorical device to discuss OOP in any context other than the version of Java that's currently in widest usage.
Re:The Case Against OOP Is Wildly Overstated by goatlover on Friday July 31, 2020 @01:47PM (#24011347)
It was whatever Simula and then Smalltalk's goals were.
Re:The Case Against OOP Is Wildly Overstated by winstonewert on Friday July 31, 2020 @10:55AM (#24009214)
I presume "code and data are really the same thing" is intended to refer to way that OOP binds code and data together.
Re:The Case Against OOP Is Wildly Overstated by throwaway894345 on Friday July 31, 2020 @10:50AM (#24009121)
I'm not sure "code is data" necessarily means "homoiconicity", but it could mean "first-class functions" (or at least that's what I think of when I hear the phrase; maybe I'm wrong); however, I'm not familiar with anyone who argues that these are fundamental OOP features (perhaps Smalltalk had first class functions, but for a very long time the most popular flavors of OOP did not).
Re:The Case Against OOP Is Wildly Overstated by _old_dude_ on Friday July 31, 2020 @11:10AM (#24009374)
yes,

Homoiconicity is about having the same syntax for both structure and data.

First class functions means there is no conversion, again at syntax level, between a function and a value.

Mainstream languages all have a way to see code as data, it's function pointer in C, delegate and lambda in C# and first class functions in Python or JavaScript.

Re:The Case Against OOP Is Wildly Overstated by throwaway894345 on Friday July 31, 2020 @01:15PM (#24010895)
I understand the differences between homoiconicity and first class functions and even that modern languages often support them, but that support is typically an artifact of a functional (and not OOP) influence with the exception of function pointers in C whose origins im not sure about except that it doesn’t come from OOP. The point is that despite the confusion about “what does OOP mean, really”, there are no prominent arguments that suggest that homoiconicity or first class functions are defining characteristics.
Re:The Case Against OOP Is Wildly Overstated by prostodata on Friday July 31, 2020 @01:33PM (#24011165)
I think both conceptions are important. On one hand, some code is naturally related to certain data and hence we should accordingly design the program. On the other hand, complex and distributed programs have code which must be dynamically bound to different data. OOP focuses on only one aspect but does it very well. How to adequately support the opposite aspect is not clear. At least there are many ways how this can be done.
Re:The Case Against OOP Is Wildly Overstated by tehjoker on Friday July 31, 2020 @01:56PM (#24011480)
This reads like a rejection of von Neumann architectures. I don't think this is quite right.

https://en.wikipedia.org/wiki/Harvard_architecture