Most active commenters
  • chipdart(3)
  • ryao(3)

←back to thread

249 points mattcollins | 18 comments | | HN request time: 1.529s | source | bottom
Show context
cutler ◴[] No.42190248[source]
OOP is an industry of its own which generates a ton of incidental complexity. See "Object-Oriented Programming is Bad" by Brian Wills (https://www.youtube.com/watch?v=QM1iUe6IofM) and most of Rich Hickey's excellent videos, especially his keynote at Rails Conf 2012 where he basically told the Ruby crowd they're doing it wrong (https://www.youtube.com/watch?v=rI8tNMsozo0).
replies(4): >>42190770 #>>42191094 #>>42191386 #>>42191490 #
1. chipdart ◴[] No.42191386[source]
> OOP is an industry of its own which generates a ton of incidental complexity.

I think you're confusing "OOP is used in projects and I've seen accidental complexity in projects" with "OOP generates accidental complexity".

The truth of the matter is that developers create complexity. It just so happens that the vast majority use OOP.

I challenge you to a) start by stating what you think OOP is, b) present any approach that does not use OOP and does not end up with the same problems, if not worse.

replies(3): >>42193090 #>>42193446 #>>42193844 #
2. galangalalgol ◴[] No.42193090[source]
a) I'm not sure what OOP is, and it doesn't seem like the people who tout it are either. I'm sure someone would look at code I think is good and call it OOP, and someone who wouldn't. It is so many buzzwords old at this point that using it is more a label of a viewpoint than a coding style. Combined with the book's apparent focus on TDD and carefully selecting names, it zeros me precisely in on a set of people I have worked with over the years. I don't, as a rule, like the code those people generate.

b) The best style is no style, or at least pick a more recently popular dogma like FP, at least it gets you easy/safe parallelism in exchange for throwing some of the tools out of your toolbox.

replies(1): >>42197238 #
3. InDubioProRubio ◴[] No.42193446[source]
OOP is a mental crutch that breaks complex problems down into a easy mentally discoverable world/domain model with objects that have a life of their own, that is capable to derive correct results to complex problems via the relations of the objects.

Meanwhile its creators can not hold the whole complexity in mind (often barely in spec) and still can produce a artifact that produces correct results.

4. nailer ◴[] No.42193844[source]
A. OOP as practically implemented for the last 25 years is glueing functions to state

B. Functions and structs.

replies(2): >>42195309 #>>42195764 #
5. corytheboyd ◴[] No.42195309[source]
In the real world, where many people of varying backgrounds and skill levels are editing the same code, if the OOP method becomes a mess, why wouldn’t the functional approach also become a mess? I think that is more the point OP was making. In a vacuum with a single perfect Adonian programmer, seems like the OOP and functional approaches would becomes the same level of maintainable, because we’re in a vacuum of perfection anyway.
replies(1): >>42195675 #
6. lioeters ◴[] No.42195675{3}[source]
In my experience, the mess created using OOP is harder to untangle than the mess created using a functional approach. With the latter, it's simpler to replace a different function for any part of the logic, and the data is always just data; whereas with OOP the method is usually tied up with shared state and other functions.
replies(1): >>42195837 #
7. chipdart ◴[] No.42195764[source]
> A. OOP as practically implemented for the last 25 years is glueing functions to state

I see you opt to go with a huge amount of handwaving over the question.

> Functions and structs.

That's what a class is, and thus OOP, except it supports information hiding and interfaces. So your alternative to OOP is... OOP?

replies(2): >>42195882 #>>42196371 #
8. chipdart ◴[] No.42195837{4}[source]
> In my experience, the mess created using OOP is harder to untangle than the mess created using a functional approach.

OP complained about accidental complexity, not subjective takes on how hard it is to refactor code.

Even so, anyone who has any cursory experience with TypeScript projects that follow a functional style can tell you without any doubt whatsoever that functional style is incomparably harder to refactor than any "enterprise-grade" OOP.

replies(2): >>42196327 #>>42209066 #
9. Joker_vD ◴[] No.42195882{3}[source]
I suspect "functions and structs" here meant "functions and structs, separately, instead of gluing functions together with structs into unholy amalgams". Basically, Wirth's "Algorithms + Data Structures = Programs" idea.

