more about programming style

M.J.Shannon mjs at eagle.UUCP
Fri Jul 12 13:01:56 AEST 1985


> In most cases, I think new programmers
> have some obligation to use those idioms.  Why? Because (contrary to your
> example) in most cases someone reading your code is more likely than
> not to be well versed in the language, and will be more confused by code which
> doesn't use the established idioms.  Witness the letters already submitted
> in which people say strongly they find i++ more intuitive than i = i + 1.
> 
> Craig Partridge

Sorry, but I don't buy this.  As a long term user of various UNIX Systems, I
have used many of the `language' tools once, or perhaps as many as a dozen
times.  Mostly I use the C compiler, occasionally assisted by yacc and lex, but
every once in a while a tool such as awk is more appropriate.  Now, I am aware
that some folks whose code I have access to, and have done extensive work in
awk, have rather large sets of idioms (idia?), but how much time should I spend
examining their code to ascertain the semantics of their idioms?  What I have
always done in the past (and, I dare say, shall continue to do) is write the
application in such a way that someone fluent in the language in question can
easily comprehend both the algorithm and the implementation of it.  I will be
the first to agree that "++i" is more readable (to experienced C programmers)
than "i = i + 1", but if I were mostly a fortrash programmer writing some C
interface programs to f77 (for example), I'd probably use the latter
expression, because it more closely resembles the syntax and semantics of the
language with which I am most familiar (hypothetically).

One way of stating my opinion on this (admittedly religious) matter is:

	Sometimes it pays to be eloquent.  It always pays to be clear,
	precise, and accurate.  When I can achieve eloquence at little
	cost while maintaining clarity, precision, and accuracy, I will
	do so -- but only then.

Can anyone claim that this is an unreasonable stance?  If so, please do so
via private mail; there is no need to further clutter this discussion with
religious debates.
-- 
	Marty Shannon
UUCP:	ihnp4!eagle!mjs
Phone:	+1 201 522 6063



More information about the Comp.lang.c mailing list