8 ms·
> There's also this notion that "Fortran is fast" that MANY people hold for some reason. They don't know about what kinds of modern compiler optimizations they'
by qb45 9y ago
> There's also this notion that "Fortran is fast" that MANY people hold for some reason. They don't know about what kinds of modern compiler optimizations they're missing out on and what new IPC frameworks are available.
Fortran is fast and has no reason to be worse than C. In fact, it may be easier to write compiler-friendly code in F thanks to "restrict by default". And are there really HPC-grade C compilers with whatever "modern optimizations" that don't come with a Fortran frontend? Don't think so.
BTW, I have seen an attempt to rewrite a few dozen KLOC Fortran project to C and it wasn't pretty. The code was still a bunch of for loops crunching through a bunch of arrays, just in a different language, and then it had some new bugs that were introduced in translation and also it produced slightly different results because of different language rules, compiler and optimizations translating the same math formulas to different machine code. And the formulas were written to produce expected output when compiled with, you guessed it, Fortran.
Don't get me wrong, the old-school Fortran with 3-letter variable names, 72 character columns, GOTOs and stuff sucks donkey balls. But you don't have to write like that - while I'm no real Fortran expert (sorry), I've heard that modern standards of Fortran are vastly better and look much closer to C. I would certainly research this before rewriting everything in C.
- jay-anderson 9y agoAlso, there are optimizations that can be done with fortran that are more difficult or cannot be done with C (see https://en.wikipedia.org/wiki/Pointer_aliasing https://en.wikipedia.org/wiki/Pointer_aliasing).
- qb45 9y agoThat's what I meant by "restrict by default". You can get Fortran-like semantics in C by marking function arguments with the restrict keyword, at the cost of some manual labor (and possibly having to explain this to scientists who consider computers a necessary evil) ;)
- gravypod 9y ago> Fortran is fast and has no reason to be worse than C Finding developers and maintainability. Those are two reasons.
- walshemj 9y agoAny decent developer can learn Fortran at my first job straight from high school at a world leading RnD Org. I was told to get the book on Fortran from the company library and learn it. I did have a quick hours training on how to operate the PDP 11 though.
- gravypod 9y agoI'm not doubting that. Anyone can learn any language. I'm more asking why should you be using Fortran when other, better suited, languages exist for the same tasks. I can understand legacy libraries. I cannot understand new projects and mission criticle systems.
- walshemj 9y agoSeveral reasons For Fortran's use case you want to turn math into running code and all this C /C++ OOP stuff gets in way. Also any language that doesn't have arrays built in is not going to get the time of day from a technical programmer. You want the maximum performance out of your code so Python might be good for prototyping but you want to convert that to the fastest code in production.
- gravypod 9y ago> For Fortran's use case you want to turn math into running code and all this C /C++ OOP stuff gets in way. Turning math into code is just as easy in both languages. The only addition that is different is adding types is mandatory in C++. You'd see more "float" or "long double"s in C/C++ code. No other difference. > Also any language that doesn't have arrays built in is not going to get the time of day from a technical programmer. Julia and Python have arrays built in, C++ has an array type, and C/C++ have pointers. > You want the maximum performance out of your code so Python might be good for prototyping but you want to convert that to the fastest code in production. With very little work you can turn prototype python code into production code with Cython. C speeds with python orchestration. This leaves out the other languages on the block like Haskell and D which are better suited for other tasks.