Xref: utzoo comp.object:3297 comp.lang.misc:7575 Path: utzoo!utgpu!news-server.csri.toronto.edu!rpi!zaphod.mps.ohio-state.edu!swrinde!cs.utexas.edu!uunet!igor!rutabaga!jls From: jls@rutabaga.Rational.COM (Jim Showalter) Newsgroups: comp.object,comp.lang.misc Subject: Re: Readability of Ada Message-ID: Date: 23 Apr 91 01:38:37 GMT References: <3878@ssc-bee.ssc-vax.UUCP> <20245@alice.att.com> Sender: news@Rational.COM Followup-To: comp.object Lines: 56 %I think that it is interesting to note that the example used in this %debate about the readability of Ada/C/C++ is in the domain where the %solutions are essentially equivalent. Do you honestly regard the C solutions as being as readable as the Ada solution? >I think that there is a significant issue in the readability of code >where a language supports or fail to support a programming paradigm. You mean like multi-thread execution not being supported by C++? ;-) %So, how about comparing the languages on the example originally used %to introduce the technique we now commonly refer to as object-oriented %programming in the Simula textbook SIMULA BEGIN? The problem is to %write a little program that define a set of shapes and manipulates %them (I'll rotate a list of shapes). Then we add another shape and %see what effort that takes and whether the original code manipulates %shapes still works. There are other `tests' for object orientation %(both harder and easier on the expressiveness of programming languages), %but this one has the property of demonstrating a realistic problem %of program organization in a small problem and has been around for %about 20 years. I've been wanting to ask someone who purports to know the answer this question for over a year. Consider the shapes example. Suppose that the given example goes out in binary form, and arrives at my site, and I want to add a new shape. Suppose that the initial shapes were limited to triangles and squares. Suppose that I now add a Circle, which has a new method defined for it that does NOT apply to triangles or squares and which was never previously defined in the base class for shapes--radius. This method returns the radius as some floating point number from 0 to whatever. Now, I want to take a heterogeneous list of shapes, including triangles, circles, and squares, and I want to iterate over the list and print out all of the radii. How do I do this? I can't get elements out of the list and call the Radius method on all of them, because not all of them HAVE such a method defined. I can't add the new method to the base class (with a null implementation as the default for those shapes for which it is a meaningless operation) because the base class is in binary. I can't ask the shapes to tell me their Kind because there is no such operation defined on them in C++. It is my claim that solving this problem in C++ results in a solution that is every bit as messy as simply using a discriminated record and an enumeration type in Ada--and Ada doesn't HAVE inheritance. -- * The opinions expressed herein are my own, except in the realm of software * * engineering, in which case I borrowed them from incredibly smart people. * * * * Rational: cutting-edge software engineering technology and services. *