From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on polar.synack.me X-Spam-Level: X-Spam-Status: No, score=-1.3 required=5.0 tests=BAYES_00,INVALID_MSGID autolearn=no autolearn_force=no version=3.4.4 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 1014db,dab7d920e4340f12 X-Google-Attributes: gid1014db,public X-Google-Thread: 103376,dab7d920e4340f12 X-Google-Attributes: gid103376,public From: kurtz@mustang.nrl.navy.mil (Bob Kurtz) Subject: Re: Ada is 'better' than C because... Date: 1996/08/12 Message-ID: #1/1 X-Deja-AN: 174540171 references: <01bb7bf9$b89a1740$96ee6fcf@timhome2> <4un7j3$m9g@ursa.smsu.edu> organization: Hughes STX @ US Naval Research Lab, Wash. DC newsgroups: comp.lang.ada,comp.lang.c Date: 1996-08-12T00:00:00+00:00 List-Id: In article <4un7j3$m9g@ursa.smsu.edu>, aho450s@nic.smsu.edu (OBryan Anthony H) wrote: > William Clodius (clodius@hotspec.lanl.gov) wrote: > > : Not quite. First when passed as an argument to a user defined function > : a C array looses a lot of its distinction from a pointer, a problem > : that many other languages do not have. Second, while (almost?) all > > I have a hard time seeing this as a problem. It's one of the fantastic > advantages of the C language. An array of any given type can be passed > to a user function and treated as an array of any other integral type, > converted, processed, etc. in any manner the programmer desires. This is one of the best features of C. This is one of the worst features of C. You are free to handle that passed address in any way you choose, without substantial limitation by the language, and regardless of whether it is sensible or whether you really meant to do it that way. What seems powerful when developing small programs becomes deadly when developing large systems with many programmers. > : additional capabilities that C arrays lack, the ability to specify > : array shape in arguments (Fortran I), and various forms of whole array > : operations, APL, PL/I, Algol 68, and Fortran 90. > > What do you mean by array shape? C is fully capable of performing whole > array operations. The capability is not embedded in the language, as C > is designed to provide only the bare necessicities for program > development with all else being provided in function extensions, but the > language itself allows for anything a machine is capable of doing. Using this argument to suggest that C provides whole-array operations is like saying C provides for computer vision, because the machine is capable and somebody once wrote a program ("function extensions") that did this. In fact, there is a big difference between language-supported operations and those "extensions" that you make by yourself. For one, language operations are (we sincerely hope) extremely robust and unlikely to fail. It takes serious measures (like good design, thorough unit and integration testing, and preferably a history of use) to be able to make that contention about a user-written library module. I presume that "array shape" is the ability of a module to determine the dimensions of an array passed as an argument. Ada supports this (to my great delight when I first learned about it), C does not. That's not to say you can't pass dimensions to the module as well, or bundle the dimensions and the pointer to the array into a passed structure (yuck), but it is not inherently supported by the language, and thus invites nonstandard (even within the same project) ways of dealing with the problem. This, in turn, invites errors, particularly subtle ones. So is Ada "better" than C? Depends. Is it "safer" than C? Sure thing. -Bob -- Bob Kurtz (kurtz@mustang.nrl.navy.mil) Hughes STX Corp., US Naval Research Lab, Washington DC