5 ms·
I have recently went through Fortran from zero to all advanced features. My take is the following. The language is verbose but pleasant to work with. The lates
by rad_gruchalski 4y ago
I have recently went through Fortran from zero to all advanced features. My take is the following.
The language is verbose but pleasant to work with. The latest 2008 version is really nice to look at. My assumption is that working with Fortran 77 and earlier isn’t going to be do nice. With modern Fortran, it’s possible to write generic code, operators can be overridden, new operators can be defined, derived types support inheritance. The language supports pure functions and subroutines verified by the compiler. Programs compile to native binaries.
On the other hand, numbers overflow and there’s no support for any networking without c interop, no byte arrays.
The language shines for multi-dimensional data. For example, multiply every array element by two: [10, 20, 45, 65] * 2. Or, multiply one array over another: [10, 30, 46, 32] * [100, 134, 32, 87]. Up to 15 dimensions are supported. Parallel computing: Fortran coarrays are a relatively simple mechanism to distribute work across CPUs, pin work to selected CPUs, and synchronize the computation across CPUs. Potentially thousands of them.
This makes Fortran a one trick pony. It does parallel multi-dimensional data very well, but that’s really where it ends.
A couple of notes on the ecosystem. The community has done a tremendous job at making Fortran easy. FPM is a package manager designed after cargo. It is really easy to import packages from remote locations, for example git branches. There are some really high quality packages out there, but the ecosystem is difficult to explore because there are no package catalogs. FPM website tries to change that. Editor support is awesome. There are extensions for many editors, language servers exist so code hints and syntax checking also works.
Would I choose Fortran for a new product today? If it had byte arrays, sockets and TLS available natively, maybe.
- TheNewsIsHere 4y agoFortran’s strengths with numbers, particularly multidimensional data and parallel computing, is partly why it’s still the go-to standard for crunching through weather modeling.
- deleted 4y ago[deleted]
- noobermin 4y agoThat's the point, Fortran today is a DSL for computational science, that's it and mainly what it focuses on today. It is not (if it ever was) a general programming language.
- pasttense01 4y agoRemember C did not come out until 1972. So in the 1960s your primary options were Fortran, COBOL and assembly language (there were lots of other languages but they were relatively minor languages). Considering the major defects of assembly language there was a significant amount of use of Fortran as a general programming language in conjunction with various libraries.
- tsimionescu 4y agoVarious LISPs were a major contender in those times, with various companies selling their own flavors. LISP was the major high-level programming language used for writing operating systems - before C, other OSs were basically written in assembler (though there was at least one written in COBOL, BLIS/COBOL, which seems to have been more or less contemporaneous with C's early life). FORTRAN was always dedicated to scientific computing, I don't believe it was ever used for system software, so it is a bit apples-to-oranges.
- skissane 4y ago> FORTRAN was always dedicated to scientific computing, I don't believe it was ever used for system software, so it is a bit apples-to-oranges. Early versions of PRIMOS used FORTRAN as a systems programming language, although later versions switched to Prime's proprietary PL/I dialect (PL/P) and Modula 2. The reason for the somewhat unusual choice of FORTRAN as a systems programming language? Prime's founders were experienced FORTRAN programmers, so it was the natural choice for them, and in 1972 alternatives were far less established (C was only just being invented)
- rjsw 4y agoI think PL/I has more of a claim to have been used for writing operating systems before C than Lisp.
- bayindirh 4y ago> Fortran coarrays are a relatively simple mechanism to distribute work across CPUs, pin work to selected CPUs, and synchronize the computation across CPUs. Potentially thousands of them. Add MPI to the mix, and you can distribute that work to multiple machines. Potentially to thousands of them. MPI over InfiniBand also can do some computations on the fly (in the HBAs and switches), so it makes it even fasterer (sic). > This makes Fortran a one trick pony. It does parallel multi-dimensional data very well, but that’s really where it ends. That one weird trick is a very strategic and cross-cutting one so almost every scientist can benefit from using FORTRAN. So, having one trick is not a bad thing here.
- rad_gruchalski 4y ago> Add MPI to the mix, and you can distribute that work to multiple machines. Potentially to thousands of them. My understanding is that coarrays are a modern replacement for MPI and that coarrays abstract the notion of "machines", they bundle that under "multiple CPUs". I'm not very fluent in either of those, only know as much as the "Modern Fortran" book explains but from the examples I have seen, coarrays can do anything MPI can and they're simpler to work with. > So, having one trick is not a bad thing here. Definitely not. Personally, I would imagine myself using it if integration with other technologies over the network was available out of the box.
- m_mueller 4y agoAren’t coarrays only for single machine CPU parallelization? I‘d be surprised if you could abstract a whole network topology over it. The MPI communicator is really where it’s at when you want to drive a whole cluster (and if you’re using Fortran, you probably do).
- bayindirh 4y agoA quick glance at Coarray Fortran [0] shows that Coarray library is built on top of MPI instead of replacing it. MPI and InfiniBand are irreplaceable technologies for HPC clusters as of today, both in terms of speed and latency. Lastly IB is not a connectivity layer. It's a HBA which carries information from memory space of one application to another. So it's properly "Magick" in terms of programming and research. [0]: https://en.wikipedia.org/wiki/Coarray_Fortran https://en.wikipedia.org/wiki/Coarray_Fortran
- bobochan 4y agoI also like FPM and the ecosystem. In case anyone is just getting started with Fortran, definitely checkout the Fortran Standard Library project: https://github.com/fortran-lang/stdlib https://github.com/fortran-lang/stdlib
- tored 4y agoHow well does Fortran intermingle with other languages, like loading libraries (so, dll etc) or compile source as a library (dynamic or static)?
- wumpus 4y agoMost Fortran compilers are also C compilers, and the Fortran standard library is usually implemented in C. So interop with C is easy.