Xref: utzoo comp.lang.fortran:4109 comp.lang.c:34138 Path: utzoo!censor!geac!torsqnt!news-server.csri.toronto.edu!clyde.concordia.ca!ccu.umanitoba.ca!salomon From: salomon@ccu.umanitoba.ca (Dan Salomon) Newsgroups: comp.lang.fortran,comp.lang.c Subject: Re: Fortran vs. C for numerical work Message-ID: <1990Nov22.051446.1871@ccu.umanitoba.ca> Date: 22 Nov 90 05:14:46 GMT References: Organization: University of Manitoba, Winnipeg, Canada Lines: 49 In article bglenden@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@ccu.UManitoba.CA Dept. of Computer Science / University of Manitoba Winnipeg, Manitoba, Canada R3T 2N2 / (204) 275-6682