3 ms·
IIRC, most people who use Fortran use it because there are extremely specialized physics libraries (or astronomy, or chemistry, and so on) that were probably wr
by vanderZwan 7y ago
IIRC, most people who use Fortran use it because there are extremely specialized physics libraries (or astronomy, or chemistry, and so on) that were probably written three to four decades ago by an extremely intelligent PhD student who lacks a proper programming background.
Which suggests that the biggest source of horror would be that most code you'll come across was written by a non-programmer who is intelligent enough to translate an extremely complicated and niche problem domain into very clever and completely un-idiomatic code, who likely was unable to read their own library mere months after graduating because most PhDs don't fully understand their own thesis within months after graduating.
- yiyus 7y agoFor sure, there are a few cases like the one you mention (I personally work with this kind of code in a daily basis), but that's not the reason most people use Fortran. There are many libraries with a level of robustness and performance that you won't find anywhere else, there are highly optimized compilers, and it is the standard language in many fields. It's also quite safe for non-programmers. Those non-programmers write complex algorithms, but the code itself is not "clever and completely un-idiomatic". Most often, it is quite naive, just a series of formulas one after the other. You will find very long subroutines, bad names, some obvious inefficiencies, and maybe some spaghetti, but nothing to be afraid of.
- rossdavidh 7y agoMy understanding from supercomputing center folks is that, if you just want to run these half a dozen equations for a bajillion nodes in parallel as fast as possible, it is still the best language for the job. Not speaking from personal experience, though.
- 6gvONxR4sf7o 7y ago"Idiomatic" depends on language and domain and era and purpose. Consider the dgemm method in BLAS (double general matrix multiply, powers all sorts of modern code like numpy). It's such a workhorse, used by everything under the sun. But it does one thing. It multiplies two matrices of doubles. You're going to want to optimize the hell out of it and ensure it's correct, then never revisit it. It's been around (in the exact same form as far as I can tell) nearly as long as I've been alive. The right, idiomatic code for that is going to look different from the right, idiomatic code for something at the business logic level that changes every 6 months. It does it a disservice to shit on it like you are.
- aswanson 7y agoYou're going to want to optimize the hell out of it and ensure it's correct, then never revisit it. Balderdash. Claptrap. Codswallop. Poppycock. What if you want to revisit it to make it run on parallel processors? Optimize it for a new CUDA architecture or caching scheme? A new instruction set that handles sparse matrices better? Code lives forever, at every level.
- 6gvONxR4sf7o 7y agoFor this kind of linear algebra, you're going to have a different routine for a sparse matrix (dcoomm) or a symmetric one (dsymm) or a triangular one (dtrmm) or symmetric banded matrix vector product (dsbmv) or whatever. Hopefully those are separate functions from your dense one (dgemm), which is what I'm talking about. You'll also have a different function for CUDA (which exists in cuBLAS) than for multi-core (in ScaLAPACK? PLASMA?) than for single-CPU (in BLAS), which is what I'm talking about. General matrix multiply in this sense isn't "all the different matrix multiplies." It's a function with a very specific purpose, and yeah you don't really need to revisit it every decade. Either way, it's not that much horror: http://www.netlib.org/lapack/lapack-3.1.1/html/dgemm.f.html http://www.netlib.org/lapack/lapack-3.1.1/html/dgemm.f.html
- greglindahl 7y agoI like it when some of my colleagues use Fortran, because their code in other languages is even more horrible. BTW, the 'non-programmer' you seem to not think much of probably used an RPN calculator. Food for thought.
- vanderZwan 7y ago> the 'non-programmer' you seem to not think much of If what I wrote lead to that as your main take-away, then I apologize for expressing myself badly, because nothing could be further from the truth! I studied physics myself at one point, and base this on conversations with friends who (unlike me) didn't drop out. Specifically, those who were asked by their professor to update old libraries during their PhD thesis.
- beambot 7y agoCould be worse... Matlab?