Java The Unfriendly...
I must preface this with saying that I don’t do much Java work. Perhaps it’s more friendly for a different domain of work, but at least for me I find that it’s overly complicated to do simple things. For instance, checking the existence of a file looks like this:
Why do I need to spend the time creating an object just to throw it away? And that’s not even my real problem. The real problem is that it’s hard to read. To make it a little easier on the eyes, you can do this:
But now you have a couple other issues. First, I’m going to have a variable for something I’ve used exactly once. Second, if this function is long-running, then f will be around for a long time (unless compilers can optimize that out… that’s not been my experience though).
It all boils down to this: it’s too much work to do seemingly simple things. Moreover, absolutely everything does not need to be an object. There is no reason that you couldn’t offer a class method called exists() that takes a string and does the dance for you. At the very least, it would be easier to read:
The other difficulty is something rather new to the language: generics. Now I have a pretty extensive background in C++. I spent years coding in it until I met Python so I have a built-in mental model of how I think Generics should work. I’m using generics in a project at work, and what I find is that you can really tell that they were an after-thought. Joshua Bloch and Bill Pugh did a Google TechTalk that highlighted some of the more problematic issues with generics, especially in regards to autoboxing:
I’ve run into an issue recently with generics that I’m unable to make warnings go away for… which is highly irritating. For instance, I wanted to create a map that was keyed by Strings and stored a List of an interface. For instance:
Actually, I tried the above knowing it wouldn’t work. The problem is that you
cannot take .class of a generic (List
A fellow Subversionite, Blair Zajac pointed me to Scala. It’s unfortunate I can’t really use it in my current project, but it’s definitely more friendly than Java is today.