Home > java > Ten Little Soul Crushing Features of Java

Ten Little Soul Crushing Features of Java

There are a lot of big things (lack of closures, type inference, etc, etc) to dislike about Java. This is a list, in no particular order of little things that make day to day Java development just that much more irritating. Most of these are just convenience methods whose omission is unforgivable. Libraries exist to address all of them, but that’s beside the point.

1) No string join method

How many times have I written this?

2) No way to set additional JVM parameters in manifest of executable jar

It’s really convenient to just double-click a jar … until you need to set your heap size or something and you have to go crawling back to a shell script.

3) java.net.URL constructor throws checked MalformedURLException rather than unchecked IllegalArgumentException

Seriously, what is so special about this exception?

4) java.io.File has no getExtension() method

Same as join() above.

5) No immutable collections.  Collections.unmodifiableList() and friends don’t count

6) java.io.File.delete() silently does nothing if you try to delete a non-empty directory

It’s even more irritating to write deleteFolder() than join() and getExtension().

7) java.util.Random has a setSeed() method, but no getSeed() method

8) java.util.logging is built-in and incredibly lame

They sucked every ounce of the joy out of log4j.

9) JTree selection behavior gives me a headache every time I have to deal with it

10) No method to just read an entire InputStream or Reader into a byte array or string

Same as join() above.

Bonus) No method to copy a file!

Categories: java Tags:
  1. oldmicah
    April 9th, 2009 at 11:00 | #1

    Pretty amazing list, although a perhaps a little exaggerated. I have only found myself cussing late at night over #2,3,4,6,78,9, and 10.

  2. mkneissl
    April 19th, 2009 at 06:51 | #2

    Mostly agree to your list, but shouldn’t 6) read “non-empty directory”?

  3. April 19th, 2009 at 07:09 | #3

    Yep. It’s fixed now. Thanks for catching that.

  4. Svend
    May 8th, 2009 at 12:22 | #4

    1. Isn’t that what String.concat(String) is for?
    10. InputStream and Reader are streaming interfaces, which means that they can have more content than you can fit in an array. It sounds like you’re talking about file based input stream or readers, in which case you can do this (provided your file length is smaller than 2GB):
    method(File file) {
    FileInputStream fis = new FileInputStream(file);
    byte[] bytes = new byte[(int)file.length());

  5. May 8th, 2009 at 12:31 | #5

    join() can be implemented with concat(), but they’re not the same. I want to write:
    “, “.join(Arrays.asList(“Jim”, “Bob”, “Al”));
    and get:
    “Jim, Bob, Al”.

    You’re code for reading a file is fine, but, again it’s a matter of convenience. Rather than writing that function over and over from project to project I want it built in:
    String s = String.fromFile(“test.txt”);
    or something like that.

    I’ve just been spoiled by scripting languages I guess.

  6. July 22nd, 2009 at 10:43 | #6

    IllegalArgumentException is to be thrown when argument is illegal or inappropiate, and it’s a RuntimeException (About RuntimeException, since every method can throw it, none is required to tell, so it’s easy to miss that or any of its subclasses)
    MalformedURLException is more strict, specifically it hasn’t a recognizable protocol or the url string couldn’t be parsed. It’s a IOException subclass, no a RuntimeException one, so it has to be declared and thus it won’t jump by surprise.
    Beside RuntimeException family (like NullPointer, ClassCast, IndexOutOfBounds…), MalformedURLException seems full of sense to me…

  1. No trackbacks yet.