4 ms·
I've never seen a fortram codebase in my life. Is it still alive? What advantages does it offer over C/C++?
by fctorial 7y ago
I've never seen a fortram codebase in my life. Is it still alive? What advantages does it offer over C/C++?
- fulafel 7y agoIt's used in science (physics, chemistry, astronomy etc). Just like C++ is used not because it's a nice language but because of inertia and path dependecy, the same goes for fortran.
- gnufx 7y agoBut it is a nice enough language, at least in its sphere: "ALGOL 60 is alive and well and living in FORTRAN [sic] 90." -- Tony Hoare
- cygx 7y agoIt's still around in the high-performance scientific computing world. Feature-wise, C99 basically looks like playing catch-up with Fortran to better compete in that space (eg restrict, complex numbers, type-generic math functions, stack-allocated variable length arrays).
- ufov2 7y agoFortran has language-level support for things important for numerical scientific computing (complex numbers, multidimensional arrays, etc.), and it has had them since the beginning in the 1950-60s. The convenience is not really matched by C or C++, where similar features have been added much later by language extensions or 3rd party libraries, resulting to more complicated usage, fragmentation, and interoperability problems. Newer languages also have similar issues, so for the user base that uses Fortran, there's a lack of viable competitors.
- PaulHoule 7y agoAlso numerical codes can be trickier to write than you think. Rounding errors and other treacheries of the floating point approximation to the 'real' numbers can eat you alive. If you want to do common numeric operations they might be a FORTRAN code that is battle tested and performance tuned and it usually not hard to call from C, Java, Python or some other language.
- stephencanon 7y agoFortran’s numerics model is actually somewhat weaker than C’s; if precise rounding behavior is your main concern C (while still not ideal) is a better option.
- gnufx 7y agoFor those of us not expert on the standards, could you explain in what way Fortran is weaker, and its rounding control deficient?
- gnufx 7y agoEvery time Fortran is mentioned, this seems to come up. In one thread I referred to the usage figures for the UK "tier 1" system, for instance.
- lloda 7y agoI write mostly C++ and Scheme and last year I wrote my first piece of code in modern Fortran (I had some experience porting/integrating old F77 libs). It's trivial to interface with C and lets you do numeric stuff immediately and without libraries using a plain syntax. Compared to C++ with template array libraries it compiles much faster and doesn't get in your way nearly as much. It has a module system... Compared to numpy/matlab/etc it takes some adjusting b/c it's still a lowish level language (errors lead to segfaults, etc.) but a lot less than going to C/C++.