Departments


Editor's Forum


Is It Time for Java++?

I was just teaching a class on Java threading, which is by far the weakest part of the Java language. The discussion inevitably comes around to how to fix the problems, and language-level solutions are often mentioned. Though there is a very-early-stage proposal for a JSR that will add a library of threading primitives to the language, a library-based solution is an awkward solution at best. It would be better to augment the language itself. Moreover, threading is just the tip of the iceberg. Java’s access privileges are too weak; Java needs a true, constrained, enumerated type; the list is endless. There’s a point at which solving these problems solely through libraries becomes unworkable. Library-based code is simply too complex in unnecessary ways.

A year or so ago, I proposed (in an article for IBM) that the language be modified in a few minor ways to provide elegant, language-level solutions for some of Java’s multitude of threading problems. I discovered, though, that it’s almost impossible to make changes — even minor ones that don’t affect the bytecode — to the language itself. Sun has an iron grip on the language, and they just don’t want to relinquish control, even if the new language would be backwards compatible with the old one.

I find this attitude unfortunate. Computer languages have a limited lifetime, and one of the reasons for the limit is that, as our knowledge of computing improves, we want languages that support new ways of looking at the computer. OO (object-oriented) languages like Java are a classic example. There’s not a thing you can do in Java that you couldn’t do in C, but it sure would be a lot harder to do it in C. I had been hoping that Java would avoid obsolescence through the JSR process — that the language itself could evolve to fix known defects and support new ways of programming. Sun, in its infinite wisdom, would see the libraries surrounding Java grow while the language itself ossifies, however.

So what’s a mother to do? One solution is to develop a new language that fixes Java’s problems, but whose compiler creates standard bytecode (or even Java source code, much like the original C++ compiler worked). This way you could write in the new language while still being able to leverage legacy code and libraries. I’m tempted to do it in my copious spare time (that’s a joke), but a project of the magnitude of a compiler is a significant amount of work. Perhaps, given enough nudging, Sun itself could be persuaded to loosen up a bit. We’d all benefit if Java didn’t go the way of PL/1.

Allen Holub
Senior Editor