Why Java Sucks - Part 1
04 Mar, 2007 2141 by
phoebus
Java is not my favorite language. Despite a fairly robust class library, and some nice constructs, it has some serious problems. This first post will be about specific language “features” (or lack thereof). The next in the series will be a bit more general.
Update: my buddy JK, who commissioned this little screed, pointed me toward this guy, who says pretty much everything I do here, and more. I swear, I hadn’t even read this before when I wrote this list. I guess it just goes to show how glaring some of these langage oversights are, huh?
- First one good thing: no
free(). QED. Now on to the bad things. - No Macro system - I realize that the C Preprocessor is in many cases the Root of All Evil, but still, it has a lot of great uses, especially for things like easy conditional compilation.
- No inline functions (admittedly not a serious issue for modern compilers). I mean, seriously, why is this not here?
- Schizophrenic basic types:
intandInteger,byteandByte, etc. I know that Java sacrificed much of its usefulness on the altar of the Gods of OOP, but it just needs to pick one or the other; primitives or objects. I’m not going to say which it should be, but it should be one or the other. - The preceeding point also leads to some issues because primitive != Object. If a function expects an
Object, and I try to send it abyte, the compiler with give me an error in 1.4. In 1.5, it will automatically box thebytein a newByteobject, which quite possibly violates my reason for usingbytes in the first place (memory overhead, perhaps?). byteis unsigned. Since when does anyone working with a type called ‘byte’ want it to be unsigned? Of course, this means that if you want to loop through the values of byte as say, array indicies, you have to normalize them first.- The inability to use non-Unicode
Strings. Sometimes you know there will be no non-ASCII characters, and you’d really like to save a little memory. At least, I know I would. - No
printf(). Most languages have realized the incredible utility of this particular functional construct, and include it in a similar if not identical form. I’m not asking for total duplication of the feature set, but things like field width and format specifiers just rock out, you know? (Update: I see now that 5.0 added PrintWriter.printf()) - No
typedef. This is an extremely handy keyword. If I want say,longs, to represent something in particular in a Java class, I can’t really assert anything about them except for theirlong-hood. - Interfaces are a kludge created by someone who has it in for multiple-inheritance.
staticmethods are not class methods, even though Sun likes to pretend they are. No, they are global friggin functions. How do I know? Try overriding one in a subclass. Just try it.- Since
newis the only way to allocate a new object, there are lots of tricks and optimizations that can’t be performed. I can see how a single allocation method might help the Write-Once, Run-Anywhere potential of Java, but frankly, that sucks as it is (see my upcoming Part 2 post). - The new generics in JDK 1.5 don’t allow you to use primitives as E types. WTF?
- No function pointers/function references. And no, functor Objects are not a good way to accomplish this.
Posted in Coding |
Printer-Friendly Version
|