Path: utzoo!utgpu!news-server.csri.toronto.edu!mailrus!ncar!dinl!noren From: noren@dinl.uucp (Charles Noren) Newsgroups: comp.lang.c Subject: Re: C official DOD langauge? Message-ID: <1628@dinl.mmc.UUCP> Date: 31 May 90 15:48:54 GMT References: <1990May30.212533.8105@msuinfo.cl.msu.edu> Reply-To: noren@dinl.UUCP (Charles Noren) Distribution: usa Organization: Martin Marietta I&CS, Denver CO. Lines: 49 In article <1990May30.212533.8105@msuinfo.cl.msu.edu> scholten@cpsvax.cps.msu.edu (David Scholten cps) writes: >What are the benefits of using C versus Fortran? I used Fortran a long time ago (Fortran IV, before Fortran 77), so some of these comments may not apply in respect to Fortran 77. Here is the start of a list of advantages of C over Fortran and Fortran over C: C Advantage list: 1. Data Structures (Fortran IV didn't have them). 2. Cleaner code structures. Rarely do you need labels (as you do in Fortran DO loops, computed goto's, etc.). You do need lables in C case statements. 3. Data Pointers. Even before I used C, there were times I needed to point to areas in memory (with a defined structure). This was faked at various times by using an assembly language function or using a vendor supplied pointer function. Never as clean as C pointers. 4. Ability to have variable argument lists. 5. Ability to do recursive function calls. 6. Macros. 7. Function pointers. One time on a project we needed to implement a function table for a Finite State Machine (for a protocol processor written in Fortran IV -- arghhh!). It was done with integer values in the table fed into a computed goto (yuk!!). In C, you put the function pointers right into the table and call them. 8. Free form entry of code for C vs. the reserved columns for Fortran (at least Fortran IV). This allows nicer indentation style to make the code easier for the human to read. C Disadvantage list: 1. Pointers. This will take pure Fortran hackers a little time to get used to. Pointers are pervasive in C. 2. Perhaps a little less mature library for math stuff. -- Chuck Noren NET: ncar!dinl!noren US-MAIL: Martin Marietta I&CS, MS XL8058, P.O. Box 1260, Denver, CO 80201-1260 Phone: (303) 971-7930