Why does python not have a mechanism for data hiding?

Samuel Bayer sam at mitre.org
Tue Jun 10 15:44:54 EDT 2008


Jonathan Gardner wrote:

> Let me share my personal insight. I used Python for a mission-critical
> application that needed, in effect, almost 100% uptime with superior
> throughput. In other words, it was a very fine piece of art that
> needed to be precise and correct. In the end, Python delivered, under
> budget, under schedule, and with superbly low maintenance costs
> (practically 0 compared to other systems written in Java and C). I
> didn't have to use any of the features you mentioned, and I can't
> imagine why you would need them. In fact, having them in the language
> would encourage others to use them and make my software less reliable.

At the risk of prolonging this thread, I'll add my own personal insight. 
I've spent a decent amount of time programming in Java, and the overhead 
of assigning a too-restrictive privacy level (which happens a lot, once 
privacy levels are in the language) has cost me an immense amount of 
time. I've lost count of how often I've had a software package which 
made an element non-public, in many cases for no apparent good reason, 
except that they hadn't anticipated the way I was going to use their 
code. Tracing down the consequences of these decisions, and trying to 
work around them, has been exceptionally time-consuming for me. You can 
say that I can go and modify the source code, as long as I have the 
source code, but that misses the point: I don't WANT to keep my own copy 
of the code, with the attended overhead in merging it with subsequent 
releases, etc.

I'm not going to claim that data hiding has no purpose - it clearly 
addresses a set of concerns that programmers have about managing APIs. 
But I've found that its difficulties far outweigh its benefits.

Sam Bayer



More information about the Python-list mailing list