Live data from Hacker News

Learning Fortran (2024)

uncenter.dev

41–50 of 85 posts

Re: Learning Fortran (2024)

#42
post #8

The article did not discuss this, but to me, one of the bigger differences between Fortran and more modern languages is the difference between functions and subroutines. Yes, they are not synonyms in Fortran and serve different purposes. I think this would trip up more people initially than the clunky syntax. It is also a bit funny that the author complains about older Fortran programs requiring SCREAMING_CASE, when…

What practical difference ever existed, beyond the fact that a subroutine does not return a value? AFAIK variable scope was handled identically. Recursion was likewise identical (forbidden originally).

Re: Learning Fortran (2024)

#43

I actually had a fantastic experience with Fortran lately. I ported a compute kernel from python/numpy to Fortran 2018, partially due to the GIL and partly so I could use Intel's compiler. The performance improvement was tremendous. Several times faster per core, then multiplying further because I could take advantage of threading. In all, the 3 day project increased actual throughput 450x. (I considered JAX, but the…

Yea, Fortran is nice to use for so-called "scientific" computing. It has high performance as well as some handy intrinsic functions like DOT_PRODUCT and TRANSPOSE but the best features to me are colon array slicing syntax like Python/Numpy and arrays being indexed from 1 which makes converting math equations into code more natural without constantly worrying about off-by-one errors.

I wouldn't call multi-dimensional arrays tensors though. That's a bit of a bastardization of the term that seemed to be introduced by ML guys.

It wasn't until I started using Fortran that I realized how similar it is to BASIC which must have been a poor-man's Fortran.

Re: Learning Fortran (2024)

#44

I actually had a fantastic experience with Fortran lately. I ported a compute kernel from python/numpy to Fortran 2018, partially due to the GIL and partly so I could use Intel's compiler. The performance improvement was tremendous. Several times faster per core, then multiplying further because I could take advantage of threading. In all, the 3 day project increased actual throughput 450x. (I considered JAX, but the…

If your problem fits into arrays/matrices/vectors as the only required datastructures, Fortran is a VERY good language.

Re: Learning Fortran (2024)

#46
I wonder: is there any reason beyond sheer curiosity* to learn Fortran in 2025? Not being snarky, genuinely curious about what Fortran brings to the table.

* Nothing wrong with that as a reason, of course

Re: Learning Fortran (2024)

#47

I'm not sure one line of that would compile in FORTRAN 66, even if you indented it properly. Been so long I'm not sure...

The reverse is true though, and I find that fascinating with Fortran.

I recently learned Fortran IV to build a backpropagated neural network for the IBM 1130 (1965) and was amazed to see it compile with no warning on both the punched card compiler from IBM and on a modern Fortran compiler (gfortran).

Some Fortran II conventions, like the arithmetic IF, are now deprecated, but --std=legacy is all it takes to make it work.

Re: Learning Fortran (2024)

#48
post #46

I wonder: is there any reason beyond sheer curiosity* to learn Fortran in 2025? Not being snarky, genuinely curious about what Fortran brings to the table. * Nothing wrong with that as a reason, of course

I suspect that nearly all of the Fortran code that will exist ten years from now already exists today, so knowing the language is a skill that is more likely to be useful to you for performance testing and code porting than for new development.

The trickiest part of really learning Fortran today is that it is hard to define what the language is, apart from the practical definition imposed by what its seven or so surviving compilers accept and how they interpret it. There are near-universally portable features that are not part of the ISO standard; there are standard features that are not at all portable, or not available at all anywhere. So what one should know as “Fortran” is its reasonably portable intersection of features across multiple compilers, and there isn’t a good practical book that will teach you that.

Re: Learning Fortran (2024)

#49
post #46

I wonder: is there any reason beyond sheer curiosity* to learn Fortran in 2025? Not being snarky, genuinely curious about what Fortran brings to the table. * Nothing wrong with that as a reason, of course

Yes. Some scientific computing code is still being developed in Fortran eg in HPC. (and has been for decades)

Re: Learning Fortran (2024)

#50

I actually had a fantastic experience with Fortran lately. I ported a compute kernel from python/numpy to Fortran 2018, partially due to the GIL and partly so I could use Intel's compiler. The performance improvement was tremendous. Several times faster per core, then multiplying further because I could take advantage of threading. In all, the 3 day project increased actual throughput 450x. (I considered JAX, but the…

Yea, Fortran is nice to use for so-called "scientific" computing. It has high performance as well as some handy intrinsic functions like DOT_PRODUCT and TRANSPOSE but the best features to me are colon array slicing syntax like Python/Numpy and arrays being indexed from 1 which makes converting math equations into code more natural without constantly worrying about off-by-one errors. I wouldn't call multi-dimensional…

e.g. "tensors" are like "vectors" in they transform in a specific way when the coordinate system changes; what felt so magic about vectors as an undergrad was that they embody "the shape of space" and thus simplify calculations.

If you didn't have vectors, Maxwell's equations would spill all over the place. Tensors on the other hand are used in places like continuum mechanics and general relativity where something more than vectors are called for but you're living in the same space(/time) with the same symmetries.

Post reply on HN