Wikileaks To Leak 5000 Open Source Java Projects
steve-yegge.blogspot.com
steve-yegge.blogspot.com
#define class struct
#define private public
#define protected public
#define true false
#define false true
#define true 0
#define false !true
#define if while
#define continue break
:) #define true false
#define false true
Did you know that if you do both of those, they cancel each other out? True story.First make a file a.c that has in it:
#define true false
#define false true
int A = true;
int B = false;
then from the command line, do (with the Microsoft compiler): D:\>cl -E a.c
int A = true;
int B = false;
Now with gcc (I'm using cygwin's gcc): D:\>sh -c "gcc -E a.c"
int A = true;
int B = false;
I've stripped the other stuff.
The consequence of this rule is that cycles of #defines don't do anything. Edit: Well, that's only true if there aren't other symbols introduced during expansion. Here's a counterexample that prints 3:
#include <stdio.h>
int x = 1;
#define x 1 + y
#define y 1 + x
int main(int argc, char *argv[])
{
printf("%d\n",x);
return 0;
} #define TRUE random()%2(While being quite funny, mind you!)
The image halted immediately.
Love it!
Both music and software are usually licensed (2), but people often disrespect music license thinking they are entitled to more rights for some reason.
Sure, in the US people have all these locked up phones, but that's the price you pay for getting subsidized hardware.
In Finland, 3000 minutes of talk time and 3000 text messages costs about 38 € on a major operator. You can often get a switcher discount to bring the price further down.
This article was about something totally unrelated.
"I worked hard to deprecate that code that I worked hard to create so I could deprecate some other code that I also worked hard on,"
Why would you want to work to be features that are superseded and should be avoided?
This guy feels my pain! :)
Eclipse is another matter: far more ridicule is called for. Far, far more.
Matz would never deny us of our right to snoop around where we don't belong.
It had a bit too much bolted on, probably due to its origins in OLE, and I think "dynamic OLE" was a tragic mistake. And its reference counting approach was a lot more appropriate in the early 90s than it is today (where a compacting GC may be the smart choice, performance-wise). But for making calls between objects in C, C++, VB6, Delphi, and pretty much every other language that lived on the Windows platform, it worked really well.
Today you can have a language in 2 years with the biggest set of libs out there.
If you explained Unix file permissions to a Windows guy, he'd probably think it was silly. They exist for a purpose though- just not a purpose the Windows guy has spent much time with.
If you need access to a library's private or final fields, the library API is badly designed. Or, if you're that keen on wanting to change how the library works, fork it. That's kind of the point of open source.
private final member variables? Invaluable.
Example, if you have a type representing a game score, you may want to implement a public Increment() method instead of letting other types access the score value directly.
The author of the post is pointing out the irony of people saying "this code is totally open" yet forcing you, ostensibly for your own good, to interact with it in a prescriptive way.
If you over-analyze the joke too much it becomes less fun :)
In Drupal, for example, there is a saying: "every time you hack core (or a module you didn't write) god kills a kitten." In the spirit of open source, we probably borrowed that saying from some earlier project, because it is generally true.
The standard Java String library is the same for everyone. [1] If you download Random Java Library X, and X works with the String library, you can probably be assured that X has been tested with the standard String library. As soon as you change one line of the library this is no longer the case. You must now face the possibility that your "minor" change will lead to side effects when combined with other things, and the responsibility for finding those side effects is now entirely yours.
Plus, the sheer mechanical tedium of preserving your patch, making sure to apply it to every new version of the library as it comes out, relearning how the patch works every few months, porting the patch when it fails to apply cleanly to a new version, figuring out how to distribute your personalized package to others because they can no longer simply `apt-get` your package from the canonical repository, dealing with the fact that the standard docs and the published books might not cover your variation...
Tools like Github have made all this stuff much easier, but it's still a bad idea to tinker with others' libraries without a good reason.
The more typical advantage of open source is that you can read exactly what your library is doing, which makes it easier to figure out how to work around it without actually editing it.
---
[1] Until it isn't. But at that point it will generally get a different version number, and an official release notice, and it will have a community that is aware of the change and will promptly coordinate to find and fix any new incompatibilities with other libraries.
For me, encapsulation comes down to "What I hide, I can change. What I expose, other types may couple to in an inappropriate way."
And if the API isn't sufficient by not exposing enough, that's fine. It's always easier to expose something later than to make it private later.
I have never been bitten by over-promiscuous code entries in Python. The times I've gone beyond the published API, I knew I was doing it so I knew I had to keep track of it. And I've gone deep here (replacing Django's database handling in their unit testing framework).
On the other hand, I can't count how many times I've been stuck in Java figuring out how to get around somebody's final class or private method that I really needed to tweak just a little bit or, worse, I needed access to a field I can see in my debugger. Needing to reflect through to get at it is STUPID.
I know that I would prefer to work with an interface with 10 public classes with 50 public methods than an interface with 100 public classes with 5000 public methods.
The conceptual weight of wading through all of that stuff has a cost. There is often value in not knowing or caring about implementation details.
Although I do agree that final/sealed is generally just mean-spirited and pointless.
But when I need to deviate from that API, for whatever reason is important to me but not to the library designer (from a bug to a weird environmental issue specific to me), if I can't get done what I need to, the language is getting in my way instead of helping me.
I was just trying to point out that there are both benefits and drawbacks to language-enforced encapsulation and the benefits may be less obvious than than the drawbacks, which are generally more painful.
Given the choice, I'll choose consenting adults. :)
...if you're using Java, since (AFAIK) you can't switch between public fields and getters/setters. Python, however, has properties: http://www.python.org/download/releases/2.2.3/descrintro/#pr... . Point 4 of http://dirtsimple.org/2004/12/python-is-not-java.html covers why they're a good idea, though you can probably figure it out from their description.
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.
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.
http://www2.research.att.com/~bs/glossary.html#Gencapsulatio...
Since this idea is not obvious, would someone mind explaining?
Oh come on, that's not true at all. C++ just happens to use access modifiers to provide its brand of encapsulation. However, languages without the `private` reserve word can still provide encapsulation -- they're not the same thing.
What if Java had no notion of private? It would be very difficult to provide data hiding (not that they're hidden anyway, but that's beside the point), so instead you would be forced to put little flags on your names and warnings in your documentation delineating the parts that people shouldn't touch. If they did then that's their fault no?
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.
Some OO traditions choose to combine encapsulation with language-enforced access control. Some schools then teach that if you don't have enforced access control, you don't have encapsulation. They're right... by their definition. They are not right by all definitions. If you don't lay out the definitions you are using when you explain whether one is necessary to the other, you're just making undefined statements. And usually one will be related to the other by definition, which means the other basic alternative is to make a vacuous argument.
I say that like a lot of other things that are mistaken as language features, encapsulation is an attribute of the program, not the language. Encapsulation is when there is a clear boundary of code that accesses a certain data structure. I have seen many C programs that have perfectly well encapsulated data structures, despite the lack of language support for access control enforcement. But that's just my definition. It is not the definition.
WalterGR commented on reddit that this rant is actually in response to this tweet by Marco Tabini:
-------------------------
"@ijansch Private has absolutely no useful role in open-source code." ( http://twitter.com/mtabini/status/18867470296 )
-------------------------
Marco is the co-founder of "a consulting firm that specializes in information architecture, code and security auditing, large-scale deployments and optimization".
More information:
http://www.reddit.com/r/programming/comments/cusyw/wikileaks...
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.
Not quite - using reflection you can dig into private fields and do your worst to them, you just need to tag each private member's Field object with with field.setAccessible(true) before accessing it reflectively.
The only hitch is that you might get a SecurityException, but you can avoid that if you're running your code on your own JVM (by default, it should work just fine, it's if you're deploying applets or something like that where you might get the exception due to the different sandboxing rules).
http://richhickey.github.com/clojure-contrib/java-utils-api....
I am pretty sure this can be defeated without taking private out. Reflection will get you there with the security checking turned off.
favorite: "But use it exactly how I tell you to use it, because fuck you, it's my code. I'll decide who's the goddamn grown-up around here."
Goverment => Java Privacy => Private Method Public Alarm => ...
Why not all fields perid. Even those with getters,setter?
See http://download-llnw.oracle.com/javase/1.3/docs/api/java/lan...