6 ms·
This is the first time that I have ever encountered someone who used Fortran for something other than earth sciences related modeling. Thank you, now I have a
by fhood 9y ago
This is the first time that I have ever encountered someone who used Fortran for something other than earth sciences related modeling.
Thank you, now I have a second example the nest time someone claims "nobody used fortran anymore".
- azag0 9y agoI’ll say it again. If the natural language of your problem domain is linear algebra and/or matrices (tensors), Fortran is the perfect tool.
- kutkloon7 9y agoWhy is it better than C(++) for this?
- gjjrfcbugxbhf 9y agoBecause for example Fortran has multi dimensional arrays as first class entities. C does not. Yes you can get the same speed in C - yes you can do the same things in C but you can do them with simpler code easier to reason about code in Fortran.
- atemerev 9y agoModern Fortran is high-level enough to pass for MATLAB, has full vectorized operations support, but in many cases faster than C. What's not to like?
- shoo 9y agoHistorically i believe Fortran language had stronger assumptions that variables arent aliases for the same memory. This means that the compiler can be more aggressive (than e.g. C) in terms of the generated code as it doesnt have to behave correctly if e.g. memory for unrelated arrays overlap. See https://en.wikipedia.org/wiki/Pointer_aliasing https://en.wikipedia.org/wiki/Pointer_aliasing I am not sure if this performance advantage is still the case as the wikipedia page on pointer aliasing notes that C99 added a "restrict" keyword so that the C programmer can tell the C compiler where similar strong assumptions can hold.
- gravypod 9y agoBecause scientists already know fortran and they're too lazy to learn something else even if there would be significantly improved results.
- atemerev 9y agoLike what?
- gravypod 9y agoJulia, C++ with libraries, Python with Cython or Numba, etc. You could also get much faster if most of your work is matrix multiplication if you make use of libraries like ViennaCL and a modern C++ compiler.
- ZenoArrow 9y agoBoth Julia and Python use Fortran code under the hood to speed up matrix multiplication. Julia comes with OpenBLAS which is partially written in Fortran, and the following page of SciPy documentation indicates that a Fortran compiler is required for some NumPy modules: https://docs.scipy.org/doc/numpy-1.10.1/user/install.html https://docs.scipy.org/doc/numpy-1.10.1/user/install.html "To build any extension modules for Python, you’ll need a C compiler. Various NumPy modules use FORTRAN 77 libraries, so you’ll also need a FORTRAN 77 compiler installed."
- gravypod 9y agoI would also say that no one in the scientific world should be writing ASM for their programs. Does that mean I'm also telling them not to use any compiled language? No.
- ZenoArrow 9y agoASM != Machine code. That aside, you haven't explained why you think the languages you listed are better suited for scientists than Fortran. What are your issues with modern Fortran?
- AnimalMuppet 9y agoBecause of the libraries. You say you can get matrix libraries for C++. And you're right, you can. But with Fortran, you can get (for example) functions that will solve Hermitian matrices, which run faster than solving regular matrices. Or special routines for sparse matrices, which run faster and use less memory. Or... And you could write every one of those in C++. But the Fortran ones have 30 years of debugging and optimization on them. They're solid. You can't get that by writing your equivalent in C++.
- cls59 9y agoBecause Fortran was purpose-built for manipulating array-based data while C++ is a general-purpose programming language. That means Fortran is optimized for this problem domain starting at the _grammar of the language_ while C++ can provide at best access to a locally optimized set of libraries. Those libraries might be quite good, but the comparative experience is still like trying to drive a Phillips-head screw using a flat-head screwdriver.
- Elrac 9y agoSorry about the "me too" but I'm another example of someone who programs non-science in FORTRAN. I work on a crew management system for a major airline. Most of this and related applications engage in data shuffling rather than number crunching, but FORTRAN used to be one way of creating code that ran at nearly assembly language speed and size in (historically) memory constrained environments. That said, the application (and I) are nearing retirement.
- shoo 9y agoi haven't been doing any numerical computing for the last 5 or so years, but previously I was using python's numpy + scipy pretty heavily for data-science / applied-maths stuff, and under the hood quite a lot of the numerical optimisation algorithms in scipy are wrappers around old fortran libraries. so at that stage it still gets used but perhaps most people can pretend it doesnt exist. similarly, the backend of the original "random forest" machine learning algorithm for R was written in fortran, and then wrapped as an R library, but as an R user you could largely pretend that fortran didnt exist. R was a pitifully slow language so this was a good move.