What is the superiority of Fortran over alternative languages like Chapel or Julia?

Hi, I wanted to learn a high-performance, parallel programming language. After a bit of research, I see a few options in front of me: chapel, Julia, and of course Fortran. I wanted to know what is the superiority of Fortran over other high-performance programming languages? In particular, there have been many recent efforts to improve the ecosystem around Fortran, which has been interesting to me. What feature of Fortran has made smart people like @certik try to improve this old programming language?

3 Likes

I’ve decided on Fortran simply because it isn’t going anywhere. It will likely still be used in science and engineering for decades to come. There is just too much validated code in Fortran to rewrite from scratch.

Fortran doesn’t aspire to the mythical language that solves all problems. They have done a great job in putting interfacing with C in the standard, and I expect compilers to get better.

My focus is on how to get it taught at elementary levels of math education.

6 Likes

One view is that what makes Fortran special are the Fortran compilers. For many decades now, manufacturers of supercomputers competed on being fastest on Fortran code and making their hardware scream without diverging too much from standard Fortran. I don’t think there is another programming language that boasts so many high quality compilers (Fortran Compilers - Fortran Programming Language).

6 Likes
8 Likes

Even if not explicitly written, I can read a sentiment “Why use an old programming language, when we have a new one?” in the question.

There are many reasons why one would want to use an established platform instead of a fancy new tool. Especially when part of your code base is already in some language and the language does not have some particular specific problem that you can point at and say - I need something new because this and this is not good.

You simply do not change your main tool just because there is a new one, you need a much better reason.

After all, the fancy new tool may not be here in the next decade and you may have to rewrite your code base to something that is still supported. That may even be the end of your business.

The stability and backward compatibility of Fortran (and some other standardized languages such as C or C++) is a great thing. I have been continuously improving my main production code for 15 years and I didn’t have to rewrite any part just because the toolset would no longer support it.

Regarding your two choices: Chapel - very attractive but mostly only for Cray supercomputers. Like in Fortran you have to take care about a rich library of general-purpose routines yourself. It does not contain something like SciPy or other Python libraries. It is quite specialized niche language for parallel supercomputing - even if theoretically general purpose.

Julia - still living in the shadow of Python. Still lacking the raw power of Fortran. I haven’t heard about applications using thousands or hundreds of cores really efficiently. But probably great for smaller programs running on a single machine - however, that already makes it somewhat limited. At least for me.

6 Likes

Fortran is as far away from hype driven development as possible. The big attraction is that I’m confident future language revisions will not create excessive, unnecessary work (unlike Python 2 → 3).

I’m familiar with other languages (Common Lisp and Prolog) so I find Python very underwhelming.

The modern versions of Fortran are very readable and easy to learn (a supposed Python strength), but are magnitudes more computationally efficient. Modern Fortran reminds me of Ada in some ways.

4 Likes

The notion that Fortran is “an old programming language” ignores the fact that if you removed everything that has been declared obsolescent etc. from the language it is in many ways “newer” than C++. To me the two biggest pieces missing from the language are a Fortran NumPy/SciPy or STL equivalent (which stdlib will hopefully remedy) and better support for generics/meta-programming. Other than maybe better support for strings etc. there is nothing else that C++ or Python does better for the specific case of scientific programming than Fortran. Don’t get hung up on the name. Automobiles named Mustang have been around for over 50 years but the modern version is vastly different from the original 1965 or so versions. The same is true for Fortran.

13 Likes

Do any of the regulars here use Julia? I wonder what the use cases are for people comfortable with modern Fortran.

There are five articles discussing comparing Julia, Fortran and other languages in the Fortran Advocacy and Language Comparisons section of the Fortran Wiki – search “Julia” and also look at A Comparison of Programming Languages in Economics: An Update.

1 Like

Hi @GLiTCH, welcome to the Forum.

Julia has been one of the inspirations and motivations for LFortran. I showed a demo to a few of the Julia authors about two or three years ago. My personal view is that there are (at least) two approaches:

  • You take an interactive easy to use dynamic language like Python or Matlab, and see how fast you can make it. That is roughly how Julia started. It’s still interactive an easy to use as Python, but much faster.

  • You start with a proven language that can generate very fast code, and see how interactive you can make it, without sacrificing the performance. That is how LFortran was born (still in heavy development).

It is approaching the same problem from the opposite direction.

The reason I chose Fortran over Julia or over creating a new language:

  • In my subjective experience with C++, Fortran, Python and other languages, Fortran is simple, easy to learn, and yet delivers the best performance in practice out of all the other options for numerical computing tasks.

  • Fortran has not realized its full potential yet. With vastly improved tooling and compilers in few years, it might be close to ideal. Most of the issues I have with Fortran can be fixed. It does not seem to me there is some fundamental problem with Fortran that would prevent it to deliver excellent performance, or that would make it complicated.

