Q:

Do Fortran compilers really generate faster code than C compilers?

When I was studying in the university I often heard the idea that Fortran compilers produced faster code than C compilers for an equivalent program.
The key reasoning went like this: a Fortran compiler emits on average 1,1 processor instruction per line of code, while a C compiler emits on average 1,6 processor instruction per line of code - I don't remember the exact numbers but the idea was that C compilers emitted noticeably more machine code and therefore produced slower programs.
How valid is such comparison? Can we say that Fortran compilers produce faster programs than C compilers or vice versa and why does this difference exist?

A:

IIRC one of the main reasons why Fortran is said to be faster is the absence of pointer aliasing, so they can use optimizations that C compilers can't use:

In FORTRAN, function arguments may not alias each other, and the compiler assumes they do not. This enables excellent optimization, and is one major reason for FORTRAN's reputation as a fast language. (Note that aliasing may still occur within a FORTRAN function. For instance, if A is an array and i and j are indices which happen to have the same value, then A[i] and A[j] are two different names for the same memory location. Fortunately, since the base array must have the same name, index analysis can be done to determine cases where A[i] and A[j] cannot alias.)

But I agree with others here: Comparing the average number of assembler instructions generated for a line of code is complete nonsense. For instance a modern x86 core can execute two instructions in parallel if they don't access the same registers. So you can (in theory) gain a performance increase of 100% for the same set on instructions just by reordering them. Good compilers will also often generate more assembly instructions to get faster code (think loop unrolling, inlining). The total number of assembler instructions says very little about the performance of a piece of code.

A:

Completely invalid comparison.
First, as @Péter Török points out, you must first compare the number of lines in equivalent programs from Fortran and C for this to even be a valid comparison on the number of lines produced.
Second, less lines of code doesn't always equal faster programs. Not all machine instructions take the same number of cycles to execute, but you also have other issues such as memory access, caching, etc.
On top of that, long code runs can be faster since it results in a lower number of execute lines (ie, Line Count != Executed Line Count).

A:

Dan is correct, longer programs don't mean slower programs. It depends greatly one what they are doing.
I'm no expert on Fortran, I know a bit. Comparing them, I would think well written C would do much better in performance with more complex data structures and functionality than Fortran. Someone (please) correct me if I'm wrong here, but I do think Fortran is somewhat on a 'lower level' than C. If so, I'm sure for some problems would come out faster on Fortran.
Another thing, at first glance I thought you were asking if the compilers are faster. I actually do think that Fortran will generally compile faster for similar amounts of code, but the resulting program and how it runs would be a different story. It is just simpler to parse through.

