comp.lang.ada
 help / color / mirror / Atom feed
From: Richard D Riehle <laoXhai@ix.netcom.com>
Subject: Re: A question for my personal knowledge.
Date: 1999/05/19
Date: 1999-05-18T20:24:11-05:00	[thread overview]
Message-ID: <7ht3rr$e65@dfw-ixnews5.ix.netcom.com> (raw)
In-Reply-To: t7ogjicaoj.fsf@calumny.jyacc.com

In article <t7ogjicaoj.fsf@calumny.jyacc.com>,
	Hyman Rosen <hymie@prolifics.com> wrote:

>Richard D Riehle <laoXhai@ix.netcom.com> writes:

>>  As to comparing the languages, such comparisons are nearly always
>>  fruitless.
>
>But you started it! You said that to the uninformed, C++ looks simpler
>than Ada, but that with deeper understanding, the opposite becomes
>apparent. I invited you to show me some code which demonstrates this.

 I apologize for having "started it."  I should know by now that 
 language comparisons are the equivalent of wading through fresh
 taffy on a warm autumn afternoon, sweet but difficult when a quick
 movement is necessary.  

 I am going to decline this invitation, but decline with a thank
 you.  The thank you is because your challenge has opened a new
 avenue of thought for me, an avenue I am going to explore by
 creating just such an example for the book I am currently writing.
 It is clear from the discussion that I might be able to make a
 contribution by creating such an example.  

 As a point of information, I will use the C++ Vector class example, 
 published in most textbooks about C++, the .  This example
 works in the comparison because it is nearly always designed with
 all four of the member functions mentioned in my earlier post.  An
 interesting feature of C++ design is the frequent use of * and & for
 variables and function return types.  In this respect, Ada is quite
 different.  That is, we do not use pointers and references in quite 
 the same way, mostly because of the increased risk of using these in
 safety-critical applications.  Yes, I know of the availability of 
 memory.h and other features to reduce the risk of raw pointers.  And
 this certainly does help C++ to be a little safer.

 I do not want to give the impression that I think C++ is evil, or even
 bad.  It is a very good language.  In my earlier post, I tried to emphasize
 that some aspects of C++ are less than wonderful and some aspects of Ada
 are less than wonderful.  My actual point was somewhat obscured by the
 way I presented it.  Someone had mentioned that the syntax of a C++ class
 was more intuitive or easier, or some such thing.  My point was that the
 simplicity seems simpler than it really is.  Class design, whether in 
 Ada, Eiffel, or C++ is not so simple.  Some kinds of designs will be 
 better in Ada.  Others might be better in C++.  It is, however, a mistake
 to think that the simplicity of the class format in C++ makes it easier
 than the class format in Ada -- or vice versa.  

>I don't know Ada, and I don't feel like learning it right now, but I
>think I could follow an example you post. So show me an object which
>requires a constructor and user-defined assignment operator in C++,
>but only a simple declaration and no such operator in Ada. Or if I
>misunderstood, just show me *something* where Ada's object model lets
>you do away with things that C++ requires.

 The textbook example of the Vector class is a good example.  Not only
 does one need to include a constructor (at least one), but also a
 copy constructor, a destructor, a friend function for the + operator,
 and a lot of other stuff one would not find in a typical Ada package
 for the Vector class.  On the other hand, I might very well want to 
 design a Vector class that had all that stuff.  I would not require
 a "friend" function because Ada's model would not require such a thing.
 If I designed the type as,

           type Vector (Size : Positive) is limited private;

 I would need a copy procedure to emulate assignment (but no separate
 copy constructor), and would probably overload the equality operator.
 I actually have a wide range of options for this design.  If I design
 it as,

          type Vector (<>) is private;

 then I will, in fact need something equivalent to a constructor such
 as a function that returns the constrained type,

          function Make (Size : Positive) return Vector;

 and will probably want to create a copy procedure for this type. Again,
 Ada practitioners will consider other design options such as use of
 a controlled type to implement an adjust procedure to prevent the 
 potential for constraint errors at assignment.  The point is, I have
 a wide range of options for designing either an elegantly simple 
 Vector or an elegantly complicated one.  

 I can also design an Ada type that resembles the C++ class, with all the
 attendant overhead.  It is more difficult, I think, to design a C++
 class that resembles an Ada type.  This will be an interesting example
 to design for my book.  It will require some thought, some compilations,
 and some testing.  I am not going publish the code here since I intend to
 use it in my book.  

 This is more than I intended to say on this subject.  I don't plan to 
 say anymore.  (Say Amen, someone).  I know this will not satisfy you.
 When you are ready to study Ada I think you will enjoy what you discover.
 Until then, enjoy the experience with C++.  I am enjoying my experience
 with it too.

 Richard Riehle
 richard@adaworks.com
 http://www.adaworks.com




  reply	other threads:[~1999-05-19  0:00 UTC|newest]

