From mboxrd@z Thu Jan 1 00:00:00 1970 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 102b75,45b50f14dadfce5b X-Google-Attributes: gid102b75,public X-Google-Thread: 110292,45b50f14dadfce5b X-Google-Attributes: gid110292,public X-Google-Thread: 1164f8,45b50f14dadfce5b X-Google-Attributes: gid1164f8,public From: Craig Burley Subject: Re: Final kick at the "Merced Guessing Game" Date: 1997/10/16 Message-ID: X-Deja-AN: 281240557 References: <61g30t$o2n@news-rocq.inria.fr> <3442F866.36A8BB69@tonys.ecology.umn.edu> <623ek6$ef5$1@news.iastate.edu> Organization: Cygnus Support Newsgroups: comp.sys.intel,comp.arch,comp.sys.dec rhawkins@iastate.edu (Rick Hawkins) writes: > In article , > Craig Burley wrote: > > >Yes, I *know* that if we threw tons of resources behind making > >C compilers more clever at teasing out the original intent of the > >programmer, we could make it produce fast code for even numerical > >codes. Then we could tell all Fortran programmers to spend more > >time writing C code than they have to write Fortran code, but we'd > >have One True Language that everyone could use. > > And here you get to the crux of it, at least for some of us. > > Yes, i could get far more control, and do more hand optimization for my > machine, with c than Fortran. But why should I? I'm a scientist, not a > programmer. I want to get from formulating my problem to an answer as > soon as possible. This code will only run a couple of times once > debugged. Spending *any* extra time to use c would be a waste of time, > unless it actually ran faster for the *same amount* of work. Agreed, except for the part about "get far more control, and do more hand optimization for my machine, with c than Fortran". I keep saying this, nobody seems to have put forth any evidence, or even persuasive counter-arguments, to the contrary: C offers *very* little in terms of low-level constructs that Fortran doesn't offer. Richard O'Keefe pointed out "pointers", and some people jumped all over him for saying that (because he didn't list a lot more), but he's essentially right, that's basically all ANSI/K&R C has to offer over FORTRAN 77 (and note we're comparing a circa-1985-standardized language, ANSI C, to a circa-1978-standardized one, FORTRAN 77, the latter having even more historical baggage dating to back when people didn't *know* how to do language design properly, instead of simply not bothering to learn about what had gone before...Fortran 90, standardized circa 1991 or whenever, *has* pointers, overly fancy ones if you ask me, certainly fancier than any C variant I'm aware of). And, most Fortran compilers (g77 and f2c probably being the only exceptions that are at all popular) offer some form of pointers anyway -- certainly all Fortran 90 compilers do. Though, adding pointers to Fortran was about as painful and weird as was adding `restrict' and all the other baggage to C to make it approach vanilla Fortran performance on similarly expressed code. In other areas where Fortran lacked the syntactic elegance of C, adding intrinsics like IAND, IOR, ISHFT, and so on was quite easy and consistent with normal Fortran expectations, and pretty much all compilers support these (or they can be added easily by programmers as external routines, typically at a performance penalty). What Fortran doesn't offer is the syntactic *convenience* of things like `&&' and `||', which is a huge pain in the butt for some kinds of work (it was for me anyway, back when I used Fortran and PL/I for my work, as PL/I also lacked these, back then). But syntactic convenience is not really a performance issue -- not for wiz kids with nifty editors (like Emacs ;-) anyway. (Speaking of that, isn't "wiz" the proper spelling? I see "whiz" used for "wizard" sometimes, as in "Weather Whiz" and such, but that makes me think of "Cheese Whiz", a name I don't believe was intended to connote wizardly qualities. Yet while "wiz" makes sense to me as a noun, when I go to use it as an adjective, I do type the "h" and then have to edit it out -- I typed "whiz kids" above first, and it *felt* right, but isn't "wiz kids" correct? This is a much more important an issue than which programming language people should use for multi-million-line numerical-programming projects, IMO.) The other painful thing about using Fortran for low-level coding is interfacing to C APIs (just as using C to interface to Fortran APIs is painful). Yes, in most Fortrans you can use %VAL, %REF, %DESCR, and so on to achieve what you want, but that's hardly a friendly way to go. But, again, it's a matter of syntactic convenience, mostly, with a strong dash of portability thrown in (since the C API might look exactly the same to C code on another system, whereas Fortran code munged to interface to that API might not). But I haven't seen these issues raised in this thread. The main issue was multi-dimensionality, and I have yet to see *anyone* explain why C's flat, single-dimension facility is *superior* for low-level coding to Fortran's `REAL A(0:N)', which is the same thing, essentially. So I *still* don't understand why C is *better* as a low-level translation of code originally, and properly, written in Fortran, than is Fortran. -- "Practice random senselessness and act kind of beautiful." James Craig Burley, Software Craftsperson burley@gnu.ai.mit.edu