Path: utzoo!utgpu!water!watmath!clyde!rutgers!ames!sdcsvax!sdcc6!ix426 From: ix426@sdcc6.ucsd.EDU (tom stockfish) Newsgroups: comp.lang.c Subject: Re: Power operator? Message-ID: <3585@sdcc6.ucsd.EDU> Date: 20 Jan 88 03:11:33 GMT References: <6982@brl-smoke.ARPA> <326@splut.UUCP> <327@splut.UUCP> <22773@hi.unm.edu> <4186@eagle.ukc.ac.uk> Reply-To: ix426@sdcc6.ucsd.edu.UUCP (tom stockfish) Organization: University of California, San Diego Lines: 65 In article <4186@eagle.ukc.ac.uk> has@ukc.ac.uk (H.A.Shaw) writes: >What people appear to be forgetting is what C is for.... >You >should not do complex mathematical work in C, in the same way that you don't >solve simultainous equations in troff (I have seen this done!) if you want a >long life without ulsers. What we need is to reduce C to it's basics. C is >one of a nearly infinite group of languages, each is good at only ONE job. We >have forgotten that C was originally a system programmers language. Who needs >pow() in a pager or line printer demon? If you want maths, use FORTRAN, to >teach, use BASIC/PASCAL, to drive a robot, use LOGO, etc., etc. Why do you >think we have so many languages? The problem is, there are a million reasons *not* to use fortran for numeric work. For instance, on a machine running Berkely unix, 1. f77 compiles about 50% slower than cc, on comparable source code. 2. on a Celerity, the famous "hello world\n" program, in C, has a 30kbytes executable file (stripped), whereas the fortran version is 100kbytes! Essentially every fortran executable is 70kbytes larger than the equivalent program in C. 3. You can't reasonably write user-friendly i/o schemes for numeric work in fortran. In C you can do a lot of very nice stuff with lex and yacc. 4. In Unix, fortran users are second-class citizens. The symbolic debugger (dbx) is almost unusable with fortran. There are two beautifier programs for C (cb and indent), none for fortran. Other system utilities, such as awk, bc, and sh borrow much of there syntax from C. If there is something wrong with the C compiler it gets instant attention, because the whole system depends on it. For instance, a colleague's research ground to a halt when we upgraded from 4.1bsd to 4.2. NONE of his programs worked anymore, because "print *, ..." statements no longer worked. I doubt a "bug" of such magnitude would have been allowed to slip out in the C compiler. 5. fortran, compared to C, is a very nasty language to write in. The only time I do is when I need complex arithmetic, and then, I write only those subroutines I need in it. When C++ compilers become widespread, I won't use fortran ever again. (At that time I won't use C ever again, but that's another story). 6. On PC's, C compilers are cheap and readily available. Fortran compilers are expensive and might not fit on your machine. Anyway, back to the issue, which is additions to the C standard to make numeric work on C attractive. I realize that system programmers can't live with inside-parenthesis-only optimizations, and that numeric people will never muck up there already difficult to read mathematical expressions with a zillion more parentheses and unary plusses. That is why I whole-heartedly support the previously proposed use of []'s to mean groupings which cannot be rearranged. It's orthogonal, it's mathematical looking, it's elegant, it overloads []'s no more than parentheses are already overloaded, it's [insert your favorite buzzword]. If a power operator is too much trouble, o.k., forget it. But this evaluation order thing is crucial. I wish there were a language designed just for numerical work that was better than C. But nothing comes close. -- || Tom Stockfisch, UCSD Chemistry tps@chem.ucsd.edu