Skip to main content

Java 1.5: The end of Java?

Posted by javaerb on July 21, 2003 at 12:14 PM PDT

Return with me, if you will, to the early days of Java. It was hot. People started using it when it was alpha; by beta, there was at least one book out, Netscape supported it, and people were already using it on their web sites.

Clearly, the great attraction of Java at the time was the ability to make your web pages actually do something. But Java had other attractions as a language. For me, the core library was thrilling. What really made me fall in love was that I got high-level socket programming for free, and without needing to read a book on networking. But the language itself was also appealing. In the same general family as C++, it provided the most powerful constructs in a simpler language.

It is the language I wish to speak about here. I had been using C++ on and off for several years before, and C long before that. C appealed to my true hacker side. But looking at C++, I decided it was really an ugly language. In C and C++, punctuation characters are the significant delimiters and language constructs. Since C++ needed to extend the functionality of C, symbols need to do double and triple duty. Think of the :: operator. Throw in operator overloading, and you get constructs like iostream::operator=(streambuf* _sb). And of course it is always easy to write ugly C++ code anyway, as attested to by all those whole-program-in-one-line oddities we've seen.

In contrast, Pascal was a more attractive language than C. More keyword-based, and less powerful, it was much more suited to novices, but also encouraged nicer coding. Java is a bit more Pascal-ish. The elimination of pointers makes it slightly less powerful, and it is slightly more keyword-oriented (think of instanceof as an operator), though not by much (it still uses braces instead of Begin/End). Yet because of elimination of many features, such as operator overloading, templates, and multiple inheritance, it looks less cluttered with symbols. And one of the attractions of Java in general was that it was simpler. I grudgingly accepted the absence of multiple inheritance, because I accepted the arguments of how much complexity it eliminated.

Then came inner classes. At first they irked me no end. I felt thay made the code so much harder to read, mostly by adding extra levels of nesting. But I slowly accepted the value of certain usages, such as anonymous inner classes, very useful when a quick listener implementation is needed. Now, with modern IDE's that give tree representations of your code and allow you to navigate it in all sorts of ways, I use inner classes all over the place without fear of getting lost in my souce code. Though I did wish they had added multiple inheritance while they were at it...

Now I hear about Java 1.5 and new language constructs being added. OK, I say, templates are kind of cool, and I'm sure Sun will find an elegant way of implementing them. No such luck. The Java template -- oops, I mean generics -- syntax is as jarring as that in C++. Then I look at other features and see they are even worse. 1.5 adds an enhanced for loop. OK, I think, it will look something like:


foreach o in c{}


A bit unusual for Java, but not beyond possibility. It adds new keywords, but isn't that what happened with assert anyway? But no, we get:


for (Object o : c)


Hey wait a minute, I must be looking at the C++ web page by accident... no, it's the folks at Sun presenting this to us with a straight face. So now I'm thinking about Animal Farm with the animals becoming indistinguishable from the humans. And I'm still wondering where multiple inheritance is...

OK, this log is starting to get a bit long here, but I think you see where I'm going with it. Sure, I can avoid using the new Java language features, but I know from previous experience that is not going to happen. So with Java looking more and more like C, I'm starting to wonder what my reasons are for not switching to C#. Sure, the multiple platform support might be a bit weak, but most of my recent jobs have been mainly Windows-based. Yes, C# brings many of the pitfalls of C++, but it also has most of the benefits of Java. And it's supported by Microsoft, and it's being standardized. I think Sun is eventually going to get in trouble from the tight hold it keeps on Java, ending up in the same place as other companies that thought they knew better than the market. (Think: logging API.) Unless you are Microsoft and can steer the market, you need to tread carefully.

Related Topics >>