Comment by vips7L
4 days ago
Object orientism is just encapsulation. It’s the only thing that is required. You can have objects without inheritance and virtual dispatch.
4 days ago
Object orientism is just encapsulation. It’s the only thing that is required. You can have objects without inheritance and virtual dispatch.
Languages like Go and Rust have module-scoped visibility, though. This is definitely encapsulation, but I wouldn't call it inherently OO.
So Python is not OOP language? You can't hide fields.
You can hide fields in Python with a little bit of gymnastics:
Usually, a simple function is enough:
Example:
But it hides nothing:
"private" in Python is cultural, not enforced. (you can access `self.__private` from outside too if you want).
It has conventions to hide data. Good enough.
Python was a mistake if you ask me ¯\_(ツ)_/¯
Python is the worst programming language except for all of the others.
I would say specifically encapsulation of mutable data
Lots of modern OO uses immutable data.
A lot of the underlying intuition behind OOP is expressed as "cells exchanging messages like an organism" and such, and I think that implies the distribution of state among a variety of small, special-purpose state-managers. More functional variants of OOP where state is managed centrally are a meaningful shift away from traditional ideas of OOP, and I think calling them both equally OO glosses over that shift a little.
What's a good example? What comes to my mind is modern C# which I would say is a multi-paradigm language that encourages things like immutable records and interfaces and composition over inheritance as alternatives to the now less favoured OOP styles that it also supports