frontpage.
newsnewestaskshowjobs

Open Source @Github

fp.

Open in hackernews

Why OOP Exists

https://mathspp.com/blog/why-oop-exists
17•lumpa•3d ago

Comments

eru•1h ago
Compare and contrast https://www.youtube.com/watch?v=wo84LFzx5nI
victorbjorklund•1h ago
Site died.
groomlake•1h ago
Wayback link since the site was hugged to death: https://web.archive.org/web/20260827081007/mathspp.com/blog/...
OtomotO•1h ago
OOP exists to add a quadrillion of layers to otherwise perfectly understandable business code in an attempt to obfuscate meaning and intent and guard against malicious extraction of valuable trade secrets.

Oh, it also helps me to pay my bills, because someone has to untangle the mess.

And it helps my therapist, because he has to keep the madness that grows inside of me in check.

Jokes aside: I was taught OOP at university.

I was also taught functional programming, answer set programming and other forms such as logical programming.

Focus was definitely on OOP though.

I mainly see OOP as a way to (dis) organizer code and a way for hardware manufacturers to sell more hardware.

TonyStr•10m ago
OOP is sold on the promise that everything is modular. Since everything is neatly encapsulated with clearly defined API surfaces, you can easily swap out any part for any other. This should make developers interchangeable, because anyone can go in to the code and swap out parts as needed.

In reality this seems to make coupling even worse. Now you have to dig 8 classes deep just to find the business logic for a particular feature. Changing it is even harder because the rest of the program expects this part to behave in a very specific way.

echelon•58m ago
OOP is perfectly fine.

Rigid class-based inheritance (especially multi-inheritance) is what sucks. This over-engineered complexity really only benefits things like window toolkits where you want super rigid modeling of widget types. But even that's a stretch.

Traits do OOP the right way. Complete flexibility.

    Dog goes "woof"
    Cat goes "meow"
    Bird goes "tweet"
    And mouse goes "squeak"
Does not need classes.
garretraziel•55m ago
Not sure if intentional, but I read it in Ylvis’ “What does the fox say?” and now I can’t get it out of my head, thank you very much.
dnautics•27m ago
Nah even traits are kinda bad because it increases the indirection necessary for code reading
mrkeen•53m ago
Admittedly I read this pretty quickly, but this is just structs.

The "behaviours" being modelled here were data access. Writing .name() instead of .name.

You can save yourself the time of manually packing these structs by writing out a constructor in full. Which the article called "automatic".

