From: "Mauricio Fernández" Date: 2002-08-23T06:59:12+09:00 Subject: [OT] Re: What New Language After Ruby? On Fri, Aug 23, 2002 at 01:10:47AM +0900, Gavin Sinclair wrote: > > ----- Original Message ----- > From: "Dan Sugalski" > > > > > > Folks have already thrown Lisp, OCaml, Prolog, and Japanese into the > > mix, and Smalltalk is always floating around. Given that those are > > reasonably academic languages (Okay, except for Japanese :) I'll add > > a few of the more low-level or odd languages. > > > > [...] > > > > Fortran: Yeah, it's older than you are, but it still can't be beat for speed. > > Can I ask why? People say it all the time, but I point-blank refuse to believe > that it is faster than optimised C. They're the same bloody thing, aren't > they? - low-level procedural languages. My knowledge of Fortran is small, but > of course everyone knows it's used for scientific calculations, so it may have > the edge in numerical calculations (infinite precision, ...) but can't you get > a C library that equals it? If not, why not. It's all machine language in the > end, and not sufficiently far from that to begin with for me to believe that > the two should be any different. I've never used (or seen :) Fortran, but I can think of a number of reasons for a language to be "faster" then C... * scientific computation means doing things with _vectors_; I'd bet Fortran compilers know about them and can use SIMD accordingly * aliasing: in C (but no longer in C99) you can have several different pointers to the same value, which means some values have to be escaped and can't be put in registers. I'd bet again that Fortran doesn't allow that * C makes some things harder to inline. Think of qsort(): you give it a function pointer to compare two values and it sorts an array. Can't be faster, right? Yet it can: qsort() involves a function call to compare the elements, whereas in C++ for instance that function is easily inlined, for std::sort is a template function... * COW and shared mem representations: C uses by default call-by-value semantics, which involves copying data. You may use pointers to go around this, but there's one reason why this doesn't solve the problem completely (read below). One example of COW is std::string, where the actual data is only copied when it is modified... Another one is perl's strings, which I've read can often be faster than C's. * [related to the latter but I wanted to develop a little more on this]: lazy evaluation Say you have vectors A, B, C, D. You wanna make A = B .* (C + D) .* means one-by-one product, not matrix product In C you have to go through the pain of doing for ( i = 0; i < size; i++) A[i] = B[i] * (C[i] + D[i]); Sure this doesn't seem too bad, but in some languages you can make A = B .* ( C + D ) and still be running the code above (or even better), without temporary values, for C + D doesn't compute the sum right away, but something that "remembers" it is the sum of C and D. It is only computed when actually needed. Note than with A = B .* ( C + D ), in some languages you later can have A[i] and only get A[i] = B[i] .* ( C[i] + D[i] ) calculated, cause things are only computed when _really_ needed. It is convenient to be able to skip this sort of details when you're writing something complicated. APL did this, AFAIK. * not related to the language, but important anyway: many scientist have rather modest programming skills. They need a tool in which they can easily map the "mathematical solution", but they'll code as if it did even when it doesn't. Read http://www.ccl.net/cca/documents/C-vs-FORTRAN.shtml I've found a paper on Blitz++ (a scientific calculation library for C++) vs Fortran, maybe some things can map to C: http://osl.iu.edu/~tveldhui/papers/iscope97/ -- _ _ | |__ __ _| |_ ___ _ __ ___ __ _ _ __ | '_ \ / _` | __/ __| '_ ` _ \ / _` | '_ \ | |_) | (_| | |_\__ \ | | | | | (_| | | | | |_.__/ \__,_|\__|___/_| |_| |_|\__,_|_| |_| Running Debian GNU/Linux Sid (unstable) batsman dot geo at yahoo dot com Linux: the operating system with a CLUE... Command Line User Environment. -- seen in a posting in comp.software.testing