This is a read-only archive!

A calm and rational discussion of Java

In the past I believe I may have said that Java was god-awful. I was mistaken. Java is far more evil than any god. Java sucks like the black, empty vacuum-void of nothing that existed before time began.

I'm tasked with maintaining and updating some Java code at work. Today I wandered in to work in a chipper mood. The sun was shining, the birds were singing, life was good. Oblivious, I sat at my computer and fired up Eclipse. 20 minutes later it opened and I was looking at some Java code.

Events played themselves out like they usually do As Java flowed across my computer screen, at first it was a slight twinge in the back of my mind that something was wrong. All too quickly that twinge became a dull sort of deep-seated pain. As the minutes passed, my good mood drained from me like my life-blood draining from an open wound. Joy was replaced with horror at the programming atrocities being committed before my eyes. I'm not exaggerating to say that a few times I've looked at my screen wide-eyed, mouth agape, as involuntary mad laughter escaped me.

Whatever my many other faults, I'm pretty fast at reading code and understanding it. Still it took me over an hour today just to locate the place I needed to add five lines of code to get my job done. Generally I'll start at the top of some 20-level-deep hierarchy of classes and interfaces and abstract classes, and work my way down into it until I look back and realize I have no idea where I came from or what I'm even looking for any longer. You see, public abstract class com.someDomain.project.client.model.table.AbstractEditableTableModel, which extends AbstractTableModel and implements EditableTableModel, which itself is a superclass of GenericTableDataModel and MultiTableDataModel, may contain the stub of a method I have a vague notion I may want to look at someday, but the fun thing about Java is that I get to search the whole hierarchy of imaginary insubstantiatable classes top to bottom until I find the overridding method that really implements the logic I need to see. Then I get to re-search the whole tree to find all the methods that method calls, along with the many separate trees of classes of all the objects the first class uses.

The code I'm dealing with is 210 classes and interfaces worth of Java that does little more than fetch some data from a database and display it in a GUI in a couple of grids. Those 210 classes of course extend and implement many bits and pieces of standard classes from the Java's standard library, meaning the number of classes I really have to deal with is far higher. And most of them DON'T DO ANYTHING.

Most of this code is completely without comments of course, and important variables are named things like s and data. And methods have names like good old actionPerformed; so if the program, you know, performs any actions, I guess I'm covered.

But I shouldn't say it's entirely without documentation. Here's one method along with its documentation.

// used to propogate [sic] privilges [sic] down to the lowest node
public void pushPrivileges()
{
    int myPrivileges = getPrivileges();
    Iterator i = tables.keySet().iterator();
    while( i.hasNext() )
    {
        tableModel tbl = tables.get(i.next());
        tbl.addPrivileges(myPrivileges);
        tbl.pushPrivileges();
    }
}

This is one of the hundreds of boilerplate methods in the code I'm dealing with. I often wonder what proportion of code in Java actually directly works to solve your problem, and what proportion just flips buttons and turns knobs on hundreds of objects which in turn flip buttons and turn knobs on other objects, most of which have no need to exist, while Java spins its wheels in the mud. The above method would be one or two lines of straightforward Lisp or Ruby code, if this method even had a need to exist. Java is much like a 100-armed monster, who will put 3 of those arms to work to solve your problem if you very carefully tell it how to use the other 97 arms to masturbate itself.

The highpoint of my day though was finding a method called "isHasDeletePrivilege". Only Java could inspire such madness in a programmer. I very barely managed to keep myself from right-clicking in Eclipse, selecting refactor => rename and typing canHasDeletePrivilege. If you try to read Java code from the perspective of a group of retarded pseudo-sapient cats living on the internet, it actually makes a bit more sense.

The worst thing about Java is that it actually just barely can be used to solve most problems, which only continues to encourage people to use it.

March 27, 2008 @ 9:15 AM PDT
Cateogory: Programming
Tags: Java, LOLcats, Rant

12 Comments

Zeth
Quoth Zeth on March 27, 2008 @ 10:45 AM PDT

This post popped up in my RSS reader in the early hours of the morning here in the UK, so I was going to bookmark it. However, after the first two sentences I made it my home page. I hate Java and I hate all the people that keep throwing it into my face as a solution to a problem. Add Java to a problem, you now have two problems.

Jeremy
Quoth Jeremy on March 27, 2008 @ 4:38 PM PDT

Java has its faults, yes. But to write truly bad code you need one of two things:

1) A programmer who doesn't have a clue 2) a code generator.

Sounds like your boilerplate code was generated that way.

I think you'll find that if you actually spent the time learning swing and the java object model you'd find it a lot easier to navigate that codebase. 210 classes is small time stuff if the project is correctly structured.

Make no mistake, there are some parts of Java I loathe with the heat of a million suns. But the language itself is actually quite good, if you know your way around it.

J

Hollow
Quoth Hollow on March 27, 2008 @ 6:19 PM PDT

One important thing to note here is, that it really is the java language which sucks, not the java virtual machine, which also has some good languages to use it with (jython, groovy, etc)

David
Quoth David on March 27, 2008 @ 6:30 PM PDT

I'd probably have a similar cow if I had to deal with poorly designed code in any language I didn't know very well.

Every language has it's place. As far I can tell, J2EE apps are the only thing Java's particularly good for (and even then, only if well designed).

NameNotFoundException
Quoth NameNotFoundException on March 27, 2008 @ 6:48 PM PDT

