← Back to context

Comment by hatmatrix

4 days ago

A lot of the early, absolute advantages of Fortran (numerical precision, non-aliasing) has been adopted by C.

However what still makes it a great choice is that it still a relatively simple language compared to C, and maps mathematical formulas to code very well. Inelegant code will still run reasonably fast (which is not the true with C) - so all of these points make it actually a good language when the program is being written by domain experts (i.e., scientists) rather than professional programmers or software engineers.

As @jleyank pointed out, the more restrictive semantics of Fortran prevent expressing things the compiler can't optimize. A Fortran compiler can make assumptions about code flow and memory accesses a C compiler can't, and, therefore, can optimize the code further than a naive C implementation could be optimized.

>Inelegant code will still run reasonably fast

What do you mean by inelegant code in this context?

Non-idiomatic? Like non-Pythonic in the case of Python?

  • Basically you don't need to think much about the computer itself, unlike C or C++. Just pass in your arrays or pointers (everything is passed by reference anyways), crunch numbers, and it'll be about as optimized as carefully __restrict__ laden C code.

    There's also fewer traps to fall in than C++ which is elephant sized in scope to Fortran's mouse.