Path: utzoo!attcan!uunet!aplcen!uakari.primate.wisc.edu!zaphod.mps.ohio-state.edu!uwm.edu!psuvax1!rutgers!cmcl2!lanl!jlg From: jlg@lanl.gov (Jim Giles) Newsgroups: comp.society.futures Subject: Re: C's sins of commission (was: (pssst...fortran?)) Message-ID: <63201@lanl.gov> Date: 17 Sep 90 21:57:05 GMT References: <1990Sep14.160429.2732@abcfd20.larc.nasa.gov> Organization: Los Alamos Natl Lab, Los Alamos, N.M. Lines: 67 From article <1990Sep14.160429.2732@abcfd20.larc.nasa.gov>, by jcburt@ipsun.larc.nasa.gov (John Burton): > [...] > BTW: since the early 70's it has also been shown that the total LACK > of GOTO's is also bad. Selective use of GOTO is the key. Yes, I believe I mentioned that in the article to which you are responding. Although, I have not been able to find any evidence that GOTO-less is actually _bad_, there were several experiments that showed that disciplined use of GOTOs was not worse (or better) than "Structured" coding in any statistically significant way. The conclusion of most researchers was that all the "Structured" alternatives to GOTO should be provided in a language - and GOTO should also be provided just in case. > [...] > Sorry, but it IS more expensive (execution time wise) to sequentially > index through an array, than it is to simply increment a pointer... Sorry, but it is not. The compiler technology to tell that array indexing is semantically _identical_ to the pointer incrementing scheme to which you are referring is about 30 years old: if your compiler is _that_ far behind the state-of-the-art, you got rooked. (The optimization is called "constant folding". The address of the array is added to the initial value of the array index variable at _compile_ time - the interior of the loop (or wherever) uses this combined value as your C program would use a pointer - including the simple increment as th loop progresses.) > [...] >>Recursive data structures are best implemented directly [...] > [...] > Not using pointers would make life easier for a novice programmer. It would > severly limit the experienced programmer... The method I gave is semantically _identical_ to using pointers. The only difference is the lack of the need for dereferencing. There is no functionality that C can perform that the features I gave cannot also perform. There is no reason (at the present state-of-the-art) for the compiler to generate less efficient code than using explicit pointers would use. There is (at the present state-of-the-art) excellent reason to expect that the features I propose could be _MORE_ efficiently implemented since the presence (or absence) of aliasing is easier to detect. > [...] > C was designed to accomplish tasks quickly. The often made comparison > of indexing through a 1-dimensional array (linear representation of > a multidimensional array) instead of incrementing pointers is not strictly > valid. For every array access, there is a corresponding index calculation > (usually a multiplication and an addition) to determine where to look for > the data. Incrementing a pointer is faster (generally a register increment > operation). [...] As I pointed out, the modern (more recent than the late 50's) compiler can eliminate the addition you refer to. The multiplication is only needed for multidimensional arrays - which C doesn't, strictly speaking, even have. The multiply should also be eliminated by a modern (more recent than the early 60's) compiler - the technique is called "strength reduction". If your compiler doesn't have it, you been rooked again. > [...] > When asked the question, "what is the *best* programming language?" the > answer should be "it depends on what you want to do..." The first correct thing you've said. However, you have not made a convincing argument that the answer should _ever_ be C - no matter what the application is. J. Giles