11 ms·
The State of Fortran
- orionblastar 5y agoOpenWatcom Fortran: http://www.openwatcom.org/ http://www.openwatcom.org/
- throwawaybutwhy 5y agoPlease note there's been some uptick in the intensity of discussion on generics lately [0]. Generics are necessary to bring performant data structures to Fortran, and yet they are nowhere near Go's generics. For the usual naysayers doubting Fortran's place in a modern world: whenever you are reading or watching a weather forecast, that's decades of Fortran staring at you. Whenever you drive past a nuclear power plant, or an airbase with 'igloos', remember that nuclear safety codes run on Fortran. [0] https://github.com/j3-fortran/generics https://github.com/j3-fortran/generics
- RandomWorker 5y agoFor what it’s worth the nuclear power plant I worked at ran mostly on LabView. We compiled the code on PCs onto dedicated LabView boxes. No Fortran was ever used.
- noobermin 5y agoNow, as someone with experience with labview that is a horrifying thought...
- hilbert42 5y agoI'd absolutely agree, it's truly worrying. I say that as someone who has worked in nuclear safeguards.
- RandomWorker 5y agoAgreed, we ran a small nuclear system 2KW. All the equipment was experimental. I can see the issues with Lavbiew on PCs plus hardware sucks, but there dedicated systems are actually really good and stable.
- hilbert42 5y agoYeah, right. As you'd know, the size of your system is immaterial when it comes to this stuff, the basic rules are essentially the same in that they all come under the treaty (it's highly unlikely your country isn't a signatory-there being very few that aren't). In essence, that means the simplest approach is to use dedicated and or standardized systems (i.e.: in measurement/accounting) wherever possible then there's little or no argument when the inspectorate arrives. (From my comment you'll know my background.)
- GoodbyeMrChips 5y ago> the nuclear power plant I worked at ran mostly on LabView Jesus wept! -Signed, a physicist with 20 years LabView and Fortran experience.
- socialdemocrat 5y agoFortran has certainly been very important but now people are building climate models faster in Julia and with better performance. Fortran used to be the only option for high performance numerical computing but that is no longer the case. For instance preliminary performance tests of BLAS rebuilt for Julia shows higher performance than the Fortran variants which have been tuned for decades. Part of the reason Julia can do this is due to support for parametrized types and JIT compilation which I can make it possible to in-line a lot of code which you cannot inline with AOT compilation.
- teleforce 5y agoGlad to see Julia is catching up. D language has beaten Fortran based BLAS library in the performance metrics for more than five years now [1]. [1] 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/...
- GuB-42 5y agoI know that modern Fortran is a thing but from my limited experience, it is being phased out. I work for an aeronautics company that has a lot of Fortran code: flight models, material calculations, etc... Some of it is maintained but I didn't see any new Fortran project, and most of the legacy Fortran code have been replaced by C++, Java, etc... as well as more specific tools like SCADE (which generates C code). Same thing for ADA.
- zdragnar 5y agoThat's not to say the code quality is any good, only that it still runs and everyone has their reasons to avoid a rewrite. True, the fact that it is still running says something, but not overmuch about whether it would be pleasant to maintain, extend or otherwise modify.
- ImprovedSilence 5y agoBut does “code quality” matter if all you need is a black box calculation that spits out the right answer every time, and has done so for the past 50 years? Put all the damn goto statements in there you want, as long as I don’t have to look at at, great!
- adgjlsfhk1 5y agoIf your code is performance critical, it absolutely matters. Most Fortran code is FORTRAN 77, and 2-20x slower than it could be because it was written for processors without vectorization, out of order execution, modern branch predictors, or any of the other hardware advances of the past 30 years. Modern compilers can mitigate this slightly, but the algorithms that old FORTRAN code use are fundamentally inefficient on modern hardware.
- ogogmad 5y ago> vectorization, out of order execution, modern branch predictors Two out of three of those are controversial because of Spectre. https://en.wikipedia.org/wiki/Spectre_(security_vulnerability) https://en.wikipedia.org/wiki/Spectre_(security_vulnerabilit...
- adgjlsfhk1 5y agoThey might be "controversial", but they still are absolutely necessary. Modern CPUs typically execute around 3 operations per clock cycle. Without OOO and speculative execution, that drops to .3 (roughly). There's a reason no one is making cpus without them for anything even performance adjacent. Also, just because Fortran code was written without knowing about them, doesn't mean they don't still happen, the only difference is that the algorithms are bad.
- necheffa 5y agoFor what it is worth - I write Fortran professionally (in some of the use cases you describe) and I doubt its usefulness. The way I see it, Fortran exists today because of inertia, not because it still has technical superiority. These mountains of Fortran code represent decades of investment and undocumented "features" that you could never code around during a rewrite. And so today, new code is bolted on, with a prayer that nothing breaks, may god have mercy on your soul.
- mkoubaa 5y agoThe key advantage of fortran is that it doesn't allow pointer aliasing, which allows the compiler to vectorize more. Couple that with the typical fortran use cases and compiler vendors competing on performance by vectorizing more and more. What you end up with is a language with a reputation for being faster for computation
- necheffa 5y agoWhen C99 introduced the restrict keyword this argument fell apart. But I can assure you, the vast majority of legacy Fortran is not vectorizable. At least not without a bit of refactoring. Oh and did I mention, most of this legacy code was hand optimized for memory utilization. You see, back in the day 8k of memory was cutting edge HPC and about half that went to the OS and compiler. Well we all know, everything is a balancing act between time and space - the old timers traded time for space just to be able to do the computation at all on the hardware they had.
- dralley 5y ago> When C99 introduced the restrict keyword this argument fell apart. 1) Nobody puts "restrict" everywhere, and in C it can be very dangerous to do so unless you're exceedingly careful. 2) The fact that few codebases use it means it's riddled with compiler bugs even if you are exceedingly careful. Just look at how many times Rust has had to disable noalias due to LLVM bugs and regressions.
- 5y ago
- ogogmad 5y agoAre things like higher order functions and closures relevant features for Fortran programmers? This is an open-ended question. [edit] Just to be clear, I don't think Fortran has these.
- milancurcic 5y agoIt's limited. You can pass functions as arguments to other functions. You can't return a function as a function result.
- ogogmad 5y agoI was asking whether these are worth having in a future version.
- milancurcic 5y agoOops, I missed that. I would enjoy this feature but I think it's unlikely to be considered by the committee. As far as I'm aware it hasn't been discussed.
- adgjlsfhk1 5y agoSpecifically, Fortran's type system isn't nearly advanced enough to usefully support this type of feature well. Higher order functions are really useful, and if you want them, you should use a different language.
- ogogmad 5y agoWhat kind of editor support does Fortran have? I think a language is more than just a language as such, and the surrounding environment is at least as important if not more. I've used things like Mathematica, RStudio and Matlab, as well as Java IDEs, and these make all the difference.
- wiremoons 5y agoGood timing for your question as there is a poll going on at the moment about editors used with Fortran, on the Fortran Lang community Discourse here: https://fortran-lang.discourse.group/t/code-editors-ides-used-for-fortran/3139 https://fortran-lang.discourse.group/t/code-editors-ides-use... But the quick answer is that people programming in Fortran use the usual editors - Visual Studio Code, Emacs, Vim, CLion, etc.
- semi-extrinsic 5y agoThe tooling around Fortran is very similar to C. The debuggers are the same, you can typically use ctags of some sort for navigating between subroutines etc. across all files, and then you can add in a compiler-editor integration that checks for syntax errors at every save. There are also a couple of Fortran REPLs out there, the most promising is probably LFortran which is only in alpha stage of development but has Jupyter integration and will be the next cool thing I think.
- kergonath 5y agoI tend to use TextMate on Mac or SublimeText on other platforms. Fortran also is usually very close to C, and most standard debuggers like ten or lldb (even when LLVM had no Fortran front-end) can be used without problems. It’s a bit barebones compared to recent IDEs, sure. What I would like in particular is better refactoring and static analysis tools (though the lack of the latter is mitigated by the strong type system and some very good compilers like NAG). There is no real equivalent to RStudio or Matlab.
- ratboy666 5y agoBut... Matlab was originally written in FORTRAN ("easy access to... LINPACK and EISPACK..."). Written by Cleve Moler, distributed by Jim Kweeder. May 25, 1982. 7852 lines of FORTRAN 66 (for the version I have). "With proper use of overlays, it is possible run the system on a minicomputer with only 32K bytes of memory." -- Cleve Moler Fred Weigel
- hatmatrix 5y agoModern Fortran is beautiful and I love coding in it. However, my understanding is that its main focus is on array computations. Now with hierarchical data structures and graphs becoming ever pervasive, I wonder if Fortran will ever try to compete in this space (when these higher-order concepts are integrated into domains of Fortran's past dominance in numerical simulation).
- noobermin 5y agoHonestly, it really shouldn't, at least IMO. Where may be once it was used for other things, today it's essentially a DSL of some sort for the numerical computations you specify. It doesn't need to be used for a game engine (game engines can go ahead and call fortran code as they might).
- xioxox 5y agoAs a comparison, I have to program in Fortran in my day job, and I really hate it. On the negative side, text handling is really horrible (even with the new variable length strings), there are very few good libraries outside of numerics, a lack of type-safe generic data structures (like C++'s STL), buggy compilers (my code has some horrific pointer hopping to work around gfortan's bugs), the C-Fortran interface is horrible to use and there's little good documentation on the language. The positive things are the multidimensional arrays and slicing, and the modules.
- _0w8t 5y agoHierarchical data structures are bad for CPU caches, see, for example, references in [1] how various data-oriented programming techniques try to avoid them. From that point of view Fortran may be even more relevant for high-performance computing now than even 10 years ago. [1] https://en.m.wikipedia.org/wiki/Data-oriented_design https://en.m.wikipedia.org/wiki/Data-oriented_design
- freemint 5y agoB-Trees are very much not bad for CPU caches,neither are tries. Generalizations like this are harmful.
- mrtweetyhack 5y ago
- mcnrb 5y ago
- jordemort 5y agoThe fact that “The State of Fortran” is a paper on arXiv instead of a blog post actually says a lot about the state of Fortran.
- urda 5y agoWhat value does your suggestion have here? I think you might be placing way too much value on a blog post.
- agucova 5y agoThis only speaks to the academic nature of Fortran, and there's nothing wrong about it.
- kergonath 5y agoWhat do you mean? It’s a paper written by several people on the standard committee of who contributed to the draft standard, on which blog would they put it? Traditionally, these things were published in ACM SIGPLAN Fortran Forum (or on NAG’s servers for historical reasons). Arxiv is really natural, given the direction scientific and technical publishing is taking. This is a heavy duty language used by scientists and people like mechanical and nuclear engineers. Not the latest JavaScript framework or full stack doodad from Google.
- shadowofneptune 5y agoOh yeah, a blog. Really keeping up with the times there compared to a paper.
- pjmlp 5y agoIndeed, it isn't something that is only cool for a month or to be embraced by magpie developers.
- buescher 5y agoI read that as "with all the good and bad that implies". That others didn't... well that's Fortran for you. Or maybe just hackernews.
- 5y ago
- freecodyx 5y agoTechnically, all programming languages are constrained by what a machine can do (the cpu architecture), to me all programming languages are transpilers, just chose the language that fit best your usecase, and that will allow you to write correct code easly, but always keep in mind that regardless of the language you’re using, you’re still constrained by same machine architecture,
- Silamoth 5y agoVery interesting paper! It's cool to see that Fortran is still evolving. I've been considering learning it (when I have the time) because of its use for numerical computations and parallel processing. I feel like there's been a big push towards general-purpose languages like C++. However, I'd love to get a better feel for what it's like to program in a language specifically designed for your use case. The closest I've experienced is MatLab, but I feel like MatLab is designed more for scientists and engineers who need to perform some calculations but don't want to actually learn how to program, not for professional programmers working on scientific computation.
- pwr-electronics 5y agoThe strengths of Matlab is that it's a domain-specific glue language with a domain-specific interactive environment. It's great if the benefits to you are worth the specificity and investment. Otherwise, something like Python might suit your needs better. Either way, there's still often at least some native code you have to write and wrap. That's where a professional programmer might get involved. But probably more often than not, it's the engineers and scientists themselves.
- zozbot234 5y agoI don't think there's much in Fortran that's still unique or "specifically designed" for numerics compute. General purpose languages reached parity with Fortran a long time ago. And "general purpose" typically wins anyway because it has the larger and more diverse ecosystem.
- leephillips 5y agoMost of them did not reach parity, at least not in performance. The fast languages are C, C++, Fortran, and Julia. Those are the only ones used for teraflop computing. Fortran is a great tool for scientific computing, but for new projects, where you are not extending an existing code base, Julia will be much more fun in every way.
- Asooka 5y ago
- zabzonk 5y agoI've always liked Fortran - one big project I wrote in Fortran 77 was an Intel 8080 simulator that was used for teaching at the Polytechnic I worked for. The original code was on a Dec10, but I ported it to a VAX and an IBM 4381 in a couple of days. It's an easy language to get to grips with, but the users somewhat less so. At one point doing consultancy, I came across people declaring variables like I1,I2,I3,I4 to IN where N was a large number. I asked "why?" and they said "we might need them" - Fortran programmers will see at least two reasons why this is daft.