Orphaned Response

faustus at ucbcad.UUCP faustus at ucbcad.UUCP
Sat Jul 13 07:05:00 AEST 1985


> Let's say I am a person whose programming experience consisted a few
> high school and college courses in Basic & Pascal.  Ok, now let's say I
> have a problem that I want solved by a programmer.  The programmer comes
> back to me with a program which doesn't do quite what I wanted.  Now
> from the comments it looks like the program should work right.  The
> problem is in the code.  Now the programmer goes off and tries to fix
> it, thinking he knows exactly what I want.  But when he comes back with
> the revised program, it still doesn't do what I wanted.  Now the
> comments were not enough to understand why the program doesn't do what I
> wanted.  Therefore I must look at the code ("Foul", I hear you say.
> "What are you doing looking at his code; you're not an experienced C
> programmer!"  Well who else can look at it, if the programmer can't fix
> it himself?  At least I know what I want done).  The program turns out
> to be a full of these strange little idioms, which I've never seen
> before.  Luckily, some of the code is readable, so I hope that what is
> wrong is in that.  Let's say the problem with the program is that a
> variable is being incremented when it shouldn't be.  However I don't
> know that the variable is being incremented because I see this cryptic
> "stuff++" which I pretty much ignore because the code is full of things
> like that which gets lost in the shuffle.  I'm lost, the programmer
> doesn't know what's wrong, and we're stuck.
> 
> However if the program said "stuff = stuff + 1" or even
> "increment(stuff)", I could say "Aha! I think I know why it's not
> working. That variable 'stuff', why is it being incremented.  I don't
> think it should be incremented".  The programmer removes that line, the
> program is fixed, and we all live happily ever after.
> 
> I know this was a rather long story, but I had to get my point across
> somehow.  Remember that the "I" in that story could be someone you will
> be working for.

You should either: (1) Hire programmers who do the right thing, or (2)
Learn C. If there are nice features in a language like "i++", it is
silly to expect programmers not to use them because non-programmers
won't understand them. If you don't understand "i++", you sure won't
understand "p->foo". Besides, many people have pointed out that you
sometimes have to be a bit obscure to get efficient code -- if you write

	while (p->duck)
		p++;

instead of

	while (p++->duck)
		;

you are likely not to get the loop compiled with auto-increment instructions...

Anyway, you should admit that you are fighting a losing battle -- C
programmers write programs that should be understood by and only by other
C programmers, and if you don't know C you have no business trying to
understand it.

	Wayne



More information about the Comp.lang.c mailing list