From: | jbuck@Synopsys.COM (Joe Buck) |
Newsgroups: | comp.lang.java,comp.compilers |
Date: | 25 Jan 1996 15:01:30 -0500 |
Organization: | Synopsys Inc., Mountain View, CA 94043-4033 |
References: | 96-01-037 96-01-063 |
Keywords: | translator, interpreter |
In a discussion of reimplementing other languages for the Java bytecode
engine, boutell.com@holly.aa.net (Thomas Boutell) writes:
>C++: see above, but more so. C++ does have several features which are
>missing from Java, most notably multiple inheritance and generic types
>(templates).
Ah, but Java does have multiple inheritance, with restrictions. In
Java, a class may be derived from one base class and may implement any
number of interfaces. But interfaces are simply what C++ calls
abstract base classes, with the additional restriction that they may
not contain data members. Thus a Java class that "extends" another
class and "implements" one or more interfaces is an example of
multiple inheritance. It turns out that some of the most common uses
of multiple inheritance in C++ meet these restrictions
(e.g. Stroustrup's recommendations on the design of container classes
in "The Design and Evolution of C++").
In other cases, data members for the second class can be faked in a
number of ways (e.g. stored in a HashTable someplace), so it should be
possible to retarget C++ multiple inheritance to Java. C++ Classes
that are used in multiple inheritance might have to be turned into
Java interfaces together with a basic implementation of that
interface.
Templates, on the other hand, may be added to Java.
--
-- Joe Buck <jbuck@synopsys.com> (not speaking for Synopsys, Inc)
--
Return to the
comp.compilers page.
Search the
comp.compilers archives again.