We described our motivations in the following two blog posts if you are interested in more detailed motivation:

Regarding Chapel, I only played with it a little bit, they have some good ideas (about how to parallelize and separate algorithms from their parallelizations) but I think it has not proven yet and the community is not as big yet. It’s a chicken and an egg problem, and another reason why I chose an established language over creating a new one. (Fortran has proven over the decades that it works in practice for large production codes, runs in parallel and delivers excellent performance.)

12 Likes

Because of native support. Personaly I am a C++ programmer but recently started to look at Fortran and Rust too for considering using both for some low level stuff as alternatives to C++ because the language is simply too complex. The real point is that Fortran has huge industry support and can run basically on every platform from embedded devices to high performance servers and has a compiler in the works that is actually a part of LLVM itself which means good future support and huge cross platform support when it will get out. Also Fortran functions are exposed as simple C functions to other languages when wanting interfacing with it from other languages as opposed to Julia where you have to initialize the VM first and do some other stuff before calling your Julia functions inside your applications. Also it has native support for CUDA, OpenACC, and other parallel programming technologies directly by CPU and GPU vendors like Intel, AMD, NVidia, etc… Last time I’ve checked nothing as direct as that exists for Julia. That’s why I’ll stick with Fortran, Also Julia is not a strictly statically-typed language which for the kind of job I do is a downside.

13 Likes

A few months ago I responded to a similar question about “modern” alternatives to Fortran. I simply repeat my answer here.

…The modern language you are looking for is called modern Fortran 2018. Fortran 2008 and 2018 have everything a numerical computing project would need and so many features that many other languages mentioned here lack (including extremely pleasant array-syntax which has inspired all other languages such as MATLAB, Python, R, Julia, …, even C++ numerical libraries). It is the only language that has native built-in parallelism at all levels and is the only language, along with C, for which the official MPI parallelism standard is released. It has also excellent vendor support for GPU parallel computing and as I heard in SC18, some vendors like NVIDIA/PGI have already started implementing the native parallelism features of Fortran via GPUs.

Modern Fortran is a high-level language comparable to MATLAB and Python, yet 100-500 times faster than both (NASA Modeling Guru: Basic Comparison of Python, Julia, Matlab, IDL and Java (2019 Edition)). Using Coarray Fortran you can seamlessly parallelize your code with minimal effort to run it from your laptop to the largest supercomputers in the world. No other language that I know of, has such capability at the moment. Fortran is also the only language that has all levels of parallelism, from instruction level to vectorized, concurrent, and coarray shared/distributed parallel computing. If such features are not considered “modern”, perhaps “post-modern” would be a better description.

Fortran has been a reliable lasting language for almost 3 quarters of a century and has excellent highly-optimized compiler support (Intel, GNU, NAG, IBM, PGI/NVIDIA, …). If you want to write code that lasts decades, then port your FORTRAN77 code to modern Fortran with minimal effort and save yourself time, energy, money, and computational power.

If you decide to port your code effortlessly to modern Fortran, you can also get help from the official Fortran language website https://fortran-lang.org/ and the community of programmers on Fortran discourse: https://fortran-lang.discourse.group/

Update Nov 17, 2020

Just yesterday NVIDIA released a news post on its GPU implementation of the concurrent features of Fortran 2008 / 2018. Users can now write code in pure modern Fortran and let the compiler automatically offload it to GPUs for thousands-way parallelism.

What is the relevance and importance of this achievement? The same Fortran code that a user writes can now be parallelized via GPUs, distributed CPUs, OpenMP threads, or auto-parallelization features of the Fortran compiler depending on the user’s platform and compiler choice. All of that complexity is hidden from the user. No need for preprocessing and conditional compilations anymore. This further enhances the excellent existing portability of Fortran programs across platforms and architectures.

14 Likes

Boutique languages come and go, but there is always Fortran. Like C and Lisp Fortran has remained relevant because it has evolved to meet the needs of the people that use it.

I spent my entire 25 year career writing C code in high performance graphics applications from the application level down to the OS kernel. But given the choice to write applications with I would choose Fortran then C, Lisp has its applications also…

Interfaces to C libraries are readily available or you can write your own, the compilers are great and the performance is excellent.

I find C++ too complex at this point to write clean code that is easily understood for code reviews and debugging other peoples code.

4 Likes

