Efficient coding considered harmful?

David Harvey dharvey at wsccs.UUCP
Wed Nov 9 18:56:26 AEST 1988


The recent postings on the net on this topic has prompted me to respond
about a teacher at our college (not necessarily reflecting the opinion
of all faculty members) who would fail me for the following code:

if( ! something) {
	++j;
	.
	.
	.
}

but would pass me with flying colors for the following:

if ( something != 0)
	{
		j = j + 1;
		.
		.
		.
	}

As a matter of fact, he would under no circumstances allow me to
use the '++', '--', '+=', '-=', '/=', '*=', or '%=' operators.
I would LITERALLY be failed if it were there.  And yes, he feels
that Pascal is much better than C, and Modula2 better yet.  In
other words, C does have philosophy of coding that emanates a
flavor of efficiency.  Use it or lose it.  By the way, another
teacher here loves ANSI C, and every 'enhancement' he mentions
smacks me of being Pascalish in orientation.  For example, the
declaration of variables within the function parentheses will
provide the 'protection' that Pascal lovers want only if the
compiler can compile both the caller and callee at the same time.
Or the linker must be more sophisticated, using information that
is generated by the compiler.  How will it be handled folks?
Either way we lose.  If the compiler does it, there goes our
modular strategy of putting related functions in seperate files
from the functions that use them.  But then we could always
#include C code files, which is exactly what one of the afore-
mentioned teachers required of beginning C students!  But what
if I want to package a set of functions for users of equipment
I manufacture to connect to the computer and I don't want them
to have the source?  Then the linker will have to do it.  Will
that cost more for the compiler and linker?  You bet your boots
it will!  My point of view?  If you want to program in Pascal,
Modula2, Ada, et al, by all means do so.  But don't cram your
views that make a machine run slower down my throat!  If I want
to do that I will use Lisp or Prolog where I get something back
for what I lost!

dharvey at wsccs



More information about the Comp.lang.c mailing list