jeenglis@alcor.usc.edu (Joe English Muffin) (12/04/90)
gt4512c@prism.gatech.EDU (BRADBERRY,JOHN L) writes: > Many who >have programmed in other languages for years don't want to be forced >to 're-think' their programming style to suit a language. However, the >fact that one HAS programmed for years in a language is perhaps a good >reason to take a step back and consider some alternative methods. It's >too bad that it takes more time than many are willing to invest... Hear, hear! Exposure to different languages is a tremendous benefit. Learning Lisp and C++ gave me a whole new outlook on programming; being able to think in a different language, as it were, has helped me to do things in C that I probably wouldn't have been able to do otherwise. (Learning Forth, on the other hand, gave me some *really* nasty programming habits for a period of time, but I'm over that now :-) --Joe English jeenglis@alcor.usc.edu
mjs@hpfcso.HP.COM (Marc Sabatella) (12/05/90)
>(Learning Forth, on >the other hand, gave me some *really* nasty programming >habits for a period of time, but I'm over that now :-) On the contrary, it taught me the value of documenting even the most trivial of operations, for fear of forgetting what I meant by "drop over dup dup". It also taught me how to be conservative with function arguments, to avoid excessive copying of stack items. Cobol; now *there's* a language I got nothing useful out of.
mjs@hpfcso.HP.COM (Marc Sabatella) (12/07/90)
> C on the other hand was not designed for math. It was designed for >systems programming and any other use is incidental. It's not so much >that C is difficult, it's that its syntax is unnatural for scientific >programming. C is a lovely language if you're writing an OS. I think >that those of us who say that we don't want to learn C because it's >"difficult" really mean this: C is not particularly well-suited to our >purposes so that beating our problem into C would be quite a chore. But what makes you say this? About the only significant difference in syntax (as far as translating mathemetical formulae) is that C has no exponentiation operator; instead you must call a library function. Other than that, why is C = SQRT( SIN(X) + LOG(Y) ) perceived to be more "natural" than c = sqrt( sin(x) + log(y) ); ?
mroussel@alchemy.chem.utoronto.ca (Marc Roussel) (12/08/90)
In article <8960031@hpfcso.HP.COM> mjs@hpfcso.HP.COM (Marc Sabatella) writes: >> C on the other hand was not designed for math. It was designed for >>systems programming and any other use is incidental. It's not so much >>that C is difficult, it's that its syntax is unnatural for scientific >>programming. C is a lovely language if you're writing an OS. I think >>that those of us who say that we don't want to learn C because it's >>"difficult" really mean this: C is not particularly well-suited to our >>purposes so that beating our problem into C would be quite a chore. > >But what makes you say this? About the only significant difference in syntax >(as far as translating mathemetical formulae) is that C has no exponentiation >operator; instead you must call a library function. Other than that, why is > > C = SQRT( SIN(X) + LOG(Y) ) > >perceived to be more "natural" than > > c = sqrt( sin(x) + log(y) ); The two lines you have written make it look like it's not a big deal. However, consider the case where x,y and c are complex. Then in Fortran I simply put COMPLEX C,X,Y in the declaration section of my program and the compiler does the rest, right down to selecting the right sqrt, sin and log routines for complex values. On the other hand, in C I would have to supply: a) the complex type b) the addition operator for complex numbers c) sqrt, sin and log for complex arguments on top of which I would have to write c = csqrt(cadd(csin(x),clog(y))) which, at least in my opinion, obscures the meaning much more than the form above. Creating a complex type in C is not a particularly big deal, nor is writing an addition function, but providing a whole complex library could be a lot of work. Sure you only have to do it once and perhaps not even that since someone else might make his code available to you... But what's the point since Fortran knows all about complex types? And what about array operations? My impression was that C's array handling was less than impressive. Pointers are fine, but they don't represent a vector in as obvious a way as a one-dimensional array. Passing a pointer to an array to a subroutine is just not quite the same as passing a vector to a subroutine that deals with vectors. A similar argument applies to higher order tensors. If scientific programming never involved anything more than simple algebraic operations on scalar real numbers and integers, I'd be less resistant to the idea that C might be just as good as Fortran for this purpose. Unfortunately, practically all Fortran code involves matrices or complex numbers. Writing the same programs in C would just not be as easy. Marc R. Roussel mroussel@alchemy.chem.utoronto.ca
gl8f@astsun7.astro.Virginia.EDU (Greg Lindahl) (12/08/90)
In article <8960031@hpfcso.HP.COM> mjs@hpfcso.HP.COM (Marc Sabatella) writes: > Other than that, why is > > C = SQRT( SIN(X) + LOG(Y) ) > >perceived to be more "natural" than > > c = sqrt( sin(x) + log(y) ); Try C = ABS( SQRT(X) ) vs. c = abs( sqrt(x) ); Oops. I guess C++ has what it needs to support intrinsic functions, but that's not in C. It's not a big problem, but I perceive intrinsics as being more "natural". After all, I write "+" to add integers or floating point...
john@ghostwheel.unm.edu (John Prentice) (12/08/90)
You know, the title of this subject "learning other languages" is interesting. The unspoken assumption is that all defenders of Fortran are people who only know Fortran and who are resisting learning anything new. But the issue is not learning new languages at all, it is finding the one that makes you most productive. I know an awful lot of scientific programmers who graduated from college during the last 10 years who only learned Pascal in the university because it was the fad language of the time (now it is C). But I don't know any of them that continued to program in it regularly once they started working on real scientific applications (Pascal was fine when all you did was program small quadrature routines at school, you can put up with any language for small applications. Big ones or very complicated, or anything with complex arithmetic, are a whole other ball game). They all learned Fortran because it was easier for them to accomplish what they were trying to do. So, for them the "other" language was Fortran, not C! I just want to remind people that people also make conscious decisions about their choice of Fortran occassionally, it is not just a question of them being resistant to change or just plain ignorant. John K. Prentice Amparo Corporation