=> yujiri.xyz | Software

Enforced privacy is stupid

Many languages have enforced privacy: a member of a module or class can be declared "private" and that makes other code not allowed to access it. In some cases this is partly for compiler implementation reasons, but that aside, it's a stupid policy (and there are people who defend it as a policy, so I'm making this article).

Nothing in a language without enforced privacy stops you from having loose coupling and marking attributes not meant for external use with a convention like a _ prefix. The discussion isn't about the benefits of loose coupling (those are obvious), which is why Wikipedia's car manufacturer example is a false analogy. Enforced privacy isn't about not accessing implementation details from the outside, but preventing said access.

The core reason this is stupid is because as a library author, you can't anticipate all possible use cases of your code. Just because you don't see why someone would need to access something from the outside doesn't mean there's never a valid reason. Hacks are ugly and I have as much of a negative visceral reaction to them as the next coder, but sometimes, practicality beats purity, and so I don't understand why so many people are convinced that we should artificially hide data from intentional access.

=> Zen of Python

Proxy Information
Original URL
gemini://yujiri.xyz/software/enforced-privacy.gmi
Status Code
Success (20)
Meta
text/gemini; lang=en
Capsule Response Time
398.485795 milliseconds
Gemini-to-HTML Time
0.25356 milliseconds

This content has been proxied by September (ba2dc).