Compare e.g. to "What should a language have instead of Lua-like tables? Maps and vectors" — "But that's what a table is, so your alternative to tables is... tables?"

10. nineplay ◴[] No.42196327{5}[source]
> OP complained about accidental complexity, not subjective takes on how hard it is to refactor code.

The biggest problem with accidental complexity _is_ how hard it is to refactor code. Refactoring code is a huge part of software development.

11. nineplay ◴[] No.42196371{3}[source]
>>> a) start by stating what you think OOP is

>> A. OOP as practically implemented for the last 25 years is glueing functions to state

> I see you opt to go with a huge amount of handwaving over the question.

I think the question was answered pretty clearly. You can't ask for an opinion ( "what do you think" ) and then criticize the response as 'hand-waving'.

12. layer8 ◴[] No.42197238[source]
The core of OOP is encapsulation (into objects) and polymorphic interfaces. You program against interfaces with well-defined contracts. Implementation details are encapsulated behind those interfaces. The same interface can have different implementations. The same interface-typed variable can point to different implementations at different times within the same program execution. The caller who invokes operations on an interface is supposed to not care about the implementation details behind it, and thus be decoupled from them. Interfaces can have an inheritance/subtyping relationship. (Implementations may as well, but that’s optional.) This enables abstracting over the commonalities of several related interfaces without having to introduce an adapter/proxy object. That’s basically it.
replies(1): >>42197665 #
13. ryao ◴[] No.42197665{3}[source]
After making those interfaces, the moment you need to do something that breaks those interfaces, you suddenly have a headache. I wrote a program in college that daemonizes by being an instance of a daemon class. Years later, people wanted the option to not daemonize. With C, this would be easy. With the way that I did things according to OOP principles in C++, I need to delete all of the code related to starting the program and write it from scratch.

You could say that I just did not do it right, but that is the problem. You need to know precisely what the future will want to do it right and that is never possible to know in advance. OOP encapsulation is heavily overrated. There are a ton of headaches in C++ that do not exist in C because C does not try to do these things. Ever hear of the diamond problem? It does not exist in C. Nonsensical types that span multiple lines when trying to figure out why there is a type error? Not an issue in C either.

C++ was advertised as reducing complexity, but in reality, it that encourages developers to drown themselves in complexity. If it were not for C never gaining a widespread STL equivalent, C++ would be far less popular. Sun Microsystems did make libuutil to provide such facilities, but sadly, it never caught on outside of Sun Microsystems technologies. The BSD sys/queue.h is the closest we have to it, but it is only for lists, and we need trees too to get a good equivalent to the C++ STL. That said, libuutil is available through ZFS, so it is not that people cannot adopt its awesome AVL tree implementation on other platforms. It is just that people do not know about it.

replies(1): >>42198296 #
14. carmackfan ◴[] No.42198296{4}[source]
Your problem was a misuse of inheritance, not encapsulation or interfaces.
replies(2): >>42199144 #>>42204087 #
15. Sohcahtoa82 ◴[] No.42199144{5}[source]
Misuse of inheritance is often the biggest generator of criticism of inheritance, sadly.

People use the wrong tool for the job, or use it incorrectly, and then blame the tool. It's like using a hammer to play drums, obliterating the drum set, then ranting against hammers.

replies(1): >>42204106 #
16. ryao ◴[] No.42204087{5}[source]
That is exactly what I said you could say:

> You could say that I just did not do it right, but that is the problem. You need to know precisely what the future will want to do it right and that is never possible to know in advance.

Every time inheritance causes a headache, you can call it a misuse of inheritance, but that is only obvious after you have been to the future.

17. ryao ◴[] No.42204106{6}[source]
OOP is a tool that causes people to hang themselves with it by design. The only way to avoid misusing it is to be to the future to see the impact of every single decision involving it to make only the ones that do not cause problems.
18. nailer ◴[] No.42209066{5}[source]
> Even so, anyone who has any cursory experience with TypeScript projects that follow a functional style can tell you without any doubt whatsoever that functional style is incomparably harder to refactor than any "enterprise-grade" OOP.

My experience differs greatly. One can see functional style has taken off in the TS world, particularly with the popularity of React, so I suspect I'm not alone.