10 ms·
Reasons why Fortran is still used (2021)
- BXLE_1-1-BitIs1 4y agoFortran was my first language. It's crap on working with character data. I happily moved to PL/1. I was in a project using Fortran for telecom switches and had to add an Assembler routine for character manipulation. PL/I can produce efficient numeric code, provided you avoid library calls, and dope vectors (use static and pointers). However that requires setting standards to avoid PL/I performance traps. PL/I data conversion library subroutines can bog performance by a factor of 10.
- travisgriggs 4y ago> Fortran is easier to use than C/C++ for scientific computing You had me at “Fortran is easier than C++”.
- gus_massa 4y agoHave you tired modern fortran? Arrays and matrix are easy. String are horrible, but they have also many quirks in C. Anyway, we still use a mix of modern fortran with old fortran (I'm not sure it's even fortran 77).
- deleted 4y ago[deleted]
- varjag 4y agoMost things are easier to master than C++, Fortran included.
- jmclnx 4y agoThere is also comp.lang.fortran in USENET if you do not want to mess with discourse. There are a few very knowledgeable people still hanging out there. Plus no tracking if you use a real news reader (which means not google groups).
- jabl 4y agoThat newsgroup also has more than it's fair share of maddeningly annoying people who think anything beyond Fortran77 plus the proprietary compiler extensions of the compiler they happen to use (which inevitably is some long-dead trainwreck like MS Powerstation that nobody else has used for decades) is an affront to them and God (in order of importance). And some people who inevitably try to derail every single thread into a discussion of Fortran IV and PL/I in the context of programming some 1970'ies IBM mainframes. I used to be somewhat active on c.l.f, but I quit many years ago, and to be honest I haven't missed it one bit.
- sakex 4y agoTalk is cheap, show me the code. There are exactly 0 snippets in this article, despite making subjective claims about the language being easier and more intuitive than C/C++ for HPC.
- rad_gruchalski 4y agoHere’s a good introduction to coarrays: https://github.com/tkoenig1/coarray-tutorial/blob/main/tutorial.md https://github.com/tkoenig1/coarray-tutorial/blob/main/tutor....
- btrettel 4y agoIn my view, Fortran's biggest advantage over C and C++ is its much simpler mental model. Compared against C and C++, a Fortran programmer needs to think much less about pointers and memory addresses. For example, Fortran procedures (functions and subroutines) are pass-by-reference, compared against C functions being pass-by-value. A Fortran programmer doesn't need to call a procedure with (C syntax) func(&x), declare the procedure with int *x, dereference the pointer with *x to get the value inside the procedure, etc. They can simply write x in all those places and it'll work. Why is pass-by-reference good in computational science? Passing large arrays by value would waste memory. Pass-by-reference is a better choice for large arrays.
- npalli 4y agoA bit off topic, but the author has some nice links to his experience with Julia (starting with this post) which seems a very strong contender for taking over numerical computation and HPC from Fortran (not to mention the somewhat unnatural languages like Python/C/C++)
- fnands 4y agoI was about to comment, if you like Fortran's syntax for numerical computation, you should try Julia. I feel it's basically the spiritual successor to Fortran, without all the historical baggage.
- complex_pi 4y agoI am always surprised that people are surprised about Fortran's activity! It works and your code will likely still compile 10-20 years from now. (It is certainly not perfect and sometimes it is annoying, but the same can be said about most programming languages).
- rad_gruchalski 4y agoI 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.
- thewebcount 4y agoI recently checked out flang[0] because I had never used Fortran and just wanted to see what it was like. It works pretty well! I did find one compiler crasher which I reported and they fixed within a few days. [0] https://flang.llvm.org/docs/ https://flang.llvm.org/docs/
- mapmeld 4y agoAs an open source dev, I was impressed by how patient everyone is in getting complex Fortran PRs merged (you can take a look on OpenBLAS on GitHub). Part of this is the communities which still use Fortran, and part of it is no one is doing it haphazardly. I even got good suggestions on my own repo from strangers.
- hilbert42 4y agoSometimes one finds oneself agreeing with a HN story that one knows to be factually correct and then not bother to defend its position against naysayers with entrenched views as to do is to buy an argument that one can't win—well, this is one such story. As a Fortran programmer I know the language is alive, well and still doing what it does best so there's no need for me to defend its position in the programming languages debate—a debate which in recent times has taken on a fervor of nationalism about it.
- deleted 4y ago[deleted]
- goethes_kind 4y agoWhat do you use it for? My dream is to write Fortran some day. I'm a mathematician who does mostly computations stuff, so like, it should be easy to come by such an opportunity, but so far I had no luck. Only Python, C, C++ and some Julia.
- fuzzfactor 4y agoMaybe you would be a good candidate to compile a number of Reasons Why Fortran Should Be Used More Often.
- mellavora 4y agoI can think of one or two reasons, - It is damn good at what it is designed for, and that use case covers a lot of ground. - No maddening update cycle which breaks all of you code once every 6 months There are some languages where the primary reason for using them seems to be - It is the first language I learned, and even though it is maddeningly inconsistent (despite claiming to be simple), it is a tool I am comfortable with Not taking sides here. If you need to deliver something, the tool you know may be the best way to get it done on time/in budget, or a common tool may be better for business continuity. Everything is tradeoffs.
- tibbydudeza 4y agoJust one thing - debugged and battle tested numerical compute libraries
- dm319 4y agoIs there another numerical computing language that compiles?
- mkovach 4y agoAhh, FORTRAN. I have fun, memories of FORTRAN. Write out of college in the mid to late 90's I worked with the language quite a bit. I was working for a logistics company and we spent a lot of time calculating routes, costs (fuel, maintenance, etc.) and the like using FORTRAN. The move from F77 -> F90 -> F95 was rather pleasant. When the web started to become popular and Microsoft started including IE on desktops, I ended up writing CGI scripts, in FORTRAN!, to model reports in HTML. We were moving from OpenVMS to Sun Solaris boxes, which allowed use to move way from writing text based reports that people viewed on a terminal to HTML pages that would easily allow CSV files to be downloaded. I was a mess for few months. I don't think I have ever fully recovered. Yep, my first bit of web based programming was FORTRAN 95 and DCL. I had to cobble a cgi library together where I put in something that acted like, but wasn't exactly, authentication and security. By the mid-2000s the system had been migrated to some monstrous application that was mostly Java, but there were still FORTRAN bits handling the math and numerical back end, but I had moved on by then. I still have nightmares about the system, but writing the FORTRAN code was also easy. Using it in the right spot was always the hard part.
- BlueTemplar 4y agoTo insist on a point : FORTRAN is not just used like the (more recent) COBOL might still be "used" in legacy infrastructure - it's still being taught too, with mandatory FORTRAN-only assignments ! (Of course I might just be unaware, and COBOL teaching might still be widespread in some fields, feel free to prove me wrong !)
- bullen 4y agoWhat do Coarrays do differently than a simple C(++) int/float array for atomicity? Is there some extra magic, maybe for architectures that have "weak" memory?
- j_not_j 4y agoIt's not about atomicity. Co-Array Fortran is for multiple copies of the same program running on different data -- SPMD. Think MPI but much easier to write for. You start a CAF program with mpirun. Multiple copies on the same machine or multiple machines in a cluster, your choice. Embedded directives to process arrays concurrently is a different topic, and confusingly called OpenMP with no "I". Thus your multi-core CPU can process a numeric code more quickly. You start a program using OpenMPI with it's own name --- ./a.out for example. You can control the number of threads used. Etc.
- bullen 4y agoOk, to me those abstractions/tools make little sense. I'd much rather use C on a client (int/float arrays for parallelism + cache) or Java concurrency on a server. If I need cross machine parallelism that is not something I want automated.
- hyperbovine 4y agoI think the main reason, sort of related to "code longevity", is simply that a) nobody learns Fortran anymore and b) there is a huge existing library of extremely efficient, mostly bug-free numerical code that was written by experts in the 70s-80s-90s. LAPACK being the best example. Any port will a) contain more bugs and b) be slower, so what's the point? There are more fun things to do in life.
- teleforce 4y agoPorting LAPACK is not necessarily slower. C, C++ and D languages have better performance ports that are faster than Fortran based LAPACK (numerical library still being used by Matlab and Julia to this very day) [1][2]. Particularly, D language has a better performance port of LAPACK since more than 6 years ago and it should be much easier to be understood and maintained compared to Fortran, C or C++ ones [2][3]. Recently D introduced importC feature to natively support C, the de facto language for system programming. You can then just simply import and re-used the existing C programs and libraries as it is with all the bugs without introducing more bugs [4]. I hope already debunked the myth that Fortran is irreplaceable for numerical codes based on your arguments for good. [1]Vastly outperforming LAPACK with C++ metaprogramming: https://wordsandbuttons.online/vastly_outperforming_lapack_with_cpp_metaprogramming.html https://wordsandbuttons.online/vastly_outperforming_lapack_w... [2]Numeric age for D: Mir GLAS is faster than OpenBLAS and Eigen: http://blog.mir.dlang.io/glas/benchmark/openblas/2016/09/23/glas-gemm-benchmark.html http://blog.mir.dlang.io/glas/benchmark/openblas/2016/09/23/... [3]Commentary on "Outperforming LAPACK with C++ metaprogramming": https://news.ycombinator.com/item?id=16257794 https://news.ycombinator.com/item?id=16257794 [4]Your next C compiler is a D compiler: Introducing DMD's ImportC: https://news.ycombinator.com/item?id=33443615 https://news.ycombinator.com/item?id=33443615
- adgjlsfhk1 4y agoAny chance you can make a PR to julia to give us one of the better LAPACKS? Our medium term goal is to replace LAPACK with pure Julia code but in the meantime, performance improvements are always appreciated.
- plaguepilled 4y agoI would love to get some exposure to FORTRAN! Where are the jobs hiding?
- fastneutron 4y agoAssuming you’re in the US, Check out the various Department of Energy labs, NASA, basically anywhere there’s big computations being done to support science and engineering projects.
- mbrodersen 4y agoYears ago at university I wrote a small 2D circuit board drawing system in Fortran running on some old IBM mainframe computer. Only the first 6 characters of function names mattered so I ended up using the first 2 characters as the module/namespace and carefully encoded the next 4 characters as needed. I had never programmed in Fortran before but it was easy to learn. Fun times. The company I work for is still using old Fortran code to simulate how long it takes for trains with a certain load to get from A to B given a sequence of gradients. I bet small bits of Fortran still lives inside many systems written in C/C++.