Wow! It happened to me, too! I recently read a really shitty book in French, and I must say, it was absolutely loathesome. The characters were stupid, flat and outright ridiculous, the story was boring and not worth the paper it was printed on, there were spelling errors, cuss words and bad grammar anywhere, and the whole book really sucked big time. Besides it was 1000 pages long where 10 had fully sufficed. Really, French is such a crappy language. I can't understand how people can be so dumb and still write books in it. Abominable and disgusting! The worst thing about French is that it actually just barely can be used to express most things in it, which only continues to encourage people to use it.

numerodix
Quoth numerodix on March 27, 2008 @ 6:57 PM PDT

I'm wondering if this is a good time to mention jruby. I hear it's nice when you inherit a java codebase and you can interface it from ruby without writing anymore java.

Hates_
Quoth Hates_ on March 28, 2008 @ 2:07 AM PDT

Yes, Java has it's flaws, but it sounds like your gripe is really with author of the code you had to maintain. You could produce the same sloppy and poorly documented code in just about most languages.

ph0enix
Quoth ph0enix on March 28, 2008 @ 9:28 AM PDT

isHasDeletePrivilege(). 'nuff said.

The Other Jeremy
Quoth The Other Jeremy on September 23, 2009 @ 6:31 PM PDT

No... the virtual machine sucks too. Have you ever fired up a java application in Windows? The answer is no. Java applications do not "fire up". Ever. They also do not release all the memory that the VM hogs once you quit them.

It doesn't really even matter whether the language sucks or not, because the applications are the absolute worst thing you will ever run on your Windows machine. If you have a choice between a free program written in shit-ass java, and an expensive one written in any other language ever conceived, go with the expensive one. You will hate life if you ever have to use any java application on any but the most powerful of desktop computers. Every single Windows java desktop application I've ever used has slowed down every single Windows machine I've ever used them on, and I've been using Windows for ~11 years and have used thousands of programs. Fanboyz can argue all they want about how this or that isn't exactly as shitty as I or someone else says, but the truth, the real truth, is that java is just fucking stupid. Weak, lame, stupid, and pathetic.

Martin V.
Quoth Martin V. on June 28, 2012 @ 1:37 AM PDT

Quoth The Other Jeremy on September 24, 2009 @ 1:31 AM PDT

No... the virtual machine sucks too. Have you ever fired up a java application in Windows? The answer is no. Java applications do not "fire up". Ever.

Some guy using Delphi asked me once to write a stub to call into a JVM to do some "Cookie-decoding" he could not pull off in Delphi (despite some "documentation"): some 512 bits had to be split in 2 halves, the first one decrypted with some 256 bit public RSA key to yield a 256 bit AES key that was used to decrypt the second part which contained the "cookie data".

For each such sequence he re-launched the JVM, called the decryption-method and got the data to use it in his web-app. That took 0.1 sec, and, yes, that included initialization and termination of a fresh JVM each time he called. And that was old Java 1.4.2!

Well, he could have accelerated it by not re-launching the entire JVM each time, but he said it was fast enough for him. If a VM-launch in under 0.1 secs is too slow for you, blame him, not Java!

They also do not release all the memory that the VM hogs once you quit them....

Well, they do ... and if they don't, it's the fault of the OS (NOT of the already terminated VM-process 8-o)

Every single Windows java desktop application I've ever used has slowed down every single Windows machine I've ever used them on, and I've been using Windows for ~11 years and have used thousands of programs.

Sure, "thousands" ... :-) Well, I still remember glorious Internet Explorer (at the time of abovementioned Java 1.4.2) on WinNT 4.0 (with service pack 6a ;-) to leak graphics resources like mad: Some intensive research through the web and many opened and closed browser windows would bring the operating system's graphics and windowing engine to a grinding halt - that worked every time I tried. And with non-Java, good and "performing" native Code only!

Fanboyz can argue all they want ...

Windows "Fanboyz" usually argue that "all" Windows software they "ever saw" was highly performing and not resource-hogging - while experienced users never had to search much for striking counter examples.

.... but the truth, the real truth, is that java is just fucking stupid. Weak, lame, stupid, and pathetic.

Well, you name it (at least, you've memorized all those good words that you can throw at stronger "competitors" eating your breakfast ;-)

Martin V.
Quoth Martin V. on June 28, 2012 @ 1:42 AM PDT

Well, I guess that the delay in adding that comment that caused me to re-post several times is another "firm proof" that Java is crap: The topic is Java? => something goes wrong or dead slow. (culprit nailed ;-)

Martin V.
Quoth Martin V. on June 29, 2012 @ 12:07 AM PDT

Hi Brian,

when, over the sample method cited, you wonder

what proportion of code in Java actually directly works to solve your problem, and what proportion just flips buttons and turns knobs on hundreds of objects which in turn flip buttons and turn knobs on other objects, most of which have no need to exist, while Java spins its wheels in the mud

how do you know, which objects/knobs/thingies "have no need to exist" and how this can be possibly a programming language's fault?

From the little code shown, I can only deduce that its author was not knowing even the base library classes and loop syntax well. E.g. why he has not just written

public void pushPrivileges()
{
    int mine = getPrivileges();
    for(tableModel tbl : tables.values())
    {   tbl.addPrivileges(mine);
        tbl.pushPrivileges();
}   }

is beyond my reach.

But what was YOUR complaint with the method?