(You don't even need to write out the constructor for a struct in C99. Probably any other modern language too)

yxhuvud•51m ago
> If you think you already know OOP, this article will change the way you think about programming

No, it won't. I'm especially sad that this, like so many OOP guides before it, did not go into how it interacts with data structures and bigger picture stuff. It had the perfect chance to do that as it could have made a Catalog class and then had a discussion about what belongs to that and what to the books. Instead it started to abstract on author, in the stupidest way possible (no, no one will ever look up a book using the author birth date).

fjcururuvy7•46m ago
The older I get the more I realize the stuff I learned in university was just plain wrong.

It's incredibly difficult now dealing with zoomers in the workplace that think I'm some old boomer that never learned "proper computer science".

No, sorry Timmy, it's not because I don't understand microservices, it's because I actually do.

projectileboy•47m ago
A good book for appreciating the OO mindset is Object Thinking by David West.
phplovesong•46m ago
There is good OOP, there is bad OOP, and then there is PHP(OOP).
wolvesechoes•40m ago
OOP, like most stuff discussed in dev-related web, exists so that permaonline people can have another reason to create their own tribes and fight each other.
mickeyp•35m ago
OOP is fine. Not using OOP is fine too if your architecture / design demands it.

What people forget -- much like the design patterns in the gang of four book -- is that languages and frameworks evolve.

A decorator pattern was a niche but useful abstraction in the 1990s. In Python today you can @decorate stuff just like that. It's evolution.

The same holds for OOP. Encapsulation and co-located methods with the encapsulating slots was an incredibly powerful upgrade over basic structs. Now most languages have first-class functions and lexical scoping so you can build your own encapsulation that way.

It's all good. Just use whatever fits best.

jongjong•21m ago
Some problems don't require OOP, but most large complex problems do, IMO.

Most complex codebases I've seen which were pure Functional Programming were spaghetti code; unmaintainable.

What I saw every single time was that the project was syncing a huge amount of state in a central place and then passing it through a large number of components and sub-components. The top level component basically had to have full awareness of everything going on inside the system in order to do its job and there were no separation of responsibilities because none of the components had sovereignty over the state they needed to do their job independently. It's just components micro-managing components all the way down.

React with Redux is probably the best FP implementation I've seen thus far but even it is kind of a mess. I have nightmares about Redux Saga. The Redux Saga logo is literally a stylized drawing of entangled spaghetti.

Had Redux + Saga been presented to people as part of React at the time it was introduced, React would probably not have become so popular. Because people would have understood that it creates too much unnecessary baggage which isn't worth it. React was used as a gateway drug to Redux which was itself a gateway drug for Saga!

slopinthebag•17m ago
ya ive seen the same but in OOP codebases, where the state is all distributed and incapsulated and it's just impossible to reason about how the entire system works because despite it's separation of responsibilities everything is still intrinsically coupled together. and then you have all sorts of hidden mutations and other shenanigans.

to me the best way to design large systems is sort of like an ecs. you don't separate components by state + behaviour, you separate systems and state.

Zak•34m ago
This seems like a beginner-level OOP-in-Python tutorial, and I'm disappointed the author didn't demonstrate a functional abstraction for `find_by`.
js8•16m ago
Well, what I don't understand is the SW engineering propensity towards cargo culting and doing things the harder way than mathematicians do.

I see it with OOP, XML, design patterns, and other things, now with LLMs. (LLMs - you really want to build complex systems in badly specified natural language, compiled or interpreted with an inscrutable algorithm and possibly indeterministic?)

Is it the excitement from a new analogy? Or are engineers naturally empiricists, while the rationalism/empiricism distinction doesn't work in computer science?

I think we would be better off if we just learned functional programming and few abstract concepts (categories, monads). Simpler than OOP.

mickeyp•7m ago
But functional programming and OOP are intrinsically the same, but expressed using different primitives.

The thing that empowers first-class functions and closures (lexical binding) is the exact same method by which encapsulation works, even if the latter opts for heap vs stack. The fundamentals are the same.

Here's a simple one in Emacs Lisp:

    (defmacro send (object method &rest args)
      "Sends a METHOD to an OBJECT with ARGS."
      `(funcall ,object ',method ,@args))

    (defun make-animal (name)
      ;; 'hunger' is entirely private (encapsulated)
      (let ((hunger 5))
        ;; here's our lambda using lexical binding
        (lambda (method &rest args)
          (cond
           ((eq method 'get-name) name)
           ((eq method 'feed) 
            (setq hunger (max 0 (1- hunger)))
            "Yum!")
           (t (error "Animal does not understand: %s" method))))))

    (let ((good-boy (make-animal "Rex")))
      ;; "call" (via our macro) the "get-name" method; then feed. hunger does down 1.
      (send good-boy get-name)
      (send good-boy feed)
      ;; pretty-print the "object" good-boy
      (pp good-boy))

    ;; this is the state of it after the two calls.
    #[(method &rest args)
      ((cond ((eq method 'get-name) name)
             ((eq method 'feed) (setq hunger (max 0 (1- hunger))) "Yum!")
             (t (error "Animal does not understand: %s" method))))
      ((hunger . 4) (name . "Rex"))]
ivan_gammel•5m ago
bronlund•10m ago
Someone learning programming it seems :D
reaanb2•7m ago
This article describes the OOP approach that leads to object-relational mapping, boilerplate code, database schema duplicated in code, navigational data access and the impedance mismatch. It defines OOP around data modeling and taxonomy, rather than around responsibilities. Principles such as "Tell, don't ask" and "Single responsibility" are just ignored. What responsibility does a book have in a library management system? It doesn't, it's just a subject of recorded facts, and a better approach would be to identify the behavioural components of the solution space, construct those as classes/objects, and let facts be encapsulated in or communicated between objects.
slovenlich•3m ago
And then you start adding some real world books that have some of the attributes missing or uncertain, have several authors, go by different titles or uses some kind of exotic notation to their titling, and this OOP structure kind of crumbles?
hurril•12m ago
Component is not a term out of the FP schoolbook. I am sorry to be making what smells like a true scottsman here, but you seem to be describing a React codebase since they call themselves functional with that Redux stuff, you think this is functional programming. A graph of "components" all talking amongst each other. Functional. Programming. Come one, man :)

What you are describing is OOP. Passing messages between identities over calling pure functions with values.

jppittma•5m ago
> none of the components had sovereignty over the state they needed to do their job independently. It's just components micro-managing components all the way down.

Isn't one of the tenants of FP that nothing is mutable anywhere?

slopinthebag•20m ago
OOP hate is definitely a popular way to signal that you aren't just a "common grunt programmer". And there are personalities who have made it a big part of their appeal.

But I also spent some time with modern Spring Boot, and I get where the hate is coming from. There is a lot of complexity that just doesn't seem necessary at all.

mickeyp•15m ago
Oh, I agree. But there's value in people who set out to do things a certain way, even if that approach ends up not working well in the long term.

We're collectively shaking a lot of trees when we build frameworks, languages and tools. What works? What does not? What is the right level of abstraction? How much developer ergonomy do we want to sacrifice?

Sadly we only seem to know in hindsight what works well. But that is also how we learn and grow; it was just meant to be this way.

js8•10m ago
Well, I just wrote a comment that could be considered an "OOP hate". I was debating whether to do it.

The point is not to be snug about it. Functional programming (and monads) are actually simpler. You just need to resist the urge to "make it more understandable".

Abstract math doesn't have good analogies to the real world. By trying to make an analogy with the concrete ("monads are mappable") you lose simplicity.

ImHereToVote•4m ago
In the end you will be passing messages between entities when your codebase becomes complex anough.
danielbarla•5m ago
> But I also spent some time with modern Spring Boot, and I get where the hate is coming from. There is a lot of complexity that just doesn't seem necessary at all.

I'm sure there is some (very high) level of inherent project complexity where the massive number of abstractions and tools that Spring Boot gives you (and forces on you) actually starts turning into a net positive... And I'm also fairly sure that most projects don't quite break even, and would be better off with something more lightweight.

OOP is not about doing things harder, it‘s about doing them efficiently. The key elements of software engineering are abstraction and encapsulation: we, humans, cannot load the entire domain into our memory and reason about it at all levels of detail at once. We need to zoom in and zoom out, decompose problems into smaller pieces, then reassemble, treating those pieces at surface value. OOP isn‘t rocket science, it just adds one more piece — the hierarchy of concepts with inheritance and polymorphism. And it‘s just a technique: most programs are written in a mix of styles anyway. The foundational style is procedural, because that‘s how computers work. FP and OOP just build on top of it and translate to it.

“I just chose words carefully”

https://unsung.aresluna.org/i-just-chose-words-carefully/
620•zdw•8h ago•150 comments

P99 0 ms* autocomplete for 240M domain names

https://ruurtjan.com/articles/p99-0ms-autocomplete-for-240-million-domain-names
68•dbalatero•3h ago•30 comments

Creepy Crawlies

https://people.kernel.org/monsieuricon/creepy-crawlies
1063•zdw•1d ago•521 comments

Transfer files over an Ethernet patch cable

https://maurycyz.com/misc/etherfiles/
45•jllyhill•3h ago•29 comments

It takes 5 cloud services to hear my doorbell

https://blog.vghaisas.com/rube-goldberg-doorbell/
113•vghaisas•2d ago•78 comments

My hobby of building miniatures and taking pretty pictures

https://sandyuraz.com/blogs/tiny-cafe/
69•thecsw•2d ago•9 comments

Why OOP Exists

https://mathspp.com/blog/why-oop-exists
18•lumpa•3d ago•33 comments

Matrox: Graphics for Professionals

https://www.abortretry.fail/p/matrox
84•BirAdam•7h ago•24 comments

Highlighting My Code Based on How Much I Care

https://hank.bond/posts/highlighting-my-code-based-on-how-much-i-care/
12•hankbond•2d ago•2 comments

Haiku R1/beta6 has been released

https://www.haiku-os.org/news/2026-08-26_haiku_r1_beta6
303•metrofun•15h ago•89 comments

Understanding ChatGPT Work

https://simonwillison.net/2026/Aug/30/understanding-chatgpt-work/
140•gmays•5h ago•48 comments

OpenClaw 2.0, Accidentally

https://openclaw.ai/blog/openclaw-2-accidentally
61•doppp•3h ago•53 comments

A 12TB Steam "teraleak" spills more than a decade of lost PC gaming history

https://arstechnica.com/gaming/2026/08/a-12tb-steam-teraleak-spills-more-than-a-decade-of-lost-pc...
19•WithinReason•59m ago•0 comments

Internet centralization and the original sin of NAT

https://dreamstation.systems/personal/ntppost.html
45•robinpie•4h ago•23 comments

How to build a diffusion language model

https://kuleshov-group.github.io/blog/blog/2026/how-to-build-a-diffusion-language-model/
58•volodia•7h ago•4 comments

Cores in space: The core memory module from a 1980 Spacelab computer

https://www.righto.com/2026/08/spacelab-core-memory.html
101•pwg•11h ago•17 comments

Show HN: NFC Energy-Harvesting PCB Business Card with an MCU

https://wilsonharper.net/projects/businesscard/
151•WilsonHarper•2d ago•15 comments

Continuous Diffusion Language Models (CDLM's)

https://sander.ai/2026/08/24/continuous-dlms.html
83•peter_d_sherman•10h ago•33 comments

Sort branches by last commit date

https://ryangreenberg.com/til/git-branches-by-commit-date/
112•speckx•5d ago•42 comments

Hacking IKEA Furniture

https://greenlightning.eu/diy/hacking-ikea-furniture/
300•greenlightning•19h ago•207 comments

Why open source rocks – a new SM750 (Silicon Motion GPU) HDMI Driver

https://github.com/KodeMunkie/sm750hdmifb
98•SillyUsername•12h ago•35 comments

Relm4 makes developing beautiful cross-platform applications idiomatic

https://relm4.org/
30•Bluestein•4d ago•17 comments

Coordination Headwind: How Organizations Are Like Slime Molds

https://komoroske.com/slime-mold/
150•rzk•15h ago•45 comments

Startup Anti-Patterns

https://www.itamarnovick.com/intro-to-startup-anti-pattern-series/
142•rzk•15h ago•72 comments

Commercially Available Bike Generators Are Not Sustainable (2011)

https://solar.lowtechmagazine.com/2011/05/bike-powered-electricity-generators-are-not-sustainable/
43•baud147258•4d ago•39 comments

Show HN: Prove your code produced your claims without making reviewers rerun it

https://github.com/27-GROUP/kveritas-go/
9•Mkld27•4h ago•3 comments

How would you know whether an ancient culture had zero?

https://www.johndcook.com/blog/2026/08/21/ancient-number-system/
50•ibobev•3d ago•23 comments

Racter (1984)

https://www.ubu.com/historical/racter/index.html
22•buescher•2d ago•6 comments

Dad’s Custom Atari Peripherals

https://www.goto10retro.com/p/dads-custom-atari-peripherals
126•rbanffy•3d ago•16 comments

Arbitrary code execution in QubesOS via copy-to-VM error reporting backchannel

https://www.qubes-os.org/news/2026/08/29/qsb-118/
225•vntok•22h ago•89 comments