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.

Pitfalls of object oriented programming (2009) [pdf]

89 pointsby davikrover 1 year ago

12 comments

robayeover 1 year ago
The original author revisited this talk[1][2] in 2017. You can also read more of the same ideas from the data-oriented-design list[3].<p>1. <a href="https:&#x2F;&#x2F;www.youtube.com&#x2F;watch?v=VAT9E-M-PoE" rel="nofollow">https:&#x2F;&#x2F;www.youtube.com&#x2F;watch?v=VAT9E-M-PoE</a><p>2. <a href="https:&#x2F;&#x2F;docs.google.com&#x2F;presentation&#x2F;d&#x2F;1ST3mZgxmxqlpCFkdDhtgw116MQdCr2Fax2yjd8Az6zM&#x2F;edit#slide=id.p" rel="nofollow">https:&#x2F;&#x2F;docs.google.com&#x2F;presentation&#x2F;d&#x2F;1ST3mZgxmxqlpCFkdDhtg...</a><p>3. <a href="https:&#x2F;&#x2F;github.com&#x2F;dbartolini&#x2F;data-oriented-design">https:&#x2F;&#x2F;github.com&#x2F;dbartolini&#x2F;data-oriented-design</a>
freetonikover 1 year ago
I find &quot;modern&quot; OOP concepts apply pretty well to graphical user interfaces. I believe that a good UI has a consistent and relatively strict hierarchy, with few &quot;unique snowflake&quot; elements. Even such a divisive idea as multiple inheritance often makes sense in UI, i.e. there could be an element inheriting low-level behavior (HTTP&#x2F;API call, etc) from a button and a high-level behavior (style&#x2F;presentation, etc) from a visual class.<p>(In a way, even CSS is kind of OOP, albeit with very confusing overriding rules.)<p>When writing generic backend code in a language like Java, I often found fighting against OOP because the business logic is not necessarily mappable to &quot;dog inherits from animal&quot;. And I can&#x27;t change the business logic, so OOP has to give in. But when developing user interfaces, I am usually in more control, I am actually designing it, not observing directly from the business logic. And OOP forces me to have a more consistent implementation, which is beneficial for the user, because consistent UI makes it easy for people to get used to it, find the underlying logic in it, and start relying on it. If all links on all web pages would inherit from normal HTML href link (like it was designed in the beginning), we wouldn&#x27;t suffer from those weird JS web apps where you can&#x27;t open a link in a new page for example.
评论 #38791970 未加载
评论 #38792031 未加载
评论 #38792216 未加载
评论 #38798799 未加载
评论 #38792159 未加载
评论 #38798609 未加载
评论 #38792042 未加载
ryandvover 1 year ago
The slide deck is about performance pitfalls of OOP languages, which can surreptitiously introduce cache misses, random access to memory, and excessive levels of indirection into your code:<p>&gt; Prefetching<p>&gt; Data accesses are now predictable<p>I&#x27;m reminded of a Stroustrup talk in which he says that vectors will always outperform linked list structures, by taking advantage of spatial locality and predictable access patterns to enable better cache prefetching. He even has a slide on C++ vs &quot;True OO&quot; style object graphs, and it looks remarkably similar to what&#x27;s described in the OP: <a href="https:&#x2F;&#x2F;www.youtube.com&#x2F;watch?v=YQs6IC-vgmo&amp;t=3m53s" rel="nofollow">https:&#x2F;&#x2F;www.youtube.com&#x2F;watch?v=YQs6IC-vgmo&amp;t=3m53s</a>
augustkover 1 year ago
<p><pre><code> &gt; Data abstraction &gt; Encapsulation &gt; Polymorphism &gt; Inheritance </code></pre> Note that it&#x27;s the last two concepts which are specific to object oriented programming. The first two are already supported by non OOP languages like C and enable implementation of abstract data types. I think it&#x27;s unfortunate that all concepts are often introduced in the same OOP course which may make the students believe that a class and an abstract data type is the same thing.
评论 #38793020 未加载
评论 #38792712 未加载
评论 #38798308 未加载
hurrilover 1 year ago
I think this description of what OO is, is flawed and makes people talk past each other:<p>&gt; • What is OO programming? – a programming paradigm that uses &quot;objects&quot; – data structures consisting of datafields and methods together with their interactions – to design applications and computer programs. (Wikipedia)<p>It isn&#x27;t that they are together, it&#x27;s that the core entity of the language used to express solutions centers around identity over state or values. As in: two objects are different even when the fields are all equal, and also: two objects can be the same even with different field values.<p>If you are going to object to this, I ask that you first contemplate whether or not you have programmed in any other way first, because as a fish, reasoning about what water is can be difficult.
评论 #38791545 未加载
评论 #38794060 未加载
nemoniacover 1 year ago
“I invented the term ‘object-oriented’, and I can tell you C++ wasn&#x27;t what I had in mind.” ~ Alan Kay, OOPSLA ‘97
评论 #38794454 未加载
评论 #38791745 未加载
评论 #38793721 未加载
commandlinefanover 1 year ago
That went in a different direction than I expected it to - but it&#x27;s also not specific to object oriented programming. Richard Stevens summarized this 40 years ago: &quot;modularity is the enemy of performance&quot;. We&#x27;ve mostly accepted that this is an acceptable tradeoff, although the author (and I) aren&#x27;t fully on board.
ChrisMarshallNYover 1 year ago
For me, personally, I’ve learned to use the right tool for the job.<p>In some cases, it’s OOP, in some cases, it might be something like FP, or Protocol-Oriented Design.<p>I write in Swift, which supports all of the above. It’s been a while, since I’ve worked with C++, but I have heard that the modern version of the language similarly supports multiple paradigms.<p>For the frontend, if I am writing for UIKit, I use OOP, and fairly standard MVP, as that is exactly what the framework was designed to afford. I haven’t done much SwiftUI, but I suspect that I’ll be using a lot less OOP, when I do.<p>On the server end, I tend to use good ol’ PHP. It’s not an especially good OOP language, but I find that OOP isn’t as relevant for my backend work. That work tends to look a lot like very old-fashioned Structured Programming, which PHP is good for. As others have pointed out, I’ve found it easy to go down rabbitholes, with backend OOP.<p>There’s a lot to be said for an approach as an experienced, multidisciplinary professional.<p>It seems as if programming and software engineering pundits generally start from the premise that all [other] software developers stink, and rules and tools should be used in an effort to force them to write “good code,” as opposed to, for example, hiring smart people, and training and mentoring them to be adaptable, resourceful, disciplined engineers.<p>That’s nothing new. I have been seeing this for my entire [long] career. The “new hotness” changes, but the attitudes are consistent.<p>Here’s an old joke, from the 1980s: <a href="https:&#x2F;&#x2F;news.ycombinator.com&#x2F;item?id=29345907">https:&#x2F;&#x2F;news.ycombinator.com&#x2F;item?id=29345907</a>
评论 #38792357 未加载
angiospermover 1 year ago
<i>Anything</i>-oriented programming amounts to tying a hand and foot behind your back. Any big enough program can benefit from OO in certain spots, functional in others, relational here and there, generic throughout all the others, pipelined, dataflow, declarative, what-have-you. The problem dictates its solution.<p>&quot;Specialization is for insects.&quot;
rkagererover 1 year ago
When the whole OOP movement gained traction I struggled to accept the degree of value it provided above simple structs and functions (at least for an organized programmer).<p>After decades developing on a lot of diverse platforms in a variety of languages and models, I&#x27;ve decided there ain&#x27;t much you can&#x27;t achieve without structs and functions (or their equivalent).<p>Sure, any tool is most efficient in the hands of a master who knows how to wield it. But in practice all those shiny extras too often become productivity distractions.
评论 #38798650 未加载
评论 #38800305 未加载
zigzag312over 1 year ago
OOP, FP and other paradigms are all useful. Just don&#x27;t do extremes like <i>everything is an object</i> or <i>everything is immutable</i> or <i>everything is without side effects</i>.<p>I enjoy multi-paradigm languages the most.
评论 #38792519 未加载
评论 #38797726 未加载
abberationover 1 year ago
cat-v at it again lmao
评论 #38794571 未加载
评论 #38792617 未加载