Xref: utzoo comp.lang.misc:6353 comp.lang.scheme:1881 Path: utzoo!attcan!telly!lethe!torsqnt!news-server.csri.toronto.edu!cs.utexas.edu!uunet!mcsun!ukc!dcl-cs!aber-cs!athene!pcg From: pcg@cs.aber.ac.uk (Piercarlo Grandi) Newsgroups: comp.lang.misc,comp.lang.scheme Subject: Re: Fortran vs. C for numerical work Message-ID: Date: 21 Dec 90 12:14:21 GMT References: <1990De <1990Dec13.084916.15659@ariel.unm.edu> Sender: pcg@aber-cs.UUCP Organization: Coleg Prifysgol Cymru Lines: 117 Nntp-Posting-Host: odin In-reply-to: prentice@hydra.unm.edu's message of 13 Dec 90 08:49:16 GMT On 13 Dec 90 08:49:16 GMT, prentice@hydra.unm.edu (Colston Chandler PHYSICS -- or John Prentice?) said: prentice> In article prentice> pcg@cs.aber.ac.uk (Piercarlo Grandi) writes: pcg> ....Still, of my 2 alternative to Fortran, one, C++, is kind of pcg> the ultimate in notational convenience; like Fortran [89]0, user defined pcg> types, operators, ... Now that I think of it I think that one of the pcg> very best languages for numerical analysis, with some of the very best pcg> implementations, is Algol 68. Too bad it has almost faded away. prentice> So how is C++ for scientific programming? In particular, what prentice> exactly does an OOPS language do for numerical programming? Well, there are plenty of fairly good quality numerical libraries for C++. The benefits of OO programming for numerical analysis is that even numerical problems often have fairly sophisticated structure, and OO programming is good at describing and changing structure. While it may be a major undertaking to change an existing program in Fortran to use sparse instead of full matrixes, it is much less of a hassle in OO languages. Changing your program from single to double precision and viceversa is trivial in any language with type declarations; with OO programming it is also almost as trivial switching from straight floating point to interval arithmetic or arbitrary precision integers. C++ also gives fairly concise notation, and it is easier to see the shape of an algorithm in C++ than in Fortran, because of the superior data abstraction facilities provided. Cleverly used, C++ is at least as efficient as Fortran, or even more so (const, inlining, ...), and the famous aliasing/optimization problem can be usually worked around by the use of compiler directives or explicit temporaries (the better solution, it makes things more obvious). On some popular machines you get better speed by translating Fortran to C/C++ then using the Fortran compiler directly. Note that many of the proposed extensions to Fortran as in Fortran [89]x are already present in C/C++. prentice> Also, do you (or anyone else) have any suggestions for a good prentice> language for doing numerical programming on a parallel prentice> computer? I am interested in fluid dynamic like codes, so I prentice> need to maximize performance. [ ... ] Is C++ or Ada better? Ah, this is some hard question. Very hard. C is essentially like Fortran in this, in that compilers analyze the source to find opportunities for parallelism, and rewrite the program... Trickery. Sadly, the state of the art for micro-parallel (vector/SIMD) languages is not that advanced. Some interesting research is being done with functional languages, but I am skeptical on functional languages (too long to explain why). Moreover current functional language implementations are not numerically oriented. For coarser parallelism there is Concurrent C/C++ and a number of thread packages for C/C++. Also, Ada tasking, but there are precious few implementation of Ada that map tasks on threads running on multiple processors. *Lisp for the Connection Machine is a rarely affordable alternative. Yeah, now that I think of it, I can remember several thread libraries for C/C++, some of them multiprocessing (different threads run on different CPUs), but (of course) none for Fortran. Interesting. pcg> Scheme is one of the most widely implemented languages, running on pcg> all of the popular architectures, is well defined by a clear and pcg> concise report, ... prentice> I will look up the reference you gave on Scheme. Sounds like prentice> something I should at least know about. I would suggest having a look at T and Mul-T; T is an implementation of (something that is nearly identicaly to) Scheme with a fairly good optimizing compiler; Mul-T is the parallel version of T. I have used a little bit T, and it is large but nice. I have not used Mul-T. Incidentally, a good list with discussion of Scheme implementations is in "arisia.xerox.com:/pub/scheme/scheme-implements.txt". prentice> [ ... the difficulty for computational physicists have in prentice> styaing tuned with CS progress like new languages ... ] But this is problem that engineers and physicists have! Their main subject is not maths, it is engineering or physics, but maths are a very important part of their training, and those that do research in engineering or physics have to keep very current in maths as well; indeed they have made a number of contributions to maths. Computer Science is this respect is like Mathematics, an abstract discipline that is ancillary to many others. Learning a new language is (well, should be) like learning a new method for doing eigenvalues for an engineer or a physicist. It is a pity that Computer Science itself does not have the traditional respectability of Mathematics, so that people that delight in learning new ways to tackle the eigenvalue problem do not delight in learning new languages or programming technology. Is this a problem with languages or other CS technology that is more offputting than maths? No, I think, because while CS people do care (too rarely!) about human engineering issues, e.g. in designing languages that are descriptive and concise, maths people don't; most mathmatical notation is horrid, and most theorems could often be drastically simplified and streamlined both in exposition and substance. But people are used to and put up with cryptic maths, while they make excessive demands of CS. Ahh. Maybe this is why people think that Fortran is like maths: it is cryptic and ill structured... :-(. -- Piercarlo Grandi | ARPA: pcg%uk.ac.aber.cs@nsfnet-relay.ac.uk Dept of CS, UCW Aberystwyth | UUCP: ...!mcsun!ukc!aber-cs!pcg Penglais, Aberystwyth SY23 3BZ, UK | INET: pcg@cs.aber.ac.uk