Should I convert FORTRAN code to C?

Leo de Wit leo at philmds.UUCP
Sun Jun 26 06:46:10 AEST 1988


In article <750 at garth.UUCP> smryan at garth.UUCP (Steven Ryan) writes:
>First of all I agree with Dijkstra with respect to Fortran. I feel the
>challenge designing a new language that can be Fortran at its own game,
>which C does not do.

So what IS FORTRAN's game?

> [stuff deleted]...
>A Fortran compiler is permitted to allocate all arrays statically, before
>compilation, and many do this. Also Fortran subroutine are not required to
>be recursive and hence do not need a procedure frame. All allocation can be
>done in the compiler and the runtime overhead can be zero.

A few remarks:
A C programmer can CHOOSE (note: uppercase 8-) whether he wants arrays
to be global, static or automatic. This means that the runtime overhead
can be at least as little as that of a FORTRAN program (zero overhead is
rubbish; you always have to page or swap the data in, whether you use data
/heap space or stack space, or you at least have to claim core).
Furthermore you make it sound as if it was a merit when functions
cannot be recursive (are not required to..); procedure frame are more
or less for compiler builders: you can do without them, making it much
harder for yourself (most procedure frames can be build and broken down
with a single, fast instruction; this goes also for pushing/popping
sets of registers). If you can design a function in which the system
spends significant time doing call, return, push, pop, link, unlink
there must be very little code inside that function (try a macro; no,
I do not mean an assembler! 8-). Dropping off these things (call, push ..)
can only gain a few percent, at what other cost (inflexible subroutine
scheme, permanent variables)? You can even totally rule out any use of
subroutines if you're out for speed: large monolotic blocks with many
pieces of repeated code, is that desirable?

The scope of local variables can be more restricted than in FORTRAN if you
wish so (yes, for auto AND for static vars); more like Algol block-bound.

>Also it is easy for programmer to modify the array base address to implement
>nonzero lower bounds. It is also easy for the compiler. I suspect Fortran
>programmers know alot less about dope vectors biased base addresses and that
>ilk than C programmers (scientists and engineers vs. computer science and
>system programmers).

The trouble here is obviously that scientists want their problem to map
too literally onto the notation and possibilities of a computer
language.  Strange, because C you have to learn only once (that is,
twice if that is not the proposed ANSI draft standard), scientific
notations may change all the time. Knowing how to work with pointers
can improve on speed considerably.

>
>>	       ii) You can define your own data structures,
>
>Apparently some Fortran programmers equivalence different typed arrays to
>create structures (shudder).

Now this one I cannot grasp (English not being my native language); what do
you mean by this sentence (what are the predicate and the subject) ?
Can you give an equivalence 8-) ?

    Leo.



More information about the Comp.lang.c mailing list