Sun are a big company. Really big. They created some of the most reliable server workstations, some of the fastest processors, some of the most stable OSs in the world. And they created the as of now most-used programming language, Java. Java is sort of nice. It's dumbed-down C++ with some enhancements, it's not feature rich, but nobody in their right minds wants a programming language to be feature rich. I'm a big advocate of "the right tool for the right job" and feature rich languages seem to contradict to that credo. Java is the right tool for many jobs: GUI creation in Swing is easy and straight forward, networking closs platform is painless and portability is one of Java's main selling points - because it's really easy. The only thing you have to keep track of is the JVM and source version and there you go.
I guess if we lived in milk-and-honey-land, that would make Java a perfect programming language. But it isn't, and milk-and-honey-land is far off. Java was supposed to bring interactive web pages to the clients more than ten years ago (note that JavaScript has nothing to do with Java). It failed. And miserably so, I must say. There's nothing that turns me off more than a page using a Java applet. They are ugly, they are slow to load, memory hogs, and they are buggy.
But I don't care about applets. Servlets are a much better technology anyways, and I found Java to be really useful for Web programming. But this rant is really about Java on the Desktop and about Java for the programmer. Over the years, I've come about some rather annoying misfeatures, bugs and Sun's stubborn way of not wanting to address bugs that have been known - literally - for years.
T[] stuff = new T[x];
is illegal. But a function header like void some_function(T[] stuff)
isn't. This means that you actually can have static arrays of generalized types, but you have to work your way around like T[] stuff = (T[])Object[x]();
This is ugly, and, moreover, it's dangerous. It's also a restriction that hits the language quite hard. Don't believe me? Read on...
public class General<T extends Something> {
InnerClass[] ic = new InnerClass[10];
private class InnerClass {
int data;
}
}
This will not compile. It fails with the oh-so-descriptive-and-helpful error message "generic array creation". There you go, the inner class doesn't even use that freaking parameter type. It's enough for it to be a subclass of a paramaeterized type. This is especially annoying when you have to create, say a tree class that is to store all sorts of interesting different types. That would be what them Generics are good for in the first place, right? Well, if you want the tree to have, say, 4 children per node, you'd love to do that using a static array, right? And inner classes are usually the best approach for making a specialized Node class... But in Java, you have to suffer compiler warnings and unsafe typecasts to do that.
This isn't even as much as I expected it to be, but there's more that I've missed for now. Jamie Zawinskie has a lot more on this, but I do not share all his views. Maybe it's that I'm just no C programmer and therefore I have a whole different set of expectations. Maybe I just don't understand all of his points, but I couldn't agree more with most of the stuff he describes. When you google for "why java sucks", you will find a whole bunch of pages. About 3000, for the phrase query. That's a lot for a phrase query.
I don't say Java sucks in general; it's an OK language for quite a number of tasks. And it's probably even the language I know best. But it has deficiencies, and quite some and then some more. I'll be moving on to greener pastures from now. Prolog sounds nice, it's well suited for what I'm currently doing. Haskell sounds even nicer, and I spend every free minute I can find with monads and similar stuff. I'll probably blog about it, too, when I'm good enough at it. ;-)