9 ms·
Learning Fortran (2024)
- ginko 10mo agoI expected this to be about Plankalkül or something devised by Babbage.
- riskassessment 10mo agoI was expecting a system like Leibniz notation, Boolean Algebra, Begriffsschrift, or the notation system in Principia Mathematica
- IAmBroom 10mo agoYeah, "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".
- deleted 10mo ago[deleted]
- turing_complete 10mo agoI was expecting Plankalkül: https://en.wikipedia.org/wiki/Plankalk%C3%BCl https://en.wikipedia.org/wiki/Plankalk%C3%BCl
- xhrpost 10mo agoI was expecting Flow-Matic but your mention is even older. https://en.wikipedia.org/wiki/FLOW-MATIC https://en.wikipedia.org/wiki/FLOW-MATIC
- 9rx 10mo agoFortran, the language, is also older than FLOW-MATIC. FLOW-MATIC's claim to fame was beating Fortran at releasing a working implementation (and having syntax that looked like English, but that's not something to be proud of). Plankalkül, however, has not yet been implemented so if we're only counting releases of working software, it isn't a contender.
- dizzant 10mo ago> a quick introduction to a few modern Fortran features: declaring variables, printing and reading to and from the terminal, if and select case, and stop Pretty much sums up this one. Can't say that I agree if/select/stop are "modern" features.
- vzaliva 10mo agoThis is an excellent idea. But I wold go with Fortran 4 if you looking at authenticity.
- jleyank 10mo agoIf 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 machines.
- layer8 10mo agoYou didn’t read the article?
- jleyank 10mo agoAll of it, no. But I never used Fortran 90 yet used implicit none. Might have been an extension from SGI or a mini super but I recall using it.
- Neywiny 10mo agoPro tip: ctrl-f or find in page helps a lot. The author talks about implicit none and shows it in code.
- atrettel 10mo agoThe 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 if anything this is an improvement over previous and current practices. Too many Fortran codes have overly terse variable names that often were just single characters or impenetrable abbreviations for obscure terms. I have had to create cheat sheets for each program to figure out what each variable was. Sun Microsystems had a great quote about this back in the day [1]: > Consistently separating words by spaces became a general custom about the tenth century A.D., and lasted until about 1957, when FORTRAN 77 abandoned the practice. [1] https://docs.oracle.com/cd/E19957-01/802-2998/802-2998.pdf https://docs.oracle.com/cd/E19957-01/802-2998/802-2998.pdf
- pklausler 10mo agoSpaces don't matter in fixed-form Fortran source files, so I don't get that at all. And case doesn't matter in either source form.
- atrettel 10mo agoYes, sorry for the confusion. To be clear, the quote is directly about spaces not being significant in the source code in general, but I was commenting more about how this mindset affects variable names in practice. At least in my experience, many codes would benefit from variables names that use underscores.
- whynotmaybe 10mo ago> difference between functions and subroutines. Waitaminit, is that why we have "sub" in Visual Basic ?
- thatjoeoverthr 10mo agoYes! QBasic also, IIRC.
- aj7 10mo agoArrays that actually make sense!
- 5555624 10mo agoThis makes me feel old. I learned Fortran on the Dartmouth Time-Sharing System back in 1980. While I think of Fortran now and again and think about re-learning, I haven't thought of DTSS in years.
- leephillips 10mo agoWow, me too. Maybe more like 1982.
- self_awareness 10mo agoWhy not COBOL?
- Hizonner 10mo agoI'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...
- rahen 10mo agoThe 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.
- AdieuToLogic 10mo agoI was taken aback by the code using lowercase. Didn't know EBCDIC[0] could do that... :-D 0 - https://en.wikipedia.org/wiki/EBCDIC https://en.wikipedia.org/wiki/EBCDIC
- thatjoeoverthr 10mo agoI 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 code in question was not amenable to a compute graph. Another option was to thread by fork, and use IPC.) I liked the language itself more than expected. You have something like "generics" with tensors. Suppose you pass a parameter, N, and you also would like to pass a tensor, and you would like to specify the tensor's shape (N, N). You can do this; the parameter type constraints can reference other parameters. Tensors and various operations are first-class types, so the compiler can optimise operations easily for the system you're building on. In my case, I got 80% improvement from ifx over gfortran. Invocation from Python was basically the same as a C library. Both Python and Fortran have facilities for C interop, and Numpy can be asked to lay out tensors in a Fortran compatible way. Part of what eased the port was that Numpy seems to be a kind of "Fortran wrapper". The ergonomics on tensor addressing, slicing and views is identical.
- prennert 10mo agoI 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.
- 3uruiueijjj 10mo agoI'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.
- thatjoeoverthr 10mo ago
- vatsachak 10mo agoI can't believe they thought so hard about how threads work in the first programming language https://en.wikipedia.org/wiki/Jacquard_machine https://en.wikipedia.org/wiki/Jacquard_machine
- dhosek 10mo agoI thought that was going to be what the article was about (or perhaps Lady Ada Lovelace’s ideas for programming).
- RyanOD 10mo agoFirst 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.
- dhosek 10mo agoJust looking at Fortran code fills the back of my mouth with the sensation I got from being around the printed IBM manuals in the basement computer lab at UIC of being around dust and powdered printer paper.
- silverfrost 10mo agoReal programmers can write FORTRAN in any language...
- stevenjgarner 10mo agoOne of oldest HIGH-LEVEL programming languages. "Programming" originally meant physically flipping switches or plugging cables into boards. Eventually, this moved to binary (1s and 0s), and eventually to Assembly.
- gorfian_robot 10mo agoa Jacquard Machine has entered the chat ...
- sdsd 10mo agoSemi-related, I've wanted to learn Plankalkül for some time but have had immense difficulty "getting it". Has anyone on here gotten the hang of it?
- fithisux 10mo agoVery good choice. Focus on the newest standard.
- drivers99 10mo agoThat was really interesting. > Next time, we’ll talk more about... Alas, there was no next time.
- klez 10mo agoI 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
- pklausler 10mo agoI 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.
- conformist 10mo agoYes. Some scientific computing code is still being developed in Fortran eg in HPC. (and has been for decades)
- AdieuToLogic 10mo agoSee also OpenMPI FORTRAN support[0]. 0 - https://docs.open-mpi.org/en/main/developers/bindings.html#fortran-bindings https://docs.open-mpi.org/en/main/developers/bindings.html#f...
- rramadass 10mo agoYes; I am seriously thinking of getting the "Modern Fortran Explained" book (https://academic.oup.com/book/56095 https://academic.oup.com/book/56095). Modern Fortran has everything (Procedural, OO, Functional, Multithreading, Parallel etc. features) that all modern languages have. I would say it is no longer "just" for numerical computing. Excellent libraries/ecosystem, a well supported and stable language, fantastic optimization right out of the box etc. makes it a great general purpose language. Fortran in Modern Scientific Computing: An Unexpected Comeback - https://medium.com/@stack1/fortran-in-modern-scientific-computing-an-unexpected-comeback-55be2564d22d https://medium.com/@stack1/fortran-in-modern-scientific-comp... 5 Reasons Why Fortran is Still Used - https://www.matecdev.com/posts/why-fortran-still-used.html https://www.matecdev.com/posts/why-fortran-still-used.html Is Fortran better than Python for teaching the basics of numerical linear algebra? - https://loiseaujc.github.io/posts/blog-title/fortran_vs_python.html https://loiseaujc.github.io/posts/blog-title/fortran_vs_pyth... I take back everything i said about FORTRAN - https://x.com/ThePrimeagen/status/1745542049284423973 https://x.com/ThePrimeagen/status/1745542049284423973 Modern Fortran online tutorial - https://wvuhpc.github.io/Modern-Fortran/ https://wvuhpc.github.io/Modern-Fortran/
- AdieuToLogic 10mo agoTwo valuable (and related) resources when learning FORTRAN are: The NUMERICAL RECIPES in Fortran 90 book[0] The NUMERICAL RECIPES website[1] 0 - https://www.cambridge.org/us/universitypress/subjects/mathematics/numerical-recipes/numerical-recipes-fortran-90-art-parallel-scientific-computing-volume-2-2nd-edition https://www.cambridge.org/us/universitypress/subjects/mathem... 1 - https://numerical.recipes/ https://numerical.recipes/
- fortranfiend 10mo agoI still have to use Fortran 77 on vax machines at work. It's... Fun. Hope it lasts long enough for this replacement project to finish.
- fortran77 10mo agoI cut my teeth on Fortran and am still very active in the Fortran community. Or what’s left of it anyway.
- tarjei_huse 10mo agoIt strikes me that SCREAMING_CASE was a good idea in an age where the displays only had two colors - black/white or black/green...
- timonoko 10mo agoShould have made "100 CONTINUE" card out of metal. It was on every freshman's program and there was even recycling bins for those.