| ▲ | A defense of object-orientated programming(codeandcake.dev) | |||||||||||||
| 10 points by olexsmir 2 days ago | 5 comments | ||||||||||||||
| ▲ | pjmlp a day ago | parent | next [-] | |||||||||||||
> Some newer programming languages, like Go and Rust, don’t support it at all They clearly do support OOP, the only difference is that it isn't the traditional class based OOP from Smalltalk and Java. I have coded the Peter Shirley's raytracing tutorial using Rust with exactly the same OOP architecture as the tutorial, based on traits. | ||||||||||||||
| ▲ | deterministic a day ago | parent | prev | next [-] | |||||||||||||
Merging data and behaviour into a single unit (the core idea behind OOP) is literally impossible to do in practice. Just imagine "sending a message to an int to send a copy of itself to a HTTP server" or "send a message to an array of colors to raytrace itself" or "send a message to a file asking it to sort itself and render itself in 3D". The problem is that everything will literally end up depending on everything. A perfect implementation of the ultimate spaghetti code. In contrast, split the code into Data, Dumper, Reader, Writer, Verifier, Renderer, Editor etc. modules (or classes used as modules) and the code is simple to understand with zero circular dependencies. And it works for any language including non-OO languages. | ||||||||||||||
| ▲ | verdverm 2 days ago | parent | prev [-] | |||||||||||||
> If this is such a great approach, why are some people moving away from it? My answer is because forcing a type hierarchy, and having to declare where every type belongs in it, is a PITA. Duck typing is far more flexible and good enough imo | ||||||||||||||
| ||||||||||||||