15 ms·
Fortran
- martyvis 3y agoTIL "Fortran is a natively parallel programming language". I guess we aren't talking about FORTRAN 77 then.
- zabzonk 3y agothings have advanced a little since then - speaking as someone that really liked f77 :-) but even way back when i think there were parallel options, if your hardware could support them.
- jeanlucas 3y agoMakes sense, somehow I assumed things stayed the same. Turns out I only know fortran from the memes about it.
- kergonath 3y agoThe important thing is that old programs and libraries keep working. Some features were removed from the standard, and modern compilers are much better at detecting errors (and are much stricter than they used to be by default), but all of them have a switch to make them work with random codes from the 1980s. There is an awful lot of new features on top of that (things like first-class multidimensional arrays language-level parallelism, object orientation, modules, etc), but old software keeps working.
- reacharavindh 3y agoThat was my first thought as well. I’ve had researchers running an in-house built Fortran program in the field of genetics on our HPC clusters, such that they’d run their task as 1000s of jobs in the cluster each operating on a small segment of data instead of a single program making use of as many cores available in the system. Perhaps, newer Fortran would’ve done it, but the old software was still reliant on old Fortran.
- pletnes 3y agoNew and old Fortran is incredibly compatible. Chances are you can rewrite or refactor to add new features directly into or along the old code. If you know what you’re doing.
- m_mueller 3y agoFortran 90+ has strong support for parallel programming, including MPI, OpenMP, CUDA and OpenAPI (for GPU).
- mseepgood 3y agoWhy would we be talking about FORTRAN 77 in 2023?
- jki275 3y agoBecause there are still codebases in active use and development in FORTRAN 77.
- kergonath 3y agoThis is an allusion to coarrays, which is a feature from Fortran 2008. It is actually very neat and very nice to program for. There is a C thing that took inspiration from it: https://en.m.wikipedia.org/wiki/Unified_Parallel_C https://en.m.wikipedia.org/wiki/Unified_Parallel_C .
- marshallward 3y agoDo concurrent loops can also be parallelized.
- kergonath 3y agoYes, a lot of things can be parallelised with OpenMP or MPI, just like in C/C++. These extensions and libraries are not core language features, though.
- deleted 3y ago[deleted]
- deleted 3y ago[deleted]
- marshallward 3y agoVery true, and it opens the door to new optimizations which are not possible when going through a library (at least in the case of MPI).
- pklausler 3y agoDO CONCURRENT is not a parallel construct. It is a serial loop with arbitrary ordering of iterations, and limitations on data accesses that were intended to ease parallelization but turned out to be incorrect.
- marshallward 3y agoI agree that it is not a parallel construct. But it can nonetheless be parallelized if certain criteria are met.
- zabzonk 3y agofortran itself is pretty easy to learn - the stuff people usually have problems with are things like linking with external libraries, job control and the execution environment generally. meh, same with most languages, i suppose.
- m_mueller 3y agoQuoting what I wrote a couple of months ago in another thread, regarding the advantages of (Modern) Fortran vs. C/C++: """ Just an example on how to declaring a couple of input float pointers in a fully optimized way, avoiding aliases and declaring it readonly (if I remember correctly, it's been a few years: Fortran: real(32), intent(in) :: foo, bar, baz C: const float *const restrict foo const float *const restrict bar const float *const restrict baz of course what happens then is that people will do a typedef and hide it away... and then every application invents its own standards and becomes harder to interoperate on a common basis. in Fortran it's just baked in. Another example: multidimensional arrays. In C/C++ it either doesn't exist, is not flat memory space (and thus for grid applications very slow), or is an external library (again restricting your interop with other scientific applications). In Fortran: integer, parameter :: n = 10, m = 5 real(32), dimension(n, m) :: foo, bar, baz Again, reasonably simple to understand, and it's already reasonably close to what you want - there are still ways to make it better like memory alignment, but I'd claim you're already at 80% of optimal as long as you understand memory layout and its impact on caching when accessing it (which is usually a very low hanging fruit, you just have to know which order to loop it over). """
- deleted 3y ago[deleted]
- iLoveOncall 3y agoThis is such a disingenuous exemple. You declare all 3 variables on the same line in Fortran but not in C despite it being supported. In any case, syntaxic sugar is irrelevant.
- m_mueller 3y agoYes I do, because in C you do have to repeat pointer declarations and their modifiers per variable - there is no clean way to separate the variable name declarations from their properties Edit: disagree also on sugar being irrelevant. It’s all about where you guide non engineers towards when they learn it. Domain scientists can be astonishingly productive in Fortran thanks to that - to achieve the same in e.g. C++ takes a lot more effort in training and establishing best practices, libraries etc.
- AlbertoGP 3y agoI can recommend this recorded live stream to get an impression of what happens when trying to use Fortran without previous experience: “Learning Fortran in 2023” https://www.youtube.com/watch?v=PvUQndB8R9s https://www.youtube.com/watch?v=PvUQndB8R9s And here is the reaction of the fortran-lang.org people to that and later streams where he went on to implement tic-tac-toe in Fortran using for the GUI the C library raylib (https://www.raylib.com/ https://www.raylib.com/), for which he made his own bindings live on screen: https://fortran-lang.discourse.group/t/tsoding-on-fortran/6102 https://fortran-lang.discourse.group/t/tsoding-on-fortran/61...
- spookie 3y agoVery understanding people from what I see. I might pick Fortran to do my course exercises this year alongside the required use of Python. This might be interesting, and worthwhile.
- reikonomusha 3y agoVery recently, Los Alamos National Lab published a report An evaluation of risks associated with relying on Fortran for mission critical codes for the next 15 years [1]. In their summary, they write: <quote> Our assessment for seven distinct risks associated with continued use of Fortran are that in the next fifteen years: 1. It is very likely that we will be unable to staff Fortran projects with top-rate computer scientists and computer engineers. 2. There is an even chance that we will be unable to staff Fortran projects with top-rate computational scientists and physicists. 3. There is an even chance continued maintenance of Fortran codes will lead to expensive human or financial maintenance costs. 4. It is very unlikely that codes that rely on Fortran will have poor performance on future CPU technologies. 5. It is likely that codes that rely on Fortran will have poor performance for GPU technologies. 6. It is very likely that Fortran will preclude effective use of important advances in computing technology. 7. There is an even chance that Fortran will inhibit introduction of new features or physics that can be introduced with other languages. </quote> In my view, a language is destined for being a "maintenance language" if all of these are simultaneously true: 1. There is a dearth of people who know the language well. 2. Few people are opting to learn it in their free time, and/or seek it out for a job. 3. Companies do not seriously invest in training in learning the language. 4. Companies don't pay enough to convince an engineer to use it. who otherwise loves using other languages and has better prospects with them. I've experienced unique challenges in hiring Lisp programmers, but the fact it remains sufficiently interesting to enough software engineers (who are usually good programmers) has been a boon, and likewise providing space to learn it helps even more. Fortran though is teetering on its historical significance and prevalence in HPC. Aside from the plethora of existing and typically inscrutable scientific code, I'm not sure what the big iron imperative language offers over the dozens of other superficially similar choices these days, except beaten-path HPC integration. Scientists are more and more writing their code in C++ and Python—definitively more complicated than Fortran but still regarded as premier languages for superlative efficiency and flexibility respectively. Julia has had a few moments, but (anecdotally) it doesn't seem to have taken off with a quorum of hardcore scientist-programmers. [1] https://permalink.lanl.gov/object/tr?what=info:lanl-repo/lareport/LA-UR-23-23992 https://permalink.lanl.gov/object/tr?what=info:lanl-repo/lar...
- throwaway_woxx7 3y ago
- ulrischa 3y agoI have not much experience with fortran but I see it as something like cobol - a relict of old times.
- galangalalgol 3y agoI don't think you are getting downvoted because people think you are wrong. Both cobol and fortran are still in widespread use, but primarily for maintained projects that are not well understood even though they still work well. You are getting downvoted because, unlike cobol, plenty of people still like fortran. It isn't a bad language at all, it has had meaningful updates for modern HPC. So people are sad to see it go.
- ulrischa 3y agoYes this is exactly what I think. Not nice getting downvote for that. In the future I shut my mouth
- xmcqdpt2 3y agoIt's more like C or C++. Old, yes, but actively developed by a standards committee. In terms of features, it's definitely more modern than C, with generics, move semantics for pointers etc.
- pklausler 3y ago“Actively” is debatable. New revisions arrive at roughly 5-year cadence and some (esp. 2018 and 2023) have been pretty small updates. And implementation uptake since F’95 has been spotty and buggy, so new features aren’t as portable as they should be, standard or not. (See https://github.com/klausler/fortran-wringer-tests https://github.com/klausler/fortran-wringer-tests for some examples.)
- tgv 3y agoOff topic: it's a bit shocking to see that a language like FORTRAN, with its enormous history, has a web page like that of Nim or Vale. It doesn't seem to be an official one, or is it?
- pletnes 3y agoMy impression, having programmed quite a bit of Fortran, is that it’s not official at all. Also the language is maintained in a completely different way (standards Committee) so it feels off.
- kergonath 3y agoIt is not official, but several people involved are in one of the standard committees. There is quite a lot of discussion on the Discourse group ( https://fortran-lang.discourse.group/ https://fortran-lang.discourse.group/ ), which also involves both committee members and ordinary developers.
- pklausler 3y agoAnd lots of crazy trolls. Not recommended.
- kergonath 3y agoYes, there is a bit of that, unfortunately. Which is a shame because there are very nice people too.
- certik 3y agoYes, there are many nice people there and we are doing what we can to moderate the Discourse so that we can all have a nice place to discuss.
- certik 3y agoPeter, I am sorry that some users drove you away, possibly myself included. I am personally doing what I can to keep the Fortran open source (and commercial) community together, I have done this before (e.g., with SymPy), and the Fortran community can be very tough in some of the responses. I know most of the people in person, and they are all very nice people. We regularly address unconstructive behavior. If you or anyone has some feedback how we can run things better, please let me know (you can email me at ondrej@certik.us).
- deleted 3y ago[deleted]
- gorenb 3y agoI'm confused why you would post this, and I'm even more confused why it would make the front page. Fortran is a dying programming language, and even if they have a website now, they are still a dying language. In essence: Fortran, please die more quickly.
- bobim 3y agoDid you take your car this morning? A bike? A plane recently? All these were designed with industrial finite elements codes that are programmed in Fortran. Radioss, Ansys, Abaqus, LS-Dyna, Code_Aster… Fortran is all around you, in your phone that has been designed to survive drop test, the solder creeping of its BGAs, the thermals… Fortran is not dying, it’s supporting your standard of living.
- sheepshear 3y agoWhat sort of experience did you have with fortran that led you to feel this way?
- TheRealKing 3y agoI guarantee, the answer is "no experience".
- nologic01 3y agoFortran is in a very strange position in the current tech landscape. There is a race of sorts going on, to simplify and commoditize high performance computing in the post-Moore's era. This means enabling things like easy GPU programming, easy multi-core programming, easy "number crunching" etc. Historically this was the stuff of esoteric HPC (high performance computing) pursued by highly specialized computational scientists etc. (read -> an important but non-economic domain that subsisted largely on government funds). Yet suddenly the same arcane HPC is effectively also the domain of "AI" and the associated planetary hyperventilation. Now all sorts of modern initiatives and language ecosystems aim to reposition to gainfully intermediate that AI revolution. Python was the scripting language that somewhat unexpectedly enabled all this, but now its warts are under the microscope and people think of various alternatives (julia), supersets (mojo), newcomers like rust etc. But that race is definetely not settled and it might not be so for quite some time. The requirements are highly non-trivial. As far as taking part in this race, Fortran seems to have missed not one but several boats. Yet the fact remains that it was a language designed for number crunching and evolved as language for HPC, with parallel computing features (since F90) etc. It combines easy to read imperative numerical code with near optimal computational performance. Its like a former world champion in a sport that was fell out of favor for a long time but is now unexpectedly back in vogue. So the question is whether the champ can get back into shape or make room for new contenders :-)
- certik 3y agoVery well put. Also a subset of Python: https://lpython.org/ https://lpython.org/, and it shares the internals with https://lfortran.org/ https://lfortran.org/, both run at the same speed. If you have any feedback, please let us know.
- ecshafer 3y agoI’ve done computational physics and used Fortran. There are some warts, like line length requirements. But for actual math, Fortran takes the cake
- milancurcic 3y agoAnd the line length limit will soon (with Fortran 2023 later this year) practically go away--a hard limit of 10,000 characters.
- sseagull 3y agoFortran is unpopular because programming is fashion driven. That is basically all. It is very suitable for it’s domain, but it’s old. Programmers have no attention span and love new and shiny things. They would rather reimplement known solutions in new languages rather than struggle with new problems. So perfectly serviceable code and languages get left behind. “He who knows only his own generation remains forever a child.“ — Alan Kay, quoting Cicero.
- userbinator 3y agoPopular culture is also fashion driven, and most programmers are not immune to that.
- thanatropism 3y agoThis is unintuitive, but modern fortran is a shorter jump from Matlab than Python. The greatness and wretchedness of Python is "pythonicity". It's very hard to miss the mark with Python (all things considered: life is finite, most people are more like analysts than developers, analysts deliver generally more value per hour than developers, Rust is hard to learn) but you basically need to submit to the "Pythonic" brainwashing -- which includes "anything performance-critical should be written in $fast_lang and then used from Python; but almost nothing is perf critical, and most of what's conceivably needed already exists".
- Bostonian 3y agoThere is an element of that, but C and C++ are not young either and have retained more of their peak popularity.
- spookie 3y agoI would wager Fortran is more reliant on a set of users who aren't as familiar with programming as C/Cpp people are. I assume it's easier to sell a language like Python to mathematicians, than it is for people in Computer Science. These are all assumptions on my part, and my own biases may have affected my understanding of the problem.
- deleted 3y ago
- mrweasel 3y agoOne thing I noticed on the page: > Fortran is a relatively small language that is surprisingly easy to learn and use I suppose you could say the same of C. C is also a small language, but if you don't know your way around the libraries and tooling you're going to have a bad time. I wonder if the same is true for Fortran.
- bobajeff 3y agoI suppose that really true for Windows users that only know of msvc. My first time using it was via Linux and gcc and didn't really have any troubles. It's even better today with vscode and clangd.
- goerz 3y agoTrue, but C and Fortran have very different semantics that make them suitable for very different fields. In particular, C does not have great semantics for linear algebra. Also, C has many footguns due to its use of pointers, while Fortran has virtually none. You still need to learn the tooling, but the tooling is actually pretty similar for Fortran/C/C++ (same compiler/linker toolchain). Libraries aren't that much of a thing in Fortran, but to the extent that they are, this again is similar to C/C++.
- aqme28 3y agoI am currently working on a project trying to convert some numerical linear algebra from Fortran90 into Python and was frankly shocked at how much more performant some relatively naive Fortran is, even over using Numpy/Scipy for matrix operations. Orders and orders of magnitude faster. No, I still don't totally understand why.
- moelf 3y agosorry but maybe give Julia a try?
- thornewolf 3y agohttps://github.com/thornewolf/CFC-Fortran https://github.com/thornewolf/CFC-Fortran This is somewhat of a link dump since the code is definitely too hard to interpret for someone not familiar but this is me converting some fairly performant Fortran code to python w/ numba at only a 1-2% performance penalty.
- ecshafer 3y agoI would absolutely expect python to perform orders if magnitude slower. Even optimal python calling numpy is going through multiple levels of abstraction copying data around. Fortran is raw operations, compiled and with the data packed together.
- deleted 3y ago[deleted]
- 3y ago
- dannyz 3y agoBase Fortran has a lot of advantages for scientific programming over other languages, but I think there are two factors that are contributing to it's unpopularity: 1. Models are increasingly becoming much larger projects where flexibility, configuration, setup, are just as important as the actual number crunching that's done. These aren't areas that Fortran is known for. 2. The existence of libraries like Eigen for c++ provide most, if not close to all, of the advantages that Fortran gives for number crunching.
- deleted 3y ago[deleted]
- riffraff 3y agoI wish these new languages would have some example code on their homepage! ;)
- blippage 3y agoConsistently separating words by spaces became a general custom about the tenth century A.D., and lasted until about 1957, when FORTRAN abandoned the practice. -- Sun FORTRAN Reference Manual
- thanatropism 3y agoI wish there were more serious studies on "Matlab risk". There's a lot on $old_lang risk already, and Excel risk is now a serious thread of research, but many in academia (and very possibly greybeards in industrial R&D) just won't budge from Matlab. So e.g. all the codes from my thesis are in Matlab because my advisor wouldn't Python. Matlab in theory has OO, but it's very slow and who bothers to verify that? So practically everything is matrices and there's very little "semantic expressed in code itself" (to paint issues with a broad brush). Also matrix calculations can get botched numerically, particularly matrix exponentials, but the whole culture (that I can't even expunge from my own thinking) is that I have a theorem so tests schmests.
- Q6T46nT668w6i3m 3y agoThere’s been numerous articles in nearly every field of science about this!
- zild3d 3y agomatlab is incredible for "I have some data, I want do a bunch of calculations and then spit out nice plots". It's why matplotlib is a thing. But not at all well suited for OO / building larger software applications / CI & testing, which is partially at least why the former is the case
- deleted 3y ago[deleted]
- cozzyd 3y agoMatlab is great for a lot of things, though it's not really a great general purpose language. Its main problem is that it's not free (though octave exists, obviously), which limits interoperability. Octave can trivially be embedded in C++ and Python; if it was easier to do that with Matlab I wonder if numpy would have ever existed...(after all, numpy is essentially a port of Matlab semantics to Python... most Python numeric programmers are unwittingly basically writing Matlab already...).
- TheRealKing 3y ago
- endymi0n 3y agoAs to the best of my understanding, Fortran still offers some "fringe", but very important low-level optimization potential, specifically in the areas of pointers and aliases that are important to linear algorithm packages, which are apparently still hard to impossible to recreate in C. Semi-informed, but serious question: Isn't there any other modern, high-level language that can offer these kinds of optimizations? Preferably in a safe kind of way? I'm still struggling to understand how Fortran still stays relevant and what could possibly succeed it as a migration (or transpilation?) target with equivalent speed but superior maintainability and safety.
- Q6T46nT668w6i3m 3y agoIt’s true that Fortran played a fundamental role in the area of numerical linear algebra but most of the linear algebra packages you’re likely using today were written in C or C++. Why is Fortran relevant? Because of that aforementioned history. However, Fortran’s use in numerical software has steadily been declining (e.g., look at the past two decades of TOMS articles).
- owlbite 3y agoMost of the BLAS implementations are in C/C++/ASM, as they're the small performance critical part. The LAPACK layer above that which calls the BLAS to do the heavy lifting is a much much bigger target, and aside from the most commonly used routines (cholesky, svd) most vendors just ship the FORTRAN code (possibly in automatically converted to C form).
- osigurdson 3y agoI’m wondering if Mojo will become the next Fortran or the next Python.
- certik 3y agoIf you like both Python and Fortran, checkout LPython: https://lpython.org/ https://lpython.org/, which shares internals with LFortran (https://lfortran.org/ https://lfortran.org/), thus delivering exactly the same performance.
- divbzero 3y agoWhen I learned FORTRAN, I recall each line of code was prefixed by a numeric label. From the “Hello, World!” presented on the website, it looks like that’s no longer the case in modern FORTRAN? program hello ! This is a comment line; it is ignored by the compiler print *, 'Hello, World!' end program hello https://fortran-lang.org/en/learn/quickstart/hello_world/ https://fortran-lang.org/en/learn/quickstart/hello_world/
- pklausler 3y agoLabels are no more and no less optional than they ever were; any statement that starts a line may be labeled. Fortran has had IF THEN / END IF and DO / END DO since F'77, so the need for statement labels has greatly decreased. You still see them on FORMAT statements, of course.
- Alifatisk 3y agoMy professor have mentioned Fortran plenty of times and its heavy usage in masssive computations, that's what it is good at and deserves more attention. When visiting the link, I expected some website written in boring plain text describing its history and docs BUT I was wrong, what a modern website for such a old language. Well done!
- jhallenworld 3y agoI've been a bit immersed in pre-Fortran-77 (so FORTRAN-IV and FORTRAN-66). It was an interesting time: FORTRAN was the most standard language, so people used it for things like compilers. An example I have is Motorola's 6800 assembler, which was delivered as a tape for various common machines of the day: http://www.bitsavers.org/components/motorola/6800/cross-assembler/6800_xasm.for http://www.bitsavers.org/components/motorola/6800/cross-asse... But this was before FORTRAN had strings.. or even bit-wise operators.. But you could read an input line into an array of integers. Then to read each character from this array, you used integer multiplication and division to perform shifting and masking. Although in this version, I can see calls to assembly language helper functions. Note the Hollerith constants.. (no strings).
- dang 3y agoRelated ongoing thread: Lfortran: Modern interactive LLVM-based Fortran compiler - https://news.ycombinator.com/item?id=37295144 https://news.ycombinator.com/item?id=37295144 - Aug 2023 (25 comments) (other thread is arguably better because less generic)
- comonoid 3y ago“I don't know what the language of the year 2000 will look like, but I know it will be called Fortran.” —Tony Hoare I think it should be corrected to year 3000.