🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: comp.lang.misc
Article #2452

Fortran vs. C for numerical work - expression notation

#2452
From: Jim Giles
Date: Sun, 09 Dec 1990 01:16
86 lines
5041 bytes
From article <16798@csli.Stanford.EDU>, by poser@csli.Stanford.EDU (Bill Poser):
> [... I said notation should resemble standard math closely ...]
>
> Jim, if you'll read the past 20 messages or so you'll see that this
> is precisely one of the things we've been discussing.  [...]

It is interesting that you should choose to complain about my posting
and not about Peter Grandi's.  He said (or, at least, implied) that
programming notation should not closely resemble standard math because
such a thing was misleading to novice programmers.  I hope you agree
that such a position is indefensible.

Instead, you chose to come religiously to the defense of C when I made
a final comment that Fortran was a noticible improvement on C with
respect to mathematical notation.  Ok, I'll follow your argument to
see if there's a grain of validity to it.

> [...]                                                 I have
> already asserted that neither C nor Fortran provides much direct
> math support, that to the extent that they do the notation is very
> close to mathematical notation, and that the only real difference
> that I can see is that in Fortran power is an infix operator
> as is typical in mathematics whereas in C it is a function and
> therefore prefixed. This is an awfully small difference, isn't it?

Well, there's a lot of different meanings to the phrase "awfully small
difference".  To a computing science professional, the difference is
indeed trivial.  To some branches of abstract methematics, functional
notation is actually more natural.  But to most scientists, engineers,
and applied mathematicians, the difference is rather more significant.
Most of these people can read standard mathematical notation as fast
as you or I read English prose (and probably with more comprehension).
Any difference from such standard notation is an impediment - period.

Now, you correctly point out that neither Fortran nor C have a
complete set of usual mathematical notation.  To some extent, this
is a constraint of the character set, and to some extent it is a
limitation of computing.  After all, it is not really meaningful to
make the integral sign an operator in your language unless
integration is a built-in feature of the language - when, in fact,
approximating an integral is often the purpose of the program
itself.  We can only hope that as character sets get larger (my
workstation has dozens of fonts and hundreds of characters) and as
higher-level languages become available, the computational notation
available to scientists will converge with their own standardized
professional notations.

You also correctly point out that some of Fortran's (more or less)
standard operators (exponentiation, normal arithmetic on Complex,
etc.) require prefix (function call) notation in C.  This is an
impediment.  You may choose to call it trivial, but it is still an
impediment.

You fail to point out that both languages (but C more than Fortran)
use standard mathematical symbols for non-standard purposes.  The
equal sign in both languages is used for assignment, for example.
Again, this is an impediment.  Again, C suffers from it worse than
Fortran.

You fail to mention that both languages use non-standard symbols for
standard mathematical concepts.  Fortran uses '.and.' for conjunction,
while C uses '&', for example (the standard symbol for conjunction is,
of course, '/\').  I think that C is still worse than Fortran here.
To be sure, C uses '<' and '>' for comparison operators, but then
commits the error of the last paragraph by using these same symbols as
part of the shift operators.

These last two points (and the fact that C uses the whole ASCII
character set in peculiar ways) tend to make many C programs look
like communications line noise - at least to most non-users of C.
This can't be held in C's favor in a discussion about closeness
to standard forms of notation.

Now, the final point that most of the people in this discussion (on
_both_ sides) seem to miss is this: _any_ change or impediment is
unjustifiable unless it confers some _advantage_.  Further, the
advantage conferred must be of greater value that the cost of the
change.  No matter how trivial you consider the changes from Fortran
to C notation, there is no intrinsic advantage to such a change.
Using prefix instead of infix doesn't make you a better mathematician.
It doesn't make your code run faster (indeed the reverse may be true
if the infix operator was built-in and "inlined" and the prefix
notation actually does a function call).

J. Giles
.
Technical Details
Message-ID: <8339@lanl.gov>
Path: arc1-ca.pugleaf.net!utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!wuarchive!udel!haven!adm!cmcl2!lanl!jlg
References: <16798@csli.Stanford.EDU>

Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!wuarchive!udel!haven!adm!cmcl2!lanl!jlg
From: jlg@lanl.gov (Jim Giles)
Newsgroups: comp.lang.misc
Subject: Fortran vs. C for numerical work - expression notation
Message-ID: <8339@lanl.gov>
Date: 9 Dec 90 01:16:29 GMT
References: <16798@csli.Stanford.EDU>
Organization: Los Alamos Natl Lab, Los Alamos, N.M.
Lines: 86