LWN.net Logo

Rust

Rust

Posted Apr 7, 2013 14:04 UTC (Sun) by anselm (subscriber, #2796)
In reply to: Rust by HelloWorld
Parent article: Mozilla and Samsung building a new browser engine

A Fortran compiler is allowed by the language definition to make all sorts of assumptions that are unavailable to a C compiler. This gives a Fortran compiler room for various optimisations that a C compiler can't do to the same degree. This means that for the typical sort of program one would write in Fortran, a Fortran compiler is at a distinct advantage compared to a C compiler as far as optimisation is concerned. On the other hand, C allows you to write programs with reasonable ease that can't be conveniently expressed at all in Fortran (one notable example being the Linux kernel).

In addition, direct translation of Fortran source code to C (and vice versa) usually leads to significantly worse performance in the new language if arrays are involved, simply because Fortran assumes that arrays are stored in row-major order while C assumes a column-major arrangement. In a speed comparison of programs written in both languages, factors like these ought to be controlled for.


(Log in to post comments)

Rust

Posted Apr 7, 2013 15:10 UTC (Sun) by HelloWorld (guest, #56129) [Link]

> A Fortran compiler is allowed by the language definition to make all sorts of assumptions that are unavailable to a C compiler.
What assumptions? The one that people keep bringing up (pointer aliasing issues) was fixed a long time ago with the restrict keyword.

> In addition, direct translation of Fortran source code to C (and vice versa) usually leads to significantly worse performance in the new language if arrays are involved, simply because Fortran assumes that arrays are stored in row-major order while C assumes a column-major arrangement.
How is that supposed to matter? Whether row-major or column-major arrangement is faster depends entirely on the access patterns in the relevant program, and besides that, you're free to use a column-major layout in C as well, you just have to calculate indices by hand.

Copyright © 2013, Eklektix, Inc.
Comments and public postings are copyrighted by their creators.
Linux is a registered trademark of Linus Torvalds