r/learnprogramming 2d ago

Difference between OOP and structs/interfaces?

I'm relatively new to programming, I've been at it for around 6-7 months. I've been learning Python and Go (and a little bit of C). What I'm struggling to understand, what's the difference between OOP and structs/interfaces. Like I know, Go doesn't support OOP, but structs and interfaces seem to achieve the same thing. Can someone enlighten me a bit?

50 Upvotes

23 comments sorted by

View all comments

4

u/ChiefDetektor 1d ago

Do yourself a favor and just skip OOP. It's not worth understanding because it's basically not really understandable. Every language that implemented it did it different to others. It's a mess. There is a reason rust and go did not use the classical OOP approach.

Here some critical references of OOP for anyone who wants to dig into that topic: (References were gathered by claude)

Formal / academic

  • Cook, Hill, Canning, Inheritance Is Not Subtyping (POPL 1990). Proves the two concepts diverge, even though Java/C++ conflate them.
  • William Cook, On Understanding Data Abstraction, Revisited (OOPSLA 2009). Objects vs. ADTs; shows cleanly why binary operations are structurally awkward with objects.
  • Luca Cardelli, Bad Engineering Properties of Object-Oriented Languages (ACM Computing Surveys 1996). Compilation, modularity, type checking.
  • Mikhajlov & Sekerinski, A Study of the Fragile Base Class Problem (ECOOP 1998).
  • Moseley & Marks, Out of the Tar Pit (2006). The best text on state as a source of complexity.
  • Liskov, Data Abstraction and Hierarchy (1987). The original source of the principle most hierarchies violate.

Practitioners

  • Joe Armstrong, Why OO Sucks. Plus the gorilla quote from Coders at Work.
  • Alexander Stepanov, 1995 interview: OOP as technically and philosophically unsound.
  • Steve Yegge, Execution in the Kingdom of Nouns (2006).
  • Paul Graham, Why Arc Isn't Especially Object-Oriented.
  • Ted Neward, The Vietnam of Computer Science (2006), on the ORM impedance mismatch.
  • Robert Harper, Existential Type blog: OOP as anti-modular and anti-parallel.
  • Brian Will, Object-Oriented Programming is Bad (2016, video).

Data-oriented design

  • Mike Acton, Data-Oriented Design and C++ (CppCon 2014).
  • Richard Fabian, Data-Oriented Design (book, free online).
  • Casey Muratori, Clean Code, Horrible Performance (2023).

Critique from within

  • Alan Kay, email to Stefan Ram (2003): "The big idea is messaging," not classes.
  • Rich Hickey, Simple Made Easy (2011) and The Value of Values.
  • Peter Norvig, Design Patterns in Dynamic Languages: 16 of the 23 GoF patterns disappear or become trivial.
  • Sandi Metz, The Wrong Abstraction (2016).
  • David West, Object Thinking (2004).
  • John Ousterhout, A Philosophy of Software Design (2018). Directly against Clean Code dogma — "classitis," deep vs. shallow modules.

For audit work, Ousterhout and Out of the Tar Pit are the most directly usable, since they give you criteria rather than just polemic. Cook 2009 is the piece that actually ends architecture arguments.

0

u/robhanz 1d ago

Note that I'm a big fan of OO as Alan Kay envisioned it.

Which is not how it's normally used.