Marc Merlin wrote:
...
In other words, information hiding is a way of making software systems
resilient in the face of change. It is not simply a way "nanny"
programming languages try to keep "top-gun" programmers from getting their
job done. Of course, for small projects with a restricted user base these
constraints hardly matter. If Ruby were intended to be only a prototyping
tool, then bypassing access controls would be no big deal. But Ruby
apparently is on the way to being adopted as a bona fide
progamming-language-in-the-large, as evidenced by such trailblazing
projects as the Rails framework. (I certainly hope so!) Consequently I
think that the adherence to a rigorous informtation hiding schema should be
taken seriously and mechanisms to bypass it should be brought into
question.
I agree; any mechanism for by-passing orderly program control should be viewed with suspicion. But such things need to be there, as the programmer must always be the ultimate arbiter.
Every modern language has such mechanisms; they are either explicit or buried, but they are there. Better they be made clear and well documented so all involved can make informed choices.
Even if strict data hiding was enforced there would be countless other ways to write poor code; I (sadly) have too much have proof of this. The end-user must always rely on the judgment of the developer, in any language.
I haven't looked at all that much of the Rails source code, so I don't know the they answer, but here's something to ponder: Were strict data + method access enforced, would Rails be (as) feasible?
Further, C is certainly well accepted as a mainstream language, and it allows for far more easier tomfoolery than does Ruby.
I don't view OO and data hiding as a way to hamstring advanced developers, but I do believe some languages gain traction precisely because their built-in constraints serve as an effective form of mob control for projects involving large numbers of inexperienced (and less expensive) developers who might otherwise run amok.
I believe, too, that it can be argued that these constraints lead to overly complex code that ages poorly compared to applications built using agile languages. While some might have a warm fuzzy feeling during production, you end up with code less resilient to change.
James
P.S.
I suspect concerns over malleable object boundaries are nearly identical to concerns over dynamic typing. Proper use of unit testing will do a lot more for ensuring robust code than either strict encapsulation or typing.