In a number of ways, Java is a more dynamic language than C or C++. It was designed to adapt to an evolving environment. For example, one major problem with C++ in a production environment is a side-effect of the way that code is implemented. If company A produces a class library (a library of plug and play components) and company B buys it and uses it in their product, then if A changes its library and distributes a new release, B will almost certainly have to recompile and redistribute their own software. In an environment where the end user gets A and B's software independently (say A is an OS vendor and B is an application vendor) problems can result.

For example, if A distributes an upgrade to its libraries, then all of the software from B will break. It is possible to avoid this problem in C++, but it is extraordinarily difficult and it effectively means not using any of the language's OO features directly.

By making these interconnections between modules later, Java completely avoids these problems and makes the use of the object-oriented paradigm much more straightforward. Libraries can freely add new methods and instance variables without any effect on their clients.

Classes have a runtime representation: there is a class named Class, instances of which contain runtime class definitions. If, in a C or C++ program, you have a pointer to an object but you don't know what type of object it is, there is no way to find out. However, in Java, finding out based on the runtime type information is straightforward. Because casts are checked at both compile-time and runtime, you can trust a cast in Java. On the other hand, in C and C++, the compiler just trusts that you're doing the right thing.

It is also possible to look up the definition of a class given a string containing its name. This means that you can compute a data type name and have it easily dynamically-linked into the running system.

--The Java Language, An Overview


Java doesn't solve the fragile base class problem, but it does solve most other problems involved in dynamic linking of objects. Java 1.1 has substantially expanded the ability to instantiate classes and call methods dynamically at runtime. The JavaBeans component architecture promises to be a relatively simple means to combine many different components from different sources.

Bottom Line: A-

Previous | Next | Outline | Cafe Au Lait Home Page
Copyright 1997 Elliotte Rusty Harold
Last Modified Sunday, March 9, 1997