Live data from Hacker News

Learning Fortran (2024)

uncenter.dev

21–30 of 85 posts

Re: Learning Fortran (2024)

#21

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…

I did something similar many years ago. I was amazed that Fortran was not more discussed as an option to write performant code within a Python / numpy codebase.

At the time everyone seems to default to using C instead. But Fortran is so much easier! It even has slicing notations for arrays and the code looked so much like Numpy as you say.

Re: Learning Fortran (2024)

#22
post #3

I expected this to be about Plankalkül or something devised by Babbage.

Yeah, "oldest" needs an asterisk.

Edit: and just three paragraphs in, the author admits they didn't even bother using the oldest version of FORTRAN itself.

So, "oldest" means "rather early".

Re: Learning Fortran (2024)

#23
post #7

If you're interested in safer code when working with older versions of Fortran, add 'implicit none' at the top. This will eliminate the integer vs. float automatic assignment and make variable definition much tighter. Back when I mucked about with Fortran (previous century really), we tried to do the memory allocation and I/O in C and the compute in Fortran. That would play well with both superscalar and vector machi…

Pro tip: ctrl-f or find in page helps a lot. The author talks about implicit none and shows it in code.

Re: Learning Fortran (2024)

#24
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…

> difference between functions and subroutines.

Waitaminit, is that why we have "sub" in Visual Basic ?

Re: Learning Fortran (2024)

#27
First language I learned while in college in the 1990s. While I enjoyed the class, I have a funny picture of me kicking the FORTRAN book across my dorm room after I turned in my final project.

Re: Learning Fortran (2024)

#28
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…

> difference between functions and subroutines. Waitaminit, is that why we have "sub" in Visual Basic ?

Yes! QBasic also, IIRC.

Re: Learning Fortran (2024)

#29

Earlier quoted context omitted.

> difference between functions and subroutines. Waitaminit, is that why we have "sub" in Visual Basic ?

Yes! QBasic also, IIRC.

it was a great improvement over GOSUB... which i probably have not thought about in forever

Re: Learning Fortran (2024)

#30

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…

I've never found anything to back this up, but my impression was that both the Python / Numpy and Fortran 90 slicing operations were directly inspired by MATLAB (although most of the ideas go back to at least Algol 68).

It also helps that Fortran compatibility is a must for pretty much anything that expects to use BLAS.

Post reply on HN