Path: utzoo!attcan!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!usc!snorkelwacker!bloom-beacon!eru!hagbard!sunic!mcsun!tuvie!vexpert.dbai.tuwien.ac.at!mst From: mst@vexpert.dbai.tuwien.ac.at (Markus Stumptner) Newsgroups: comp.society.futures Subject: Re: C's sins of commission (was: (pssst...fortran?)) Message-ID: <3643@vexpert.dbai.tuwien.ac.at> Date: 17 Sep 90 08:21:00 GMT References: <1990Sep14.160429.2732@abcfd20.larc.nasa.gov> Organization: DB and ES Subdivision, TU Vienna Lines: 46 From article <1990Sep14.160429.2732@abcfd20.larc.nasa.gov>, by jcburt@ipsun.larc.nasa.gov (John Burton): >>This leads us to pointers. Just about everything about C pointers is >>bad. From the fact that pointers are hopelessly confused with arrays >>(which are completely separate conceptually) to the syntax of pointer >>use, C's pointers are a mess. >>Since this is comp.society.futures, I will discuss pointer replacements. >>Essentially, pointers only do three things for you: 1) recursive data >>structures (graphs, trees, etc....); 2) dynamic memory; and 3) run-time >>'equivalence'. C pointer arithmetic only does what one dimensional array >>indexing already does (scaled address calculations): arrays are better for >>this - so it's _not_ counted as one of the features of pointers. > > Sorry, but it IS more expensive (execution time wise) to sequentially > index through an array, than it is to simply increment a pointer... > Array indexing is better for randomlly accessing the array... > just because random access is better for somethings, should we > totally do away with sequential access? come on, be fair... I have a friend who works for CDC. The current series of graphics workstations sold by CDC (to my knowledge, very similar to Silicon Graphics machines) are based on the MIPS RISC chip family and use heavily optimizing compilers. One day, while leafing through a C compiler manual for the system (I don't know what manual it was exactly, have never seen it), he discovered to his amazement that the programming guidelines include the following rules: - Do not use the increment and decrement operators (++ and --) - Do not use pointer incrementing for sequential array access This was a year ago, and my memory is fuzzy. As far as I remember, according to the manual, in most cases using ordinary assignment/expression syntax and incrementing an array index will be MUCH FASTER since the compiler has more freedom in keeping values in registers instead of having to store them back in memory immediately. I confess I have been very amused by this. Can anyone support it? The MIPS architecture is used by DEC and lots of other manufacturers. Perhaps somebody else has stumbled on this. What about other RISC architectures? Perhaps there is still hope for high-level languages... Markus Stumptner mst@vexpert.at Technical University of Vienna vexpert!mst@uunet.uu.net Paniglg. 16, A-1040 Vienna, Austria ...mcsun!vexpert!mst