Live data from Hacker News

Wikileaks To Leak 5000 Open Source Java Projects

steve-yegge.blogspot.com

41–50 of 140 posts

Re: Wikileaks To Leak 5000 Open Source Java Projects

#41
post #27
post #21

Earlier quoted context omitted.

Encapsulation is completely orthogonal to access modifiers.

Your view differs from some of the OO language designers. For example, Stroustrup defines encapsulation as "the enforcement of abstraction by mechanisms that prevent access to implementation details of an object or a group of objects except through a well-defined interface. C++ enforces encapsulation of private and proteced members of a class..." http://www2.research.att.com/~bs/glossary.html#Gencapsulatio... Since t…

Encapsulation can be achieved quite efficiently if you have closures ... you can have good encapsulation (i.e. preventing access to the implementation details of an object) even in Javascript.

Many dynamic languages also have tools you can use to make your life easier ... with Python I'm using pylint/pychecker to keep me honest. My Emacs instance screams at me whenever I access a protected field of some object.

Also ... private/protected fields or final classes have caused much trouble for me. Overriding the behavior of a class is the easiest way to workaround various bugs without modifying the original source ... which in some cases is a PITA, while in other cases is impossible.

I once worked on a Java project that used a commercial library with no source-code ... to fix a stupid bug I had to manipulate the bytecode at runtime. Which shows again that private/protected/final access modifiers are pretty useless as guarantees ... a determined developer can get passed them.

It's just that you begin to hate life a little bit more.

Re: Wikileaks To Leak 5000 Open Source Java Projects

#43
post #4

Christ, this guy never ceases to amaze. His talk at I/O a couple years ago was absolutely fantastic: http://www.youtube.com/watch?v=BttI-y9VzXQ

One of the points he makes is that VMs are obvious for the purpose of language interop. Seems like C and Lisp (and D, another language he mentions) have been interoperating with each other without a VM in common for quite a while.

But it's not a many to many mapping, that's the point he was making. Lots of languages interop with C, but you can't just import a ruby module into a python script very easily. In fact if you want to link to C libraries from D you have to modify the C header files to turn them into D modules.

Re: Wikileaks To Leak 5000 Open Source Java Projects

#45
First note: I have never dealt with the internal workings of the Java VM, so this is just speculation. I also haven't tested any of this, but its still fun to speculate.

In java private variables and functions are not accessible from outside the class. This means that the compiler would be able to make some assumptions about the nature of these members in the effect of optimization. When calling a public function of another class in java, I suspect that the name of the function is mapped to the actual bytecode at invocation time after being looked up in some sort of trie/tree/hashtable. So, for every function call or varaible access, there would have to be a lookup. On the other hand, if the members were declared private, the compiler could directly link a caller to the function and skip the lookup. If this is the case, then setting all these projects' sources to use only public would mean a substantial performance loss.

I would love to be corrected if this is not the case, as I haven't taken a course in OO compilers yet.

Re: Wikileaks To Leak 5000 Open Source Java Projects

#47
Can someone please explain what this means to people not familiar with Java? I'm confused because I thought open source meant open source, as in "all of the source-code is available." What does 'open source' mean in this context, if not "open'??? When I read the title I thought it was a joke. Thanks and sorry for my ignorance, I'm a lowly perl hacker.

Re: Wikileaks To Leak 5000 Open Source Java Projects

#49
post #40

Earlier quoted context omitted.

If the language isn't enforcing the encapsulation, how is it encapsulated? For me, encapsulation comes down to "What I hide, I can change. What I expose, other types may couple to in an inappropriate way."

> If the language isn't enforcing the encapsulation, how is it encapsulated? What do you mean by "enforce"? Java's private modifier doesn't enforce encapsulation. Javascript's objects do not have a private modifier, but still provides encapsulation via closures. It's hard to have a meaningful discussion when loose terms like "enforce" are thrown around.

Sure, the private access modifier doesn't strictly "enforce" encapsulation. Perhaps the term should be "language supported".

I guess, for me, that the point of private is to clearly communicate the intent of the interface (small "i" interface) of a type. That intent is generally "don't use this, use this other part instead" or "if you couple, to this, it may break on you".

There are other ways of expressing that intent, I just really like having the compiler help me and my collaborators from making stupid mistakes.

Post reply on HN