开发者

Are there such good C compilers that fortran is becoming a redundant language? [closed]

开发者 https://www.devze.com 2023-02-22 14:36 出处:网络
As it currently stands, this question is not a good fit for our Q&A format. We expect answers to be supported by facts, references,or expertise, but this question will likely solicit debate, a
As it currently stands, this question is not a good fit for our Q&A format. We expect answers to be supported by facts, references, or expertise, but this question will likely solicit debate, argument开发者_如何学JAVAs, polling, or extended discussion. If you feel that this question can be improved and possibly reopened, visit the help center for guidance. Closed 11 years ago.

Just wondered, as I'd always considered Fortran's use to be in supercomputing. However, I often hear C compilers can make C as fast as Fortran, so is it's use limited?

Also, if this is true what are the fastest C compilers?

Thanks in advance.


Argh! No, no it doesn't. And in related news, Fortran growing some OOP/polymorphic stuff doesn't obsolete C++, Erlang doesn't render Haskell superfluous, python hasn't killed bash scripting, PHP doesn't obviate the need for javascript, and mysteriously, nothing has killed off Java, etc, etc, etc. There are a bazillion programming languages out there for a reason -- there is a set of programmers that finds them good tools for specific jobs. You don't have to like them for that to be true.

C is, fundamentally, a systems programming language. It is wretchedly painful to write anything like computational science stuff in it. C++ is better because it's richer, but suffers critically from the fact that it doesn't have multdimensional arrays as a first-class type (no, it just doesn't, ok?), and all of technical computing relies critically on multidimensional arrays. The lack of a single standard multidimensional array package for C/C++ makes it very difficult to write optimized libraries for that language, and once you commit to one package you have to use their data structures throughout. Python suffers from the same problem, and will do so until Numpy becomes part of Python core.

Fortran, for all its flaws, is the only language out there designed specifically for scientific programming. It allows python- or matlab- like array operators and slicing, and that can a scientific programmers life easier. Even then, lots of scientific programers don't like fortran; they prefer the toolsets or libraries available in other languages. And that's ok.

And just to fend off your next question -- no, we don't have to all agree on editors, either.


Fortran has some properties that allow faster programs. Esp pointers stop the compiler from optimize code (and arrays are passed as pointers in C - and arrays are THE datastructure in HPC). Problem here is that two pointers can alias, in fortran this can not happen. In new C99 this problem is reduced, when good written, as you hint the compiler with restrict, that such alias can not happen.

But as there is very much old fortran code in the companies fortran never will get obsolete in near future.


Fortran isn't going away any time soon. There is too much Fortran code: fast, reliable, well-tested routines for doing all sorts of things, and programs that may be less well-designed but which work and would be difficult to rewrite in C.

Moreover, Fortran as a language is designed around high-performance computing, and has no little barriers to optimization, and Fortran compilers are usually designed for high-performance computing.


Fortran 90 / 95 / 2003 / 2008 are higher level languages than C. I'd pick C for embedded or device programming, and modern Fortran for scientific programming.


Two words. Legacy code. There will still be plenty of Fortran around in 20 years, just as there will be plenty of COBOL. And my heart goes out to those who have to maintain it.

0

精彩评论

暂无评论...
验证码 换一张
取 消