Path: utzoo!utgpu!news-server.csri.toronto.edu!bonnie.concordia.ca!uunet!odi!dlw From: dlw@odi.com (Dan Weinreb) Newsgroups: comp.object Subject: Re: Readability of Ada Message-ID: <1991May13.054011.446@odi.com> Date: 13 May 91 05:40:11 GMT References: <1991May1.041007.14124@odi.com> <1991May9.040947.28053@netcom.COM> Reply-To: dlw@odi.com Distribution: comp Organization: Object Design, Inc. Lines: 110 In-Reply-To: jls@netcom.COM's message of 9 May 91 04:09:47 GMT In article <1991May9.040947.28053@netcom.COM> jls@netcom.COM (Jim Showalter) writes: I think the relevant question to ask is: given two pieces of code that are functionally-equivalent (they both compute Julian dates, for example), one written in C, the other written in Ada, both written for maximum readability by equally expert programmers, how much training does someone need in order to understand the C version, and how does this contrast with the amount of training required to understand the Ada version? OK, that's a good well-defined sort of question. I should point out that it depends on the program. Ada is a larger, richer, more complex language than C. If a program used all of Ada's features, you'd have more to learn to understand it. The corresonding C program would presumably require less learning, but would be more verbose, having to do things "manually" that are built-in in Ada. Ada's full abilities, including some very elaborate kinds of overloading, and generics, and so on, can take a while to learn. But for simpler programs, I think you could make a case that's pretty plausible, although not really easy to convincingly demonstrate. It's just a hard sort of thing to prove. I argue that less training is required to achieve comprehension in Ada, and that this is an inherent advantage of Ada over C. Presuming this claim is true, Ada's lower training-to-comprehension overhead translates into lowered maintenance costs, since a person doesn't have to be a rocket scientist to fiddle with the code. Maybe. I know some people who are Ada experts (people who have built parts of Ada compilers) who tell me that some of Ada's advanced constructs can be rather confusing. A change to the program in one place can make a certain statement, far away, suddenly become ambiguous, because of Ada's flexible and liberal overloading rules. I don't know Ada well enough to provide a good example (so I apologize for making this non-backed-up claim). Well, this is certainly a fair question, and I had to think about it for a while to decide what my response is. I guess the answer is that, yes, I DO believe that the keywords that indicate iteration are intuitively obvious, and that Ada syntax IS something relatively natural for humans. After all, one of the goals of the Ada language designers was to make it regular, readable, intelligible, easy to learn, etc. To the degree that they succeeded, I would expect it to feel fairly natural to human beings. Well, the way you've phrased this, it's a circular argument. "To the degree that they succeeded" is the question we're discussing. I've certainly been running on the assumption that Ada is readable. Is it not? Is it gibberish to the uninitiated? Is there an assembly language or APL programmer out there who truly doesn't know anything about Ada who would care to comment on whether the following code snippets make any sense?: No, I certainly would not say that. The question was how it compares with C. Note that Ada and C both use "for" and "while". while Batter_Remains_In_Bowl and People_Are_Still_Hungry loop Make_More_Pancakes; end loop; In C, while (Batter_Remains_In_Bowl && People_Are_Still_Hungry) Make_More_Pancakes; It's not really that different. The "and" probably is a bit more obvious to the uninitiated than "&&", but this srikes me as a small point. If the body had more than one statement, it would be grouped in braces. It's not obvious to me that someone who had never seen the convention before would realize that "end loop" is supposed to be a closing delimiter that matches "loop", although it probably would not be hard to figure out. The fact that the braces are intended to match is probably a bit more obvious. if You_Are_Sleepy then Go_To_Sleep; end if; In C, this is if (You_Are_Sleepy) { Go_To_Sleep; } I used the braces this time. I think it would be hard to say that either is much more obvious than the other. for Current_Day in Monday..Friday loop Go_To_Work; end loop; I agree that Ada handles this more clearly because it has a more explicit concept of enumerated types. That the ".." means a range, though, is not something that's obvious to people who have never seen Pascal or Ada before; I know this from seeing people learn Pascal. In this particular example, it's obvious from context, because everybody knows that when you see Monday and Friday together, it means "from Monday to Friday". If I tell you that the French words for these days are Lundi and Vendredi, I bet you can guess what "de Lundi a Vendredi" means. (I apologize if I got the Francais wrong, but you get the idea.) In another example, the ".." might be less obvious. Anyway, this has probably gotten to the point where it has very limited relevance to object-oriented programming. And I certainly don't intend to be a defender of C, which is hardly a language I have great love for. And I don't even know much about Ada. So I won't post further on this subject. Thank you for taking the trouble to restate your claim so much more clearly.