Tuesday, May 27, 2008

Java: getting old and crusty

One of the main reasons I finally decided to start blogging is that I find myself whinging about the state of Java (the programming language) again and again. That type of repitition surely violates the DRY principle, so I figured I should have one place to collect my thoughts in a reasonably structured fashion and then point whoever might be interested there.

So here we go...

I've been using Java for about 7 years now, which makes it my personal record. I wasn't there from the beginning (I never even had to use pure AWT), but I believe over the years I have seen enough to have a well-founded opinion about Java the language and many things in the Java eco-system.

Fact is that I think Java the language is a very poorly designed programming language that collected a lot of cruft over the years. Sun's inability to stop chasing the holy grail of backwards compatibility (but inavoidably failing) has stopped the language from being cleaned up from problems, while at the same time the need for new features added more complexity into the already brittle system. The result is something that is hard to grasp for an experienced programmer and in my opinion causes a lot of conceptual overhead in every single programmer that would be avoidable. And of course it raises the entry barrier, adding cost to learning Java and most likely stopping quite a few people from trying it in the first place.

I even go further and claim that Java as it is causes a lot of cultural damage. While it certainly was an advancement over previous languages in some regard, it left many a problem unsolved and added some new ones. The workarounds to these problems are now what most programmers consider state-of-the-art and while I never counted I would guess that about half the patterns in the GoF book wouldn't be needed if our programming languages weren't as bad. Instead of looking for proper solutions people take the problems as unavoidable since they do not know any better. Java Puzzlers are not fun, they are a warning sign.

You might wonder why I rant like a grumpy old man instead of just going somewhere else. The problem is that the grass doesn't seem greener on the other side of the fences.

Certainly C# has evolved a lot more over the years, but somehow .NET as a platform doesn't seem to offer all the luxury of hundreds of OpenSource libraries and great development tools that the Java ecosystem has to offer. I must admit that I haven't really tried .NET yet, so maybe I will stay corrected on that one one day.

On the other hand the languages that are based on the JVM and aim to interoperate with the Java world are not really what I like. Groovy, JRuby, Jython etc. lack manifest typing -- what I am looking for is a language to replace Java in long-term projects and I am a strong believer in having expressed your intentions well in code (something I will probably talk about in later posts). And while I consider Scala a very interesting language it seems a bit too much to change at once and a bit too experimental in places. I can see myself coding in Scala in the future, but I find it hard to imagine the type of teams I have worked with over the years to switch over anytime soon.

What I would like to see is a new version of Java -- something the JavaPosse discussion group calls "Java3k", alternative labels I have seen are "Java 2" or "Java++". I quite like the first one since it seems to imply that it is not really about time-to-market. So from now on I will refer to a new and extra fabulous version of Java that has all the problems fixed as "Java3k". The even more fictious version after that is "Java4k", which I might refer to if I discuss features that I don't think are ready for mainstream yet.

If I stick to my plan the following posts will discuss in detail certain aspects of what I would like to see in a Java3k. The pattern I am intending to use is first to explore a problem in the existing Java language, then discuss what could be done about it in general and how I would like Java to change. Whenever possible I will try to link the ideas to their origin in other programming languages, but unfortunately I will probably not be able to provide strong references for everything. That is usually not because things are my own inventions, it is more that I am not good in keeping track. Even if I remember that I got an inspiration somewhere I do not always recall where I got it from. Feel invited to comments on missing links.

No comments: