TE
TechEcho
Home24h TopNewestBestAskShowJobs
GitHubTwitter
Home

TechEcho

A tech news platform built with Next.js, providing global tech news and discussions.

GitHubTwitter

Home

HomeNewestBestAskShowJobs

Resources

HackerNews APIOriginal HackerNewsNext.js

© 2025 TechEcho. All rights reserved.

A Healthy Hatred of OOP, or the principles of my message-driven framework

87 pointsby rlt3about 9 years ago

19 comments

jasodeabout 9 years ago
Your essay is arguing against a strawman of what &quot;good&quot; OOP is supposed to be. Your examples...<p><i>&gt;Objects just aren&#x27;t supposed to be reaching into each other with &#x27;getters&#x27; and &#x27;setters&#x27; and messing with information. </i><p>The getX() and setX() is an <i>anti-pattern</i> of good OOP.<p><i>&gt;Instead of using objects for compartmentalizing functionality, they were just used as a holding pen for loosely related functions. </i><p>No, good OOP has class&#x2F;object with <i>both</i> private state and associated functions combined to provide a <i>public interface</i> for clients to use.<p>(Although Java &amp; C# (unlike C++) may have muddled this aspect because their language specification does not allow &quot;free&quot; functions to live in a plain namespace. Therefore, programmers are forced to use the &quot;class{}&quot; keyword with static functions as a workaround. Maybe that&#x27;s where your &quot;holding pen&quot; characterization came from?)<p><i>&gt;A traditional OOP approach uses shadowy architecture to remove the responsibility of an object,</i><p>No, good OOP tries to <i>push responsibility</i> into classes&#x2F;objects so they can act as independent agents with minimal coupling to the outer context they sit in.<p>I&#x27;m guessing your comments are based on seeing a lot of poor practices masquerading as OOP which affects what you think OOP actually is. Unfortunately, it&#x27;s like trying to argue against Javascript because of overuse of &quot;eval()&quot; or arguing the flaws of Haskell because variable names are often 1 character long.<p>There are definitely problems with OOP but they are not the bullet points you mentioned.
评论 #11480417 未加载
评论 #11480606 未加载
评论 #11481699 未加载
评论 #11480360 未加载
评论 #11481174 未加载
评论 #11480868 未加载
评论 #11481044 未加载
评论 #11480491 未加载
评论 #11483379 未加载
评论 #11483037 未加载
评论 #11483437 未加载
评论 #11481618 未加载
评论 #11481700 未加载
barrkelabout 9 years ago
The OOP referred to in this article is certainly a straw man, but the alternative suggested has problems too.<p>Teams that work well act almost like they&#x27;re mind-reading one another. High quality orchestration of disparate parts is in tension with encapsulation.<p>Actor-based programming is highly concurrent but in my experience it&#x27;s harder to reason about as it scales up. Emergent behaviour of interactions between hidden states is sometimes the goal, and sometimes an unwanted side-effect. Network protocols are tricky to get right for a reason; splitting everything out into a shared-nothing message-passing architecture isn&#x27;t a panacea.<p>I lean more towards explicit but immutable data structures, and referentially transparent functions over those data structures. In this world, parallelism can increase performance without observable concurrency. Concurrency is the root of non-determinism; non-determinism should be avoided unless it&#x27;s inherent to the problem at hand.<p>OOP is a middle ground in this world, but it&#x27;s ill-defined. Depending on style, it can be stateful and imperative, functional or message-oriented. OOP is not an absolute bad; with effort, it can be massaged, or herded, into working patterns. But it&#x27;s certainly not a universal optimum.
carsongrossabout 9 years ago
<i>A traditional OOP approach would have much of the functionality taken out of the player objects, using them simply to hold state. </i><p>I don&#x27;t agree with that characterization. The author certainly has a point that, in some languages in particular, like java, there tend to be massive over-decomposition of problems into reams of factories, controllers, controller factories and controller factory manager factories, but that isn&#x27;t OOP, that&#x27;s due to cultural and syntactic issues with those languages. (I know, I know, No True Scotsman.)<p>In the Rails world, which is a non-trivial component of the broader OOP software world, there is a saying: &quot;Fat Model, Skinny Controller&quot; which is much more in the spirit of what the author is advocating, despite remaining OOP.<p>Again, this isn&#x27;t to deny the authors general point, but I don&#x27;t believe it is bound to OOP, so much as it is to a certain style of OOP coding that arose from early (java in particular) over-engineering and excessive decomposition.
ninjakeyboardabout 9 years ago
I made up the term &#x27;object-oriented&#x27;, and I can tell you I didn&#x27;t have C++ in mind<p>-- Alan Kay, OOPSLA &#x27;97
rdtscabout 9 years ago
Joe Armstrong&#x27;s thoughts on how Erlang is more OO than OO languages:<p><a href="http:&#x2F;&#x2F;erlang.org&#x2F;pipermail&#x2F;erlang-questions&#x2F;2009-November&#x2F;047748.html" rel="nofollow">http:&#x2F;&#x2F;erlang.org&#x2F;pipermail&#x2F;erlang-questions&#x2F;2009-November&#x2F;0...</a><p>Joe likes to be funny, so don&#x27;t get upset and confrontational about it.<p>The central idea is this I think:<p>---<p>I now believe the following to be central to the notion of OO.<p><pre><code> - Isolated concurrent things - Communication through message passing - Polymorphism </code></pre> All the other stuff (inheritance, private&#x2F;public methods, ....) has nothing to do with OO.<p>---
评论 #11481064 未加载
评论 #11480888 未加载
markbnjabout 9 years ago
&gt;&gt; When I started learning C++ I was shocked. Instead of using objects for compartmentalizing functionality, they were just used as a holding pen for loosely related functions. Instead of communicating between themselves, objects were operated on by some bigger parent object. I found it absurd and fought it for a long time.<p>This has nothing whatsoever to do with C++. It&#x27;s like blaming a microwave oven because your kid put a ball of tin foil in it.<p>C++ is a great language when you are developing big compiled programs and need strong metaphors for decoupling and modularity. Most developers today work on distributed systems where the individual cooperating pieces that they write are much smaller. Your 1000 line HTTP handler in python won&#x27;t benefit much from strong static type checking, but the linux kernel does, and so do a lot of the infrastructure components we all take for granted every day.
评论 #11481995 未加载
paulddraperabout 9 years ago
One of the more ironic titles I&#x27;ve seen.<p>Alan Kay (progenitor of Smalltalk and OOP) has said on various occasions that it should have been called message-oriented programming, rather than object-oriented.<p>&quot;I&#x27;m sorry that I long ago coined the term &#x27;objects&#x27; for this topic because it gets many people to focus on the lesser idea. The big idea is &#x27;messaging&#x27;&quot;<p><a href="http:&#x2F;&#x2F;lists.squeakfoundation.org&#x2F;pipermail&#x2F;squeak-dev&#x2F;1998-October&#x2F;017019.html" rel="nofollow">http:&#x2F;&#x2F;lists.squeakfoundation.org&#x2F;pipermail&#x2F;squeak-dev&#x2F;1998-...</a>
nbevansabout 9 years ago
The same thing happened with REST, TDD and Microservices, etc. The term gets hijacked by people that are less than skilled at executing it. And unfortunately there are more unskilled than skilled people in software; so usually the hijacked term wins the contest. It then takes decades of the &quot;original guy&quot; sending out a BBS message &#x2F; IRC message &#x2F; vBulletin post &#x2F; Blog post &#x2F; Tweet &#x2F; HN comment &#x2F; etc to try to correct people&#x27;s understanding by saying &quot;actually, that&#x27;s not canon!&quot;.
copxabout 9 years ago
Comment on the code:<p>As a Lua aficionado I hate to see stuff like this:<p><pre><code> Ball = {} Ball.__index = Ball function Ball.new (x, y) local table = {} setmetatable(table, Ball) table.x = x table.y = y return table end </code></pre> Explicit setmetatable() call and manual __index setting? You can automate this and hide all the metatable magic = less code to write, less potential for bugs.<p>E.g. in my own Lua object system the above would be:<p><pre><code> Ball = Class() function Ball:Properties(x, y) return { x = x, y = y } end</code></pre>
KirinDaveabout 9 years ago
I think that we suffer from a paucity of precise language around OOP. Everything is OOP, everything is what Kay created, etc.<p>But that&#x27;s clearly not the case, and so people have these radically divergent systems of programming within the framework of &quot;object orientation&quot;.<p>My read of this article and it is very message-passing OO to me. Its broadcast mechanism is interesting, for sure. But it reads a lot like Erlang&#x27;s supervision tree without all that troublesome thinking about a network.<p>But it&#x27;s approach is still very &quot;OO&quot;.
daxfohlabout 9 years ago
The downside of message passing is debugging. No call stack so you can&#x27;t trace things back to their source.
评论 #11480478 未加载
评论 #11481340 未加载
评论 #11480877 未加载
评论 #11480894 未加载
评论 #11480689 未加载
ameliusabout 9 years ago
The only good thing that OOP brings to the table is, in my opinion, access control.
评论 #11480620 未加载
sbovabout 9 years ago
Isn&#x27;t this basically event driven programming?
koder2016about 9 years ago
<i>&gt; Objects just aren&#x27;t supposed to be reaching into each other with &#x27;getters&#x27; and &#x27;setters&#x27; and messing with information.</i><p>In pure Actor Model adding two numbers would probably involve 2+ actors, yet Erlang is not doing this for some reason... I guess on a lower level hardcoding messages makes complete practical sense.
lucb1eabout 9 years ago
Some meta feedback on the article: this font is too big to comfortably read on mobile, fitting about five to seven words on a line (the typically recommended line length is about 14 words).
qaqabout 9 years ago
How does this make fp? If we fill fp with plugs for 1 man projects with 1 watcher we&#x27;d have 1000s of entries a day.
andrewmcwattersabout 9 years ago
The less actual code I see in articles like this, and the more abstraction I read about, the less I take the concept seriously.<p>In fact, all of this seems like bullshit to me. The actual code inside of the repo is, well, object-oriented. How I interpret this is that the author seems to have no idea what they&#x27;re even talking about, and that they write more about code than they write code itself.<p>Show me what you mean, don&#x27;t just talk about it.
评论 #11480465 未加载
CyberDildonicsabout 9 years ago
TLDR: Terrible programming practices end up putting blame on labels and languages.
andrewvijayabout 9 years ago
The more I read about functional programming the more I question why are things this hard in traditional oops. If so many people have been doing oops for so many years then it must have something that is easy to pick up or something that is easier to work with. But after doing some functional programming the number of lines are painfully less and the code is easier to understand. I was thinking may be I was giving too much credit to FP but I was not it&#x27;s simply just the way things are. But why has FN been used only as an academic tool and not as a goto programming paradigm? Can someone shed some light on this?
评论 #11483900 未加载
评论 #11482536 未加载