Re: mu TECH: an unhurried digression on C pointers vs. arrays

From: Alfie Costa (agcosta@gis.net)
Date: Sat Apr 29 2000 - 00:19:54 CEST


On 28 Apr 2000, at 17:58, Miguel Angel <mulinux@sunsite.auc.dk> wrote:

> I think that worrying of speeding code written in C (or any other high
> level language) changing such things like arrays for pointers, i=i+1 for
> i++, ... is completely senseless.

The main point of my previous tale of woe, especially the Allen Holub quote,
was that such misconceptions can have quite respectable origins. Holub's 'C
Companion' isn't the sort of 3rd-hand popularization one would expect this kind
of controversial opinion from -- my naive first impression was because the book
was from Prentice Hall, and Prentice Hall publishes K&R, Earth's most respected
C book, and Kernighan himself was also an advisor, (which does not guarantee
that Kernighan ever read a line of Holub's book, or that either was
infallible), and superficially, the book is even the same size and shape, and
on the same grade of paper, as K&R... so it looked authoritative. True, the
book is 13 years old, but K&R is older than that and is still recommended; so
there was the valid (if unsound) logic that led this way.

No argument here that some speedups are not worth it in the long run. I
remember about 10-15 years back optimizing my interpreter BASIC code by running
it through a spaghetti-code optimizer like 'BasicAid'. 'BasicAid' could take a
nice readable program like:

 10 i=0
 20 print "Hola Miguel ";i
 30 let i=i+1
 40 goto 20

And turn it into:

 1i=0
 2?"Hola Miguel ";i:i=i+1:goto2

Such an optimizer might even replace the 'goto' with some sort of
1-character extended ASCII token. And so for people too poor to afford a
compiler, these spaghetti programs would run a little faster. 'BasicAid' would
also shrink variable names, and expand or re-number and re-indent ugly BASIC
code. An interesting and unlamented program...

Anyways, thanks to you and Htom both for taking the time to set me straight. It
would be unfortunate though, given the very critical usenet posts I'd archived
in the file attachment, and the general tenor of the first message, if it was
somehow unclear that this thread was NOT intended as a defense of pointer
usage.

---------------------------------------------------------------------
To unsubscribe, e-mail: mulinux-unsubscribe@sunsite.auc.dk
For additional commands, e-mail: mulinux-help@sunsite.auc.dk



This archive was generated by hypermail 2.1.6 : Sat Feb 08 2003 - 15:27:14 CET