4 ms·
To expand a bit on other answers: There is a qualitative difference Fortran has by offering 1) built-in multidimensional arrays including Matlab-like array ope
by m_mueller 7y ago
To expand a bit on other answers: There is a qualitative difference Fortran has by offering
1) built-in multidimensional arrays including Matlab-like array operations. That means every library supports the same format, it's standardized and convenient as opposed to the many formats in C++ Land.
2) performant defaults. When performance is more important than safety, Fortran programs are easier to write and maintain. Arguments are by default pass-by-reference, non-aliased (a major assumption Fortran compilers can usually make to optimize) and their intent as in/out/in out can simply be marked as such.
Fortran:
real(8), intent(in) :: foo
C:
restrict const * const double foo # if I remember correctly
- goerz 7y agoI’m not sure what you mean by “When performance is more important than safety, Fortran programs are easier to write and maintain.” The fact that arrays are not based on pointers makes Fortran a much safer language than C. It’s very hard to shoot yourself in the foot with Fortran. It’s fast and safe
- pletnes 7y agoIt’s very easy to shoot yourself in any body part - just disable array bounds checking, drop modules (which means no function call interface checks) and you’re practically back to C-land in terms of memory safety. Of course, the sensible thing to do is to check interfaces and bounds (at least in debug/test mode).
- m_mueller 7y agoFortran offers a better developer experience overall for Numerical applications yes. But it is still very foot shootable as I remember - point a pointer at allocatable and the fun can start. Or make everything inout for convenience and/or performance. But yes, compared to C the defaults are also safer, just don't expect Rust.