422 points · by lelf · 6y ago · 246 comments
It had been scheduled for merge into the LLVM monorepo 2 days ago, but has been delayed pending some additional architecture review.
Install numpy, it will pull in Fortran stuff.
Scipy is a different story.
The need for a fortran compiler was a big part of the original rationale for the divide of numpy and scipy when they replaced numeric. Numpy was meant to be the lighweight/core version of things, and scipy was the full-fledged environment. (I think numpy was even scipy-min, or scipy-core, or something along those lines for a bit.) A key differentiator for what when into numpy vs scipy was whether or not it needed a fortran compiler. That's still true today -- numpy explicitly doesn't depend on anything fortran related, and anything that uses it is optional.
(I'm not authortative on any of this, I'm just someone who's been doing scientific computing in python (and fortran) since the numeric days.)
On a different note, modern fortran (e.g. F90 and above) is actually a really nice scientific software language. It's _still_ really hard to beat, and modern fortran is pretty maintainable and easy to read in addition to being performant. I've dealt with highly optimized fortran codebases and highly optimized C codebases for the same scientific tasks. The fortran ones were usually a lot easier to read, more maintainable, and were still faster. Fortran is not really a general purpose language, but if you're doing lots of number crunching on large arrays, it's damned nice.
I was amazed how much more complex things were when moving to C++ (as opposed to C or C written in cpp files which you’ll find in academia and some books).
Of course, that ease is a hazard when all the modern (i.e. fun) sci-eng software development is in C++.
Do not grow complacent in school, ye numerical methods researchers! Write your stuff in C++. The job market awaits.
However, in order to support all existing C programs I believe they still can't make the same level of optimization as Fortran does. It'd be nice to see this gap merged, in fact.
C++ can actually do better with some numeric code since commonly used libraries perform expression optimization at compile-time using Eigen for example.
I don't know if Fortran would be considered dead by the "no longer adapting" definition, but that it's still in use isn't proof it's alive.
That said, I only write in modern Fortran when I use Fortran. The newer features make it much easier to write complex data structures, in particular.
In regard to Fortran, things are changing too. There's even a Fortran 2018 standard, which is fairly close to Fortran 2008, but would be almost unrecognizable to people who learned Fortran 77 or earlier.
Ecce?! Hui?! Vah?!
Generally, it is recommended that you create a prepared statement entirely from static SQL string(s) (no user input) and then bind parameters into it, such that there is no possibility for any user input to be parsed as SQL:
The default https://fortran.io/ not so much.
EDIT: for a modern, relatively new and highly-used scientific codebase that uses Fortran90 exclusively, see PFLOTRAN: https://bitbucket.org/pflotran/pflotran/src/master/
https://arstechnica.com/science/2014/05/scientific-computing...
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.
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.
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.
BTW, the 'non-programmer' you seem to not think much of probably used an RPN calculator. Food for thought.
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.
Funicular railway:
https://www.youtube.com/watch?v=GO9J7NsM0Ck
Cog railway:
Amusingly, a short while ago I HN-commented on the eruption of Vesuvius that destroyed Pompeii and nearby settlements. Vesuvius also destroyed the funicular that the song advertised, in a later eruption.
Fortran has moved on, even if you professor hasn't.
I know of 4 major languages created in the 1950's: Lisp, Algol, Fortran, and Cobol. Lisp and Algol were brilliantly designed, years ahead of their time, and have inspired nearly every programming language since then. Fortran and Cobol not only look like evolutionary dead ends in hindsight, but they weren't pleasant to use even when they were popular.
There's a reason we still see Lisp posts on HN almost every day, and very rarely Fortran posts.
Although, I don't guess it's any worse than wanting to use your client-side scripting language for your server, or you database query language.
I think some of its infamy is unjustified.
"The March of Progress
> * 1956: Fortran I:
> PRINT 1, X
> 1 FORMAT (F10.2)
* 1980: C
printf("%10.2f", x);
* 1988: C++
cout << setw(10) << setprecision(2) << showpoint << x;
* 1996: Java
java.text.NumberFormat formatter = java.text.NumberFormat.getNumberInstance(); formatter.setMinimumFractionDigits(2); formatter.setMaximumFractionDigits(2); String s = formatter.format(x); for (int i = s.length(); i < 10; i++) System.out.print(' '); System.out.print(s);
* 2004: Java
System.out.printf("%10.2f", x);
* 2008: Scala and Groovy
printf("%10.2f", x)
"
The reference and the details (2012):
I don't know how to solve this problem. printf doesn't cut it. It simply can't specify an exact number of characters.
%06.*g
for width 6 down to 1.I believe this will always find an answer, and the one with the largest number of significant digits.
For example:
void format(double val, int width, char* buf) {
for (int w = width; w > 0; w--) {
int count = sprintf(buf, "%06.*g", w, val);
if (count == width) return;
}
}
"Working" example (unsafe, exits on failure, etc):Note that you can't represent negative values equal or below -1e-100 since those take 7 characters.
Whether you'd want to is another question rntirely. Might make for a fun weekend project. :)
[1] https://www.microfocus.com/en-us/products/visual-cobol/overv...
The attention to detail in this video is amazing (e.g., MS-DOS window on Mac), and very funny.
http://www.fastplaz.com/ https://github.com/risoflora/brookframework
Devil’s advocate for not writing FORTRAN off completely at first sight.
Apple used to run ad campaigns about how Macs were immune to viruses and therefore highly secure. Turns out enough people just weren't using Mac, and viruses started popping up once it went mainstream.
Captive audience.
> A modern Fortran development environment for Microsoft Windows, Apple macOS, and GNU/Linux systems.
It was quite interesting to read the list of available features [2].
PS: I am sure this is meant as a parody to make fun of other frameworks.
Love the idea.
Peasants. FORTRAN-77 is the real Fortran.
I love it
COBOL-ON-COGS is hilarious though.
To my mindset, this brings us closer.
GOD = ASSEMBLER .AND. FORTRAN .GT. NODE.JSAnd of course "unholy" is itself a metaphor for something which should not be allowed.
What? That's where you lost me.
There's even a CUDA compiler.
As I understand it, lack of pointers makes it possible for fortran compilers to parallelize code quite well.
You could probably even add another zero (almost two) to this
Typically, simulations that I run in MATLAB, Python or R, take 100 to 500 times longer than the equivalents that I write in Fortran. I am sure you can achieve a similar performance with C as well. But the development cost in C is much higher for numerical computing than in Fortran, given Fortran's native array-based syntax, parallelism features, optimization hints to the compiler, and the new high-level string and memory manipulation tools that it has.
That said, every language has its usage and place in the world of programming. In my case, all of the post-processing analyses of my Fortran/C simulation results are done in either Python or MATLAB, and sometimes in R. They complement each other rather than being rivals to each other.
Like some many-angled Lovecraftian horror, it spites reality, sanity and common sense merely by existing.
I don't know Fortran, so I won't use this. But as a dedicated ruby enthusiast, I won't be throwing stones either ;)