<story><title>Why is OOP still so widely spread?</title><url>https://stackoverflow.blog/2020/09/02/if-everyone-hates-it-why-is-oop-still-so-widely-spread/</url></story><parent_chain><item><author>hn_throwaway_99</author><text>&amp;gt; If everyone hates it, why is OOP still so widely spread?&lt;p&gt;Most importantly, not everyone hates it. There are definitely warts involved, and IMO the 2 biggest warts are now largely understood:&lt;p&gt;1. People understand the pitfalls of inheritance now, so you&amp;#x27;ll see &amp;quot;composition over inheritance&amp;quot; MUCH more than you&amp;#x27;ll see inheritance as the recommended way to do things.&lt;p&gt;2. I don&amp;#x27;t know how widespread this feeling is, but as someone who moved from Java to Node&amp;#x2F;Typescript a couple years ago, I feel like I can confidently say &lt;i&gt;structural&lt;/i&gt; typing, in practice, is MUCH easier, better and fun to work with than &lt;i&gt;nominal&lt;/i&gt; typing. I can think of times I literally spent days trying to work through some refactoring in Java that was a nightmare because of the constraints of nominal typing, where the structural typing approach of TypeScript makes it trivial.</text></item></parent_chain><comment><author>seanmcdirmid</author><text>&amp;gt; I feel like I can confidently say structural typing, in practice, is MUCH easier, better and fun to work with than nominal typing.&lt;p&gt;Structural typing is crazy flexible, but you pay for it with worse type error reporting (forgetting something in an interface is now 100 errors rather than 1) and the inability to encapsulate (a structure type can&amp;#x27;t model private members, of course). There was a lot of research in addressing these problems in the 90s, but for some reason none of that work has made it into any mainstream structurally typed language today.</text></comment>
<story><title>Why is OOP still so widely spread?</title><url>https://stackoverflow.blog/2020/09/02/if-everyone-hates-it-why-is-oop-still-so-widely-spread/</url></story><parent_chain><item><author>hn_throwaway_99</author><text>&amp;gt; If everyone hates it, why is OOP still so widely spread?&lt;p&gt;Most importantly, not everyone hates it. There are definitely warts involved, and IMO the 2 biggest warts are now largely understood:&lt;p&gt;1. People understand the pitfalls of inheritance now, so you&amp;#x27;ll see &amp;quot;composition over inheritance&amp;quot; MUCH more than you&amp;#x27;ll see inheritance as the recommended way to do things.&lt;p&gt;2. I don&amp;#x27;t know how widespread this feeling is, but as someone who moved from Java to Node&amp;#x2F;Typescript a couple years ago, I feel like I can confidently say &lt;i&gt;structural&lt;/i&gt; typing, in practice, is MUCH easier, better and fun to work with than &lt;i&gt;nominal&lt;/i&gt; typing. I can think of times I literally spent days trying to work through some refactoring in Java that was a nightmare because of the constraints of nominal typing, where the structural typing approach of TypeScript makes it trivial.</text></item></parent_chain><comment><author>wvenable</author><text>&amp;gt; so you&amp;#x27;ll see &amp;quot;composition over inheritance&amp;quot; MUCH more than you&amp;#x27;ll see inheritance as the recommended way to do things.&lt;p&gt;So much that you&amp;#x27;ll have people advocate doing inheritance using interfaces and composition which results in exactly the same thing with all the same pitfalls but at least it&amp;#x27;s not &amp;quot;inheritance&amp;quot;.</text></comment>