[comp.os.vms] Why blast poor VAX C?

RMANGALD@CLARKU.BITNET (07/16/87)

        In response to a query by John Yates (yates@a.chem.upenn.edu),
who is having problems with G-floating numbers in VAX C, listmember Erik
Naggum (ik.naggum-erik@siri.uio.no) writes:

>I regard myself as an expert in C and UNIX.  I have read the ANSI
>Standard Draft of 10/10/86, and Kernighan and Richie's "The C
>Programming Language".  With 3 years of experience in C programming, and
>200K source lines on my conscience, I have some comments to your
>article, blaming C for various flaws in floating point operations on a
>VAX (model X?), using VAX C version 2.2 under VMS.
>
>I took the time to go through a lot of documentation tonight, and
>visited those for (AT&T) UNIX Version 7, System III and System V,
>for SVID, for BSD release 4.3 and Ultrix 2.0, for XENIX 3 and XENIX 5,
>and finally those of SUN OS.  (Insert list of trademark owners here.)
>
>Nowhere can I find a reference to G-floating or, in fact, any other
>specific implementation of floating point numbers, as part of the C
>language.  Rather, I have found that each machine and each implementor
>decides which formats to use, and that they are more an attribute of the
>hardware than of the language definition.
>
>Why not put away your VAX VMS or your VAX C, instead?

        With due respect, Mr. Naggum, I believe you are blaming the
computer for the errors of the programmer.  Considering your proficiency
in the language, you must have undoubtedly caught the <scanf("%f", x1)>
and the <prinf("...%e", ...)>: Mr. Yates was trying to read in and print
out a <double> variable using <float> conversions.  Surely you cannot
fault the compiler or the operating system for this?  You have to agree
that such mismatched conversions will give wrong results regardless of
the C implementation, so long as the internal representation of <float>
and <double> are different.

        Mr. Yates got a bit carried away in bombasting C, perhaps
because (I suspect) he is not a programmer, and as non-programmers are
wont to do, let of his frustration on the language.  But Mr. Naggum, you
are a professional programmer, and surely understand the difficulties
faced by non-programmers, especially those who are grappling with an
unfamiliar language.  Bombasting VMS and VAX C is not going to solve any
problems, and programming language/operating system fanaticism isn't
going to get us anywhere.

        Let's generate more light, not heat.

                                Sincerely,

                                Rahul Mangaldas.

ik.naggum-erik@siri.UIO.NO (07/23/87)

Rahul Mangaldas (rmangald@clarku.bitnet) criticizes my criticism of John
Yates' (yates@a.chem.upenn.edu) criticism of C in the case of the C
language vs the g-floating point format.

It never occured to me that John could be suspected of not being a
programmer, but this note may be worthy of bandwidth: In C, a parameter
declared as <float> is automagically converted to <double>.  Then we
have scanf, which is a quite different issue from G-floating formats.
Scanf uses pointers to store things, and calamities may arise if you
store a <double> value into a <float> slot.  Add to this the fact that
g-floating <double>s and <float>s do not carry the same relationship as
"normal" <double>s and <float>s.  (K&R assumes that <double> is just a
longer mantissa.  John's code (sans the mth$cvt_d_g) works on a Ultrix
2.0 machine, in default floating format.)  This was his error in
programming.

Then the issue of G-floating, and whether this is a fault of the C
language, which was part of what I got out of John's article.  He
assumed that since things worked with Fortran on a VAX, it would work
equally well with C.  (This assumption is correct.)  Being sloppy in C
is dangerous, and all his comments pertain to this aspect of C
programming, not to the language.  This was his error in argument.

Together the errors are graver than if he had just cried for help.  We
all make errors now and then.  (Even I :-).)  Learning from them is what
makes this life so beautiful.

You are right in that language/OS fanaticism isn't going to get us
anywhere.  It would perhaps have been better to ask John to pick up K&R
instead of putting it away, than to reverse the flaming on VAX and VMS.

I hope this did shed some light.  On my reaction, if on nothing else.

Erik Naggum		ARPA:  enag@siri.uio.no or enag%siri@ifi.uio.no
Manager			SNAIL: POB 1560 Vika, N-0118 OSLO 1, NORWAY
Naggum Software		PHONE: (intl)+47-2-549-163  (0600-1200 GMT)
-------