Tuesday, August 5, 2008

Java will replace C++ as the language of choice


I've been seeing this one a lot lately. Frequently the comment comes from a member of the original Java team. But other times it is voiced by someone whose fame and fortune is not tied directly to the belief that Java is the Second Coming. It is of course possible that everyone working in C++ today and all those who contemplate moving there will someday move all of their work to Java. But it's awfully unlikely.

The question is a pretty silly one today. Java code is far slower than C++, it can't do most of the things C++ can do and its object model and architecture hasn't been tested on large projects. We need to assume that Java can be made fast enough for most applications and that it will be given interfaces to all those libraries we need. We also need to assume that Java's long startup time (the time it takes to resolve method and data member location) can be reduced or eliminated without losing the flexibility that it was intended to provide. We need to assume that Java's garbage collector won't introduce unreasonable overhead when the programs and their data space requirements grow. (Remember that the 640KB memory limit in DOS was based on the experience with CP/M. CP/M gave you 64KB of memory. Who could possibly need more than ten times that?)

Even if Java were better than C++ at everything (a huge if), any claim to its replacing C++ ignores the inertia of the computer industry. Despite the success of C++, there are still more C developers in the world. The fact that PC-based development products include both C and C++ makes it difficult to know which language people use in what proportion. In the Unix world the answer is easier to see. And here C outsells C++ by a comfortable margin. This is in spite of the fact that C++ makes it easy to migrate existing C code with minimal modification in the code or in our development model. Java makes no such concession.

Of course, all this ignores the fact that most of the programming world doesn't work in C or C++. There is still a lot of Fortran out there among all the people who care about the best possible performance. And there's more Cobol than anything.

That the world is excited about Java is clear. That there is reason to be excited is clear as well. But I wouldn't start recycling those C++ books any time soon. Five years ago there was enormous hype about how C++ would change the world and usher in a new world for programmers. Ten years ago it was Lisp and Prolog and expert systems. Things have a way of not exactly turning out the way the press predicts. (Anybody remember how OS/2 was going to wipe Unix from the face of the planet?)

0 comments: