Re: 3 Questions

From: Peter Ajamian (
Date: 01/31/01

"Daniel A. Koepke" wrote:
> On Mon, 29 Jan 2001, Peter Ajamian wrote:
> in this case, you
> are tossing a standard by the way-side [C99].

Absolutely not, since any program that conforms to the old ANSI standard
will also conform to the newer C99 standard how can I possibly be
advocating non-conformance to C99 by advocating conformance to the older
ANSI?  My point is that by conforming your program to the older standard
it will, by default, conform to _both_ standards.

> > We are dealing with now, not eventually.
> And code is finished and released eventually, not now.  And is supported
> over time, not at the one instant 'now'.  And used by people eventually,
> not at the one instant 'now'.  And so forth.

Okay, so we're dealing with both now AND eventually.  The fact is that
if you have code that needs to be used now (or in the very near future)
then you need to conform to the standards in place now.

> > I know of people who have gone through the trouble of compiling and
> > running CircleMUD on ancient Unix platforms that only have an old
> > version of cc.
> If that's their kick, then they're free to have it.

It's not a matter of it being "thier kick", some people have little
choice in the matter.

> The code should not
> bend to support traditional C, even though it might be "more portable."

If you're talking about saving 4 or 5 lines of code, or other
improvements on a similar level of significance then I can see your
point, but we're talking about such minor issues as declaring variables
at the beginning of a function instead of in the body with only minor
loss of readability and almost negligible loss of performance, the style
of comments used, etc.  Some of these things don't improve on anything
except to support what was previously bad coding habits.

> > However (correct me if I'm wrong) it is my understanding that any
> > program that adheres fully to the older ANSI standard will also adhere
> > fully to the newer C99 standard, though the opposite ceartainly is not
> > true.
> The opposite _can_ be true.

By "the opposite" I mean that any program which conforms to C99 will
also conform to ANSI which most ceartainly is _not_ true.  Case in point
is a program that declares variables mid-function.  It conforms to C99
but not to ANSI.  Note, however, that a program which declares all
variables at the beginning of a function conforms to both ANSI and C99.

> Standards have little to do with portability

Standards have _everything_ to do with portability.  They are created
with the expressed intent of allowing for portability.  If not for the
sake of portability then there would be abolutely no need to have
standards at all.

> because most platforms don't strictly conform to every standard.  And it's
> trivial to use features of C99 and disable them/emulate them using the
> preprocessor.  The trade-off is readability.

Readability which is in the eye of the beholder.  I find that I can
write comments which are just as readable using the /* ... */ style as
with the // style, to me it's a non-issue as I can see no gains
whatsoever by using the // style comments.  Declaring variables in the
middle of functions has a relatively small advantage and I can see
myself doing that in a year or two when C99 has gained much wider
support, but not before then.

> > When it comes to advising newbie coders I would always advise them in
> > the direction of keeping thier code portable.
> If they're following a standard that is coming into increasing use and
> want to take advantage of it, then they ought to.

If there is a significant advantage to be had.  I still haven't seen

> And if at some time in
> the future they need to port to a platform without a C99-conforming
> compiler, they can deal with it then and make up their own mind about the
> gains and costs of the bleeding edge.

If there's any possibility of having to port to a platform without a C99
compiler then I would find it much preferable to keep my code conforming
to the older ANSI standard now than to have to drudge through the code
later and fix all the non-compliant parts.

> > While I can see lots of reasons to avoid breaking a standard, why on
> > earth would anyone want to avoid adhering to one?
> For many reasons, one of which you are presently arguing since, after all,
> C99 is a standard and you are advocating that people avoid adhering to it.

Absolutely not.  I am simply advocating that people should attempt to
adhere to the older ANSI standard where feasable instead of jumping into
the new standard with trivial things which would break compliance with
the old.  However, as I pointed out above, since conformance to ANSI
automatically makes your program conform to C99 then by advocating
conformance to ANSI I am also advocating conformance to C99.  A program
does not have to use all the features of a standard in order to conform
to it.

> Portability and standards are not one and the same.

I never said they were, however, standards are made to allow for

Regards, Peter

   | FAQ: |
   | Archives: |

This archive was generated by hypermail 2b30 : 12/03/01 PST