Use of expression values in C

Eugene D. Brooks III brooks at lll-crg.ARPA
Mon Jul 8 05:02:40 AEST 1985


> It is entirely possible to understand the semantics of the code fully and
> still consider it unnecessarily obscure and hard to read.  The mark of a
> good programmer is that his code is *easy* to read, not just *possible* to
> read.  Using every obfuscatory feature of the language, perhaps in the
> (oft-mistaken) belief that it improves efficiency, and then pleading that
> "any experienced programmer should be able to understand that" is the mark
> of someone who doesn't understand what this business is about.

Not being a professinal progammer or even a computer scientist, perhaps my
opinion that

	if((fptr = fopen(filename, "r")) == NULL) {
		fprintf(stderr, "Can't open %s for reading\n", filename);
		exit(1);
	}

if perfectly clear to anyone who understands the C language and is not
obfuscatory is misinformed.  You can be assured that I will continue to
use it and I will not hire any "professional programmers" who consider
it bad programming practice.  They may have a case with the employment
office however,  refusual to hire on the basis of their religion!  Any
C programmers who can't easily understand the above example simply aren't
good enough to be working for me.  When they aren't hired, or are fired,
they will have no recourse.

I do agree with the point that using subtle features of the C language
which make even the most experienced C programmer stop and think for a while
about what is being said is a bad programming practice.  An example of such
stuff would be

	if(a = b++ * --c)
	
and I do remember a lot ot even more undesirable examples.  I therefore
agree with the point made above about writing super terse programs.
The fopen case above simply isn't one of them.



More information about the Comp.lang.c mailing list