Article View: comp.lang.java
Article #6Re: C++ and Java
From: Nelson Yu
Date: Sun, 08 Oct 1995 09:00
Date: Sun, 08 Oct 1995 09:00
49 lines
2206 bytes
2206 bytes
Solution Technology wrote:
>
> Nelson Yu (nelson@scapa.cs.ualberta.ca) wrote:
> [...]
> : Java has
> [...]
> : 4) A nice class hierarchy(i.e everything is derived from object)
>
> Very argumentative! Deep trees result in almost monolithic systems
> that are hard to change.
In C++ you would do(every good class has these)
class __rtti MyClass
{
public:
MyClass();
// Virtual destructor
virtual ~MyClass();
// Copy constructor
MyClass(MyClass c);
// Assignment operator
MyClass& operator=(MyClass& myClass)
};
This is totally unnecesary under Java, since copy(), class() and
clone() are ALL located in Object. Object _encapsulates_ the
basics such as object's identity and copy construction. Since
everything is derived from Object, the power of polymorphism can
be exploited. Of course C++ templates are faster, but then we get
the problem of code bloat.
I know very well that once an hierarchy has been set it's
extremely difficult to change. AWT lacks protected
methods/variables for extendiblity and is fairly rigid(although
its 'interfaces' help loosen it up). IMHO Java(excluding the
ever-changing AWT) has a nice hierarchy because
1) Has a well designed parent class.
2) Well designed and fairly shallow class structure(using single
inheritance) compared to C++ libraries. Take a good look at how
complex iostream(with multiple inheritance) is!
Albeit you can't compare OWL with AWT, which has fairly
complicated hierarchy that uses multiple inheritance extensively,
'cause they are suited for different purposes.
Technical Details
Message-ID:
<30779340.64E4@gpu.srv.ualberta.ca>Path:
arc1-ca.pugleaf.net!rover.ucs.ualberta.ca!newsReferences:
<4535bv$cfr@susscsc1.rdg.ac.uk> <453vg1$d7j@scapa.cs.ualberta.ca> <4565t8$u5q@hopi.gate.net>Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!rover.ucs.ualberta.ca!news From: Nelson Yu <nyu@gpu.srv.ualberta.ca> Newsgroups: comp.lang.java,comp.lang.c++ Subject: Re: C++ and Java Date: Sun, 08 Oct 1995 03:00:48 -0600 Organization: Computing and Network Services, U of Alberta, Edmonton, Canada Message-ID: <30779340.64E4@gpu.srv.ualberta.ca> References: <4535bv$cfr@susscsc1.rdg.ac.uk> <453vg1$d7j@scapa.cs.ualberta.ca> <4565t8$u5q@hopi.gate.net> NNTP-Posting-Host: nyu.remote.ualberta.ca Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit X-Mailer: Mozilla 2.0b1 (Windows; I; 32bit)