Re: Beginner, Which language
From: Programmer Dude (Chris_at_Sonnack.com)
Date: 10/07/04
- Next message: Erik Hensema: "Re: Why NOT to use QT"
- Previous message: MSCHAEF.COM: "Re: Some thoughts about OO programming"
- In reply to: MSCHAEF.COM: "Re: Beginner, Which language"
- Next in thread: MSCHAEF.COM: "Re: Beginner, Which language"
- Reply: MSCHAEF.COM: "Re: Beginner, Which language"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Date: Thu, 07 Oct 2004 08:40:15 -0500
MSCHAEF.COM writes:
>> When you have a class that implements several interfaces, multiple
>> inheritance can get messy.
>
> That's much more true for implementation inheritance than interface
> inheritance, particularly when multiple base classes of a class have a
> base class in common.
Yes, exactly. My wording was unfortunate...multiple inheritance
(which I define as *implementation* inheritance--I don't use the term
for classes that implement multiple interfaces) is messy, *especially*
with a shared bases class.
Not undoable... must messy.
> With regards to some of the implementation complexities that C++ goes
> through to support interface inheritance, that seems pretty mild
> compared to the run time support Java requires.
In my mind, C++ does not support INTERFACE inheritance at all (in any
native sense), so I don't follow your point here.
>> No, of course not. The point is that languages that provide the
>> mechanism natively accomplish it on your behalf.
>
> Aside from the bit of meta-information, does it do anything else?
I think that meta-information is very nice! Source code is for other
humans, right? To the CPU it's all machine code. The ability to say,
in a design, look here, these objects "aren't-a" <parent>, but they
do "play one on TV", so to speak. I think that's a valuable thing you
can add to your design. That Java provides that ability in a single
keyword and concept is just nice.
That alone won't make me switch from C++ to Java in my own work--my
(personal) stuff tends to be Windows-based: little tools that make my
work (either work or personal) easier, better or more fun. (Like, the
most recent one is YAXV (Yet Another XML Viewer). Didn't like any
of the ones I'd found, so I made my own. Now I have a fast, Windows
tree-based graphic XML viewer, and *I* got to pick the icons! (-:
(The tree-based GUI HTML viewer I'm working on has different icons for
each tag type. What's a good icon for <h2>? :0)
But I digress. Meta information Good.
> Let's just say that C++ hypothetically had an interface keyword that
> worked just like class, with the following exceptions:
>
> - All members are public
> - There can be no data members
> - All member functions are declared pure virtual.
> - All base classes of the interface must also be declared with interface
> and meet these criteria too.
[shrug] Then it would be C++-with-Interfaces.
> Would that match the value you see in Java's explicit support of
> interface inheritance?
It would indeed match that nicety in Java. But what's your point?
That C++ is just as good as Java if it changes to be like Java? (-:
Anyway, I don't mean to suggest either is better than the other in any
general sense. I'd develop Windows programs (which I do a lot) or low
level drivers or number crunching/file processing applications in C++.
I'd write J2EE applications in Java! (And to a nuub, I'd recommend
Java over C++, which is the point of the thread.)
> Would this suffice (to get the explicit labeling of interface classes):
>
> #define interface class
Not in my book--you may have a different book. (-:
1. #define is on the "Avoid List" in C++ (in my book).
2. Slapping another coat of paint on class doesn't alter reality.
You can't enforce your rules--which kinda goes to the discussion
about static typing languages. Languages with a native concept
of interfaces can enforce rules about their construction.
> Where I'm coming from in this is that C++ could be a lot worse.
C++ has no reason to feel attacked in this discussion. To say that
language A has a nice feature, shouldn't make all the other languages
feel bad. EVERY sensible language of a certain age has nice features
or it wouldn't be around.
I happen to think C++ is *wonderful*, and I have a long-standing,
passionate relationship with her. I like pointers--in moderation,
although sometimes it's fun to just go pointer-crazy...sparse matrices
are a good excuse--and here's a C++ goodie *Java* *can't* *do* (so
nah, nah, nah, nah, NAH, nah):
void Auto_Variables_Yea (const CjString& name)
{
CjFilename file_name(name);
CjFile file(file_name);
try {
file.Open();
// do interesting stuff
file.Close(); // don't really need this!
}
catch (CjErr& e)
{
// WHOOPS!!
}
}
How sweet and clean. No "new". (And you KNOW that your resources
will clean themselves up when you leave scope. EXACTLY then.)
> Without either pure virtual methods or multiple inheritance, implementing
> interface inheritance would be considerably more difficult.
We can end on a note of agreement! (-:
- Next message: Erik Hensema: "Re: Why NOT to use QT"
- Previous message: MSCHAEF.COM: "Re: Some thoughts about OO programming"
- In reply to: MSCHAEF.COM: "Re: Beginner, Which language"
- Next in thread: MSCHAEF.COM: "Re: Beginner, Which language"
- Reply: MSCHAEF.COM: "Re: Beginner, Which language"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Relevant Pages
|