I see more books being published using Julia than Fortran nowadays. It is being used in numerical analysis courses at MIT and probably elsewhere. One of its creators, Alan Edelman, is a professor there. It may be that more science and engineering students are graduating with Julia than modern Fortran experience (and Matlab has even more share). I hope that the Fortran language and ecosystem will continue to evolve, but I would not say that competitors such as C++, C, Python/Numpy, Matlab, Julia and R have lower chances of survival, and I would recommend to a novice that they start with one of the scripting languages until they hit performance problems.

5 Likes

Blockquote
I would not say that competitors such as C++, C, Python/Numpy, Matlab, Julia and R have lower chances of survival

I think this is relative to what area you are working in.

In statistics, R is a language “written by statisticians, for statisticians” – so I don’t see it going anywhere. A similar argument could be made for Matlab.

Once the “AI/ML” winter hits, I’d expect Python to be blamed (not a valid argument, but this is the historical pattern for tech failure – blame your tools) leading to a defection from that ecosystem.

Fortran is a safe hedge, due to the ease in which it binds to C, so it can play nice with either R or Matlab, or work independently. Importantly: it is also a nice language in which to teach imperative programming, making picking up other imperative, OOP languages easier.

FWIW – I’d encourage learning the following, in this precise order:

  1. Fortran
  2. Scripting Language (R or Matlab, then Node.js, then maybe Julia).
  3. C
  4. C++

If a novice got competent with Fortran, the scripting languages won’t be hard.

2 Likes

But that has always been the case, boutique languages sell books and gather interest in programmers for something new. I am sure many have seen this cycle again and again and if there is one thing people should learn is this is a pattern in all technologies, in particular programming.

Even now languages that were popular a few years ago have gone largely unsupported. It’s always been the case and I suspect it always will.

I would stick with Fortran, it is here now and widely supported and I don’t see that changing.

4 Likes

I teach and use MATLAB, Python, R, Fortran, and a bit of C on an almost daily basis. In all fairness to Fortran, I do not think if learning Fortran is any more difficult than learning MATLAB, Python, R, or Julia, other than the initial setup of the compilation process, which becomes only relevant for large-scale projects, which can be also completely resolved and automated via CMake nowadays. This latter is I believe what Julia tries to automate without the need for the build tools.
A while ago I read an article by one of the creators of Julia about why Julia exists. The gist of the argument presented as far as I understood, was that Python around 2010 was not good enough for scientific computing. For me personally, as someone who barely gets enough time for sleep, the stability and maturity of a programming language along with ease of use is the most important factor. Fortran has passed its test on this issue, as mentioned by @VladimirF. Julia still has a long way to go to prove itself, in my opinion. As an example, I have to update my Python lectures almost every semester, because the codes do not work with the new versions of Python or its packages. I simply cannot keep up with the rapid pace of changes in the Python ecosystem. Also, I am strongly against using a new language simply because it is fashionable, or because it is taught at MIT. There must be a better scientific argument.

5 Likes

I’m wondering if Rust is not another option for comparison?
(though it may be natural because it is a systems programming language…)

Btw, I read this page some time ago, and thought that the comparison between Rust and Zig might be possibly similar to Julia (or Chapel) vs Fortran.
https://kevinlynagh.com/rust-zig/
https://news.ycombinator.com/item?id=26374268

1 Like

Michael Wirth has many posts on Julia and Fortran at The Craft of Coding blog. Most are tutorial in nature, but a few are evaluative.

As a mathematician working in finance, my main reason is aesthetic. When I think of math written in code I basically think of Fortran. This was actually the case long before I even learned any Fortran.

I greatly prefer languages specialized to one task over languages that try to be serve many masters (like C++). Fortran is optimized for high performance parallel numerical computing, and to a greater extent than Julia. Moreover, it is very readable for a mathematical scientist, very easy to learn, and in my opinion has the correct amount of abstraction in it.

Some people argue that modern scientific codes are extremely large and require complex languages with powerful abstractions like C++. I can’t talk about what happens at national labs, but from my personal experience this is not the case in finance and economics. The peddle-to-the-metal portion of the code is almost always procedural code running simulations of array oriented operations, with lots of tight loops, and with SIMD and GPU in mind.

Moreover, the language simply hasn’t reached its potential. The specificity, the array orientation, the native parallelism, the in-built ability to tell the compiler that operations are independent, etc all mean that Fortran compilers can improve much faster than they have. To say nothing of the tools

7 Likes

Exactly my thoughts. Somehow I feel Nim will be a good contender. They appear to have made some nice decisions in the design. The userbase is currently so small that I don’t feel like giving it a try, fearing it may just disappear someday like X10, Fortress etc.

1 Like