Computers and heat density

Sean Conner spc at
Sun Aug 13 22:53:58 CDT 2006

It was thus said that the Great Don once stated:
> Ethan Dicks wrote:
> >The "real" problem was that the first guy didn't really understand the
> >impact of his original construction on the underlying system, and "it
> >worked" for a few thousand names.  Didn't scale worth beans, though.
> Exactly.  Like:
> for (x=0; x<XMAX; x++)
>   for (y=0; y<YMAX; y++)
>     foo[x][y] = ...;
> vs.
> for (y=0; y<YMAX; y++)
>   for (x=0; x<XMAX; x++)
>     foo[x][y] = ...;
> They *look* the same but *aren't*.

  No, they aren't.  But I personally never remembered if C stores arrays row
major, or column major.  Then again, I rarely use two dimentional arrays

  But really, it gets to me when I see code like:

	for (i = 0 ; i < MAX ; i++)
		foo[i] = 0;

  when it could easily be replaced with:


  (which would work on multiple dimentioned arrays) or, if C allowed it:

	foo = 0;

  (to me, if the compiled sees array rvalue being set to a single lvalue,
then the intent I want as a programmer is to set the entire array to that
single value).  

> I found one piece of code that was literally counting bytes
> to determine the size of a file instead of stat(2)-ing it
> (no, it wasn't a sparse file, special device, etc. ... just
> a regular "box of bytes")

  That's just the programmer not knowing the available functions, or
perhaps, coming from a system that doesn't have stat() available (it's not
part of the ANSI-C standard library, limiting the ways one can get the size
of a file portably, and each of them having problems).  For more horror
stories, you can always check out .

  -spc (Have compiler, will program)

More information about the cctalk mailing list