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.1 required=5.0 tests=BAYES_00,INVALID_MSGID, TO_NO_BRKTS_PCNT 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: Tim Behrendsen Subject: Re: C is 'better' than Ada because... Date: 1996/08/01 Message-ID: #1/1 X-Deja-AN: 171430802 organization: InterNex Information Services 1-800-595-3333 content-type: TEXT/PLAIN; charset=US-ASCII mime-version: 1.0 newsgroups: comp.lang.c,comp.lang.ada Date: 1996-08-01T00:00:00+00:00 List-Id: On Thu, 1 Aug 1996, Byron B. Kauffman wrote: > Tim Behrendsen wrote: > > > snip... > > > > You are probably right, if you let the optimizer handle everything. > > But C also gives the capability to do things such as ... > > > > if ((array[++n] = GetValue(arg)) != 0) { > > .... > > > > v.s. a typical non-C language ... > > > > n = n + 1; > > array[n] = GetValue(arg); > > if (array[n] != 0) { > > ... > > } > > > > Now, which is easier to optimize? (more snip) > > > > Tim, I'm 180 degrees out of phase from you, experience-wise. I've > professionally done around 10klocs of Ada, and about 24 or so lines of > C, although I sucked it up and took C++ from a local junior college last > fall just so I can say that I did. > > With all that in mind, I'm going to ask (in reference to the code > samples above), which is easier to read and/or maintain? The answer, > from my C-ignorant perspective, is the non-C example, but a C compiler > obviously wouldn't have a problem with it. Unfortunately, though, the > compiler is not the one that maintains or ports the code to another > platform. IMHO, this is where Ada has the edge over C - it was designed > primarily with the -ilities in mind. I don't know if it is the industry > norm, but my primary job description for years was 80% code maintenance > and rehosting, 20% new code. It is my perception that that is what was > eating DoD's lunch and why they commissioned Ada. My statement above is a very common C expression; if you used it every day, you would think nothing of it. In fact, I could make a strong argument that the first example is much more readable/maintainable, because it's brief and concise. Too much of the latter, of course, begins to be a bad thing (take APL, for example). I certainly don't mean to imply that maintainability isn't important; in fact, I think it's the *most* important. If there are significant gains to be made in that department, then I think Ada has a chance to succeed out of its nitch. Having personally written in the neighborhood of 200-300 klocs of C code (guess? could be more), I think I have a pretty good sense of how things gets optimized. My main point, which I think is getting lost in the swirl of examples, is that in the real world, optimizers aren't that smart. Yes, you can find the "super optimizer" that does a good job when run in "-cape" mode, but in the everyday trenches, I just don't come across them very often. There just is no substitute for writing code with an eye toward what the compiler can and will do with it. Regards, -- Tim Behrendsen (tim@airshields.com)