Live data from Hacker News

Why physicists still use Fortran (2015)

moreisdifferent.com

111–120 of 300 posts

Re: Why physicists still use Fortran (2015)

#111
post #100

One of the key points of the article is that there is a lot of legacy code written in Fortran. As a former high energy physicist, I have an anecdote here that some people might find interesting. There was a library written in Fortran called CERNLIB which included a broad variety of miscellaneous numerical algorithm implementations ( e.g. minimization, integration, special functions, random number generation) [1]. I c…

Getting locked to a particular compiler isn't usually a quality of the language, but the development team. It happens to all languages where the underlying platform remains fixed a site, it evolves into every capability of the instance, not the spec. This is why it is important to have platform diversity from the start. Run your unit tests on at least two toolchains, hopefully on at least two different distros if not…

One good example of this is to run your code on both 32 bit, 64 bit, big endian and little endian machines of all those combinations. That works pretty good as a way to keep you on your toes with respect to portability.

Re: Why physicists still use Fortran (2015)

#112

"Professors usually have this legacy code on hand (often code they wrote themselves decades ago) and pass this code on to their students. This saves their students time, and also takes uncertainty out of the debugging process." This is so true. I'm a PhD student in physics using Fortran for pretty much that reason. At the start of my PhD, in response to my supervisor telling me I should learn Fortran to modify our cu…

"Within a month of his arrival, Randy solved some trivial computer problems for one of the other grad students. A week later, the chairman of the astronomy department called him over and said, “So, you’re the UNIX guru.”

"At the time, Randy was still stupid enough to be flattered by this attention, when he should have recognized them as bone-chilling words. Three years later, he left the Astronomy Department without a degree, and with nothing to show for his labors except six hundred dollars in his bank account and a staggeringly comprehensive knowledge of UNIX."

– Neal Stephenson, _Cryptonomicon_ (p. 78). HarperCollins.

Re: Why physicists still use Fortran (2015)

#113

"Professors usually have this legacy code on hand (often code they wrote themselves decades ago) and pass this code on to their students. This saves their students time, and also takes uncertainty out of the debugging process." This is so true. I'm a PhD student in physics using Fortran for pretty much that reason. At the start of my PhD, in response to my supervisor telling me I should learn Fortran to modify our cu…

Now you need to do a follow on study to see how much science the 'rival' group does with a more modern codebase than your 'legacy' group does. Would you know if there are enough examples of two groups who have diverged like this to get meaningful (as in statistically significant) results on the cost benefit of porting / not porting?

[deleted]

Re: Why physicists still use Fortran (2015)

#114
post #94
post #88

Earlier quoted context omitted.

> Now you need to do a follow on study to see how much science the 'rival' group does with a more modern codebase than your 'legacy' group does. I would guess that a C++ codebase written by PhD students, not by seasoned C++ experts, is more complicated and much slower to debug, than a corresponding Fortran codebase.

Well, that Fortran codebase probably also was written in large parts by PhD students, not export Fortran programmers.

Fortran is a much simpler and safer language than C++. And faster to learn. Fortran is even somewhat simpler than C or Java, whereas C++ is probably the most complicated language in the known universe.

So especially in the hands of non-experts, Fortran should produce less bugs.

Re: Why physicists still use Fortran (2015)

#115

"Professors usually have this legacy code on hand (often code they wrote themselves decades ago) and pass this code on to their students. This saves their students time, and also takes uncertainty out of the debugging process." This is so true. I'm a PhD student in physics using Fortran for pretty much that reason. At the start of my PhD, in response to my supervisor telling me I should learn Fortran to modify our cu…

>> Professors usually have this legacy code on hand (often code they wrote themselves decades ago) and pass this code on to their students

So cut-n-paste code. The students are running code that they don't really know what it does, it might not even be correct...it's like StackOverflow in academia.

Re: Why physicists still use Fortran (2015)

#116

Earlier quoted context omitted.

Fair enough then, I suppose that in C you have to do something like that if you want both that your matrix size is decidable at runtime, and to be able to index it with m[x][y] rather than some function.

That’s not strictly true. You can malloc an m*n sized array and then assign to another array the pointer to the head of each column, allowing you standard style indexing.

If you do that, every access will actually dereference that pointer and won't be able to optimize the standard style indexing to a multiplication and addition, so this still carries a significant performance cost.

Re: Why physicists still use Fortran (2015)

#117
post #114
post #94

Earlier quoted context omitted.

Well, that Fortran codebase probably also was written in large parts by PhD students, not export Fortran programmers.

Fortran is a much simpler and safer language than C++. And faster to learn. Fortran is even somewhat simpler than C or Java, whereas C++ is probably the most complicated language in the known universe. So especially in the hands of non-experts, Fortran should produce less bugs.

Funny as hell. Perl, though.

Re: Why physicists still use Fortran (2015)

#118
post #73

Earlier quoted context omitted.

20,000 lines of code really doesn't seem like that much. I probably output that much in about 2-3 months of biomedical research so there has to be more to it than that.

20,000 lines of code casually churned out in 2-3 months will be a nightmare to a) understand, b) maintain, much less to rewrite...

It sounds like he’s talking about scripts generated for research, rather than code for components intended to be persistent.

Re: Why physicists still use Fortran (2015)

#119

Earlier quoted context omitted.

David Baker's Rosetta code, which made him a pile of money, is IMO a spectacular example of craptastic C++ written by people who really didn't understand C++ but didn't let that deter them from using every single feature of the language, badly. Some years back we tried to port it to CUDA but there were so many levels of indirection, dereferencing, and virtual functions that it was nearly impossible to make any progre…

That's the whole trick. Good code makes complex stuff look simple. Bad code makes simple stuff look complex.

That quote should be the metric by which code/languages are judged.

Re: Why physicists still use Fortran (2015)

#120
post #8

Physicists / engineers / mathematicians are the target audience for Fortran. For heavy number crunching it's still quite good, it's people trying to use it for other stuff that causes problems. That said, Fortran really is dying. Scientific code is much larger nowadays with more functionality and scientists want to do everything in one language. C++ and Python are taking over.

Vast majority of scientists is not able to write idiomatic Fortran, yet alone idiomatic C++. Scientific C++ code that didn't have an oversight from a professional C++ developer will be always horrible. Scientific Fortran code written without such oversight can sometimes be bearable. This is perhaps the main advantage of Fortran.
Post reply on HN