Thread overview: 58+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
1999-05-10  0:00 A question for my personal knowledge Siamak Kaveh
1999-05-10  0:00 ` Dan Nagle
1999-05-10  0:00 ` Roy Grimm
1999-05-11  0:00   ` Pascal Obry
1999-05-11  0:00     ` Roy Grimm
1999-05-11  0:00       ` Robert Dewar
1999-05-11  0:00         ` Roy Grimm
1999-05-12  0:00           ` Robert A Duff
1999-05-11  0:00         ` dennison
1999-05-13  0:00           ` Mike Yoder
1999-05-13  0:00             ` Mike
1999-05-13  0:00               ` Martin C. Carlisle
1999-05-14  0:00               ` Dale Stanbrough
1999-05-13  0:00                 ` Mike
1999-05-13  0:00                   ` David Starner
1999-05-18  0:00                     ` Georg Bauhaus
1999-05-13  0:00                   ` Brian Rogoff
1999-05-14  0:00                   ` Florian Weimer
1999-05-14  0:00                     ` Steve
1999-05-15  0:00                       ` Florian Weimer
1999-05-15  0:00                         ` Matthew Heaney
1999-05-14  0:00                   ` Dale Stanbrough
1999-05-15  0:00                   ` Matthew Heaney
1999-05-18  0:00               ` Richard D Riehle
1999-05-18  0:00                 ` Hyman Rosen
1999-05-18  0:00                   ` Richard D Riehle
1999-05-18  0:00                     ` Hyman Rosen
1999-05-19  0:00                       ` Richard D Riehle [this message]
1999-05-11  0:00       ` Marin David Condic
1999-05-11  0:00         ` Roy Grimm
1999-05-11  0:00           ` Tucker Taft
1999-05-11  0:00             ` Roy Grimm
1999-05-12  0:00         ` Roger Racine
1999-05-12  0:00           ` Marin David Condic
1999-05-17  0:00             ` Charlie McCutcheon
1999-05-17  0:00               ` Larry Kilgallen
1999-05-17  0:00                 ` Chris
1999-05-17  0:00                   ` Marin David Condic
1999-05-17  0:00               ` Marin David Condic
1999-05-17  0:00             ` Richard D Riehle
1999-05-18  0:00               ` Marin David Condic
1999-05-18  0:00                 ` bglbv
1999-05-18  0:00                   ` William B. Clodius
1999-05-10  0:00 ` Marin David Condic
1999-05-10  0:00   ` Paul Whittington
1999-05-10  0:00     ` Marin David Condic
1999-05-10  0:00 ` Sam
1999-05-10  0:00 ` Larry Kilgallen
1999-05-10  0:00   ` Keith Thompson
1999-05-12  0:00     ` Charlie McCutcheon
1999-05-12  0:00       ` Werner Pachler
1999-05-17  0:00         ` Charlie McCutcheon
1999-05-17  0:00           ` bglbv
1999-05-17  0:00             ` Larry Kilgallen
1999-05-18  0:00               ` bglbv
1999-05-19  0:00                 ` Larry Kilgallen
1999-05-11  0:00 ` Jean-Pierre Rosen
1999-05-11  0:00   ` Robert Dewar
replies disabled

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox