Fortran vs. C for numerical work
Dan Salomon
salomon at ccu.umanitoba.ca
Thu Nov 22 16:14:46 AEST 1990
In article <BGLENDEN.90Nov21003342 at mandrill.cv.nrao.edu> bglenden at mandrill.cv.nrao.edu (Brian Glendenning) writes:
>
>It is often stated that Fortran is better than C for numerical work. I
>am interested in compiling both the standard list of such arguments
>and what any counterarguments might be.
Here are the reasons that FORTRAN has not been replaced by C:
1) C is definitely for wizards, not beginners or casual programmers.
Usually people who are heavily into numerical work are not hacker
types. They are mathematicians, scientists, or engineers. They
want to do calculations, not tricky pointer manipulations.
FORTRAN's constructs are more obvious to use, while even simple
programs in C tend to be filled with tricks. Even the fundamental
operation of reading input is tricky in C, as shown by the recent
postings on scanf, gets, and fgets.
2) FORTRAN is dangerous to use, but not as dangerous as C. For
instance, most FORTRAN compilers have subscript checking as an
option, while I have never encountered a C compiler with this
feature. The ANSI standard for function prototypes will
give C an edge over FORTRAN in parameter mismatch errors, but
that improvement is relatively recent and not enforced yet.
3) There is a large body of well tested mathematical packages available
for FORTRAN, that are not yet available in C. For example the
IMSL package. However, this situation is improving for C.
4) FORTRAN still gives the option of using single precision floating
calculations for speed and space optimizations, whereas C forces
some calculations into double precision.
5) Optimizers are a non issue, since FORTRAN optimizers can match
C optimizers on numerical expressions.
The reasons that C should replace FORTRAN for numerical work:
1) C allows recursive functions, whereas portable FORTRAN doesn't.
Recursive functions can often solve a problem more clearly
than iterative methods, even if they are usually less efficient.
2) FORTRAN has no dynamic array allocation. Although C has dynamically
allocated arrays, they are not trivial to describe or allocate.
--
Dan Salomon -- salomon at ccu.UManitoba.CA
Dept. of Computer Science / University of Manitoba
Winnipeg, Manitoba, Canada R3T 2N2 / (204) 275-6682
More information about the Comp.lang.c
mailing list