I created this: Gotchas — Fortran90 1.0 documentation we should probably port it to fortran-lang.org.
I had totally forgotten about this document. Has anyone presented it to Tsoding and asked him if it would have helped him in his Fortran project?
I went through a few Fortran tutorials, and was OK when I could stay in Fortran, but my ignorance of the details of C libraries and the of POSIX lead me to focus on C much more closely.
I’d like for Fortran to be a viable introductory language, so the limitations of Fortran will need to be covered by interfacing to C libraries, but I think that should be discussed in a separate thread.
Here is a nice list of differences between C and Fortran from the LLVM docs:
The Flang Compiler: Fortran For C Programmers
I noticed this sentence:
And so it is safe to assign integers to floating point numbers without losing any accuracy[...]
That should probably read like “[…] assign small integer values to […]”. If you assign an integer value larger than 1/epsilon(x) to a floating point value, then you can indeed lose precision.
Another (draft) attempt: https://github.com/PierUgit/misc/blob/011ebd2801a8f43b320e67e03ccffa32bb2e3461/misc/gotchas.md
@PierU, very nice. Why don’t you submit it to fortran-lang.org?
@certik I will
That’s unfortunately very true. But what can done, apart feeding fortran-lang with more content?
Unfortunately the IBM pages for Fortran XL are still very highly ranked, and when clicked just show an internal error that the page no longer exists.
I know almost nothing about how to affect google search rankings, but it’s a definite issue when discoverability is so low. For most intrinsics you can google “gfortran NAME” and get the documentation page. Some things like open read and write I haven’t found a consistent way to get anything useful from gfortran. For those I google “intel fortran open” for good results.
The major issue with both of these is that one has to know ahead of time how to finesse google on the topic to get current day results and not some FORTRAN 77 reference.
I assume this a temporary situation: at some point such pages will be automatically dereferenced by Google.
It takes time. Step by step, more content attract more people, who hopefully link to the content from other sites, which pleases Google so the ranking raises, which attracts more people, etc…
Or it takes money to buy ad keywords or to pay people who are “experts” to raise ranking faster.
Presence on social media also helps.
Once again, the key issue for all of this are the available resources…
On a more optimistic note, based on this thread and the videos, I installed FPM and stdlib on my Linux VM the other day, for the second time. My initial experience (on Windows) was posted in this thread:
Maybe because it was my second time going through the process, things seemed to be much easier. Especially impressive was testing a large number of scientific libraries in a few seconds. I also greatly appreciated the ability to compile the bootstrap FPM version from a simple *.F90 source file. I hope this remains a convention, especially in security conscious environments. (See https://bootstrappable.org/ for further reasons)
My only suggestion: many developers do not have root access on their machine. I think the default should assume all libraries are going to be in a user controlled directory, as is done in the Perl community via a tool like Perlbrew: An Admin-Free Installation Tool.
The use case for Perlbrew is slightly different in that it had been a serious problem with the default system Perl on Linux very often being several versions out of date from the most recent version that Perl applications run on. A separate Perl install in a user account circumvented that problem.
If I wrote a simple shell script / tutorial to facilitate the process for newcomers, could that be posted somewhere on Fortran-Lang? The materials to ease the learning curve exist, but they simply aren’t accessible to anyone other than the highly motivated.
Contributions to the docs are always welcomed and highly encouraged.
Not 100% finished yet, but already usable: my Fortran 2018 bindings to raylib 4.5.
It’s really astonishing how raylib makes it possible to create a 3D scene with just a few lines of code:
Excellent work! Auto generated interfaces are the way to go.
Amazing. I can see this project pollinating some interesting project ideas for GSoC '24.
You can read the information I resumed here:
https://fortranwiki.org/fortran/show/GFortran#contributing
and this very recent message:
The best way to get introduced in the GFortran development is to contact @JerryD : he is conscious that younger people (Fortran next generation!) may prefer more modern tools, and that is why he created a Mattermost instance for developers. Well, there are of course other ways to contribute, like maintaining or improving the documentation / communication, that is as important as you have shown. All is made by volunteers with good will… I assure you will be kindly welcome and helped to start. (Note that I am not myself a GFortran developer but I am in close contact with Jerry for a long time and I try to help as I can).
Update: Mattermost is an Open Source alternative to Slack, very very similar! In fact, we used Slack for several years before they removed some free functionalities and we decided to move to Mattermost, first in their Cloud and now hosted in the Oregon university (Mattermost decided recently that free hosting would be ended).
Just noticed this funny tweet below attributing the rise in TIOBE index to Tsoding. The TIOBE index was discussed previously in,
As much as I’d like to believe Fortran-Lang and related efforts are responsible for the rise in position, correlation does not imply causation.
Analysis of Tsoding’s Fortran streams
Over the last few weeks I’ve been watching and skipping through all of Tsoding’s Fortran streams, making notes on what he likes about Fortran, what he doesn’t like, and where he has encountered difficulties.
He is a very experienced programmer in many languages and domains. This report represents his experience, but it may also be an indication of how other Fortran beginners do during their first hours with Fortran, which may help us to improve tutorials, documentation and perhaps even the language.
While the main points have been discussed above, I hope this analysis will be more complete. It should be seen as a starting point for further discussion of these issues (if it hasn’t already happened).
The good
Let’s start with the good news. Tsoding really liked some of the Fortran features, and he even said he could see himself working with Fortran for money (but not in his spare time ).
He recognises Fortran’s potential for scientific programming, especially when it comes to array operations or printing variables. He also likes implied-do and the target
attribute. He even understands why implicit typing was (and still can be) a great thing for quickly using some “predefined variables” (he fully understands why it’s dangerous and hasn’t used it after playing around with it).
Overall, he thinks Fortran is a passable language and his first experience was educational and informative.
The bad
Given the many concepts in Fortran that are quite different from other programming languages, he naturally had many problems.
At the very beginning, he lacked the basics of Fortran, starting with the filename extension. The first extension listed on Wikipedia was .f
, which led to another problem: confusion about fixed-source-form. He then saw that he should use .f90
, but didn’t realise that this is the de facto default extension for every Fortran standard since Fortran 90.
Next, he wondered why the asterisk is needed in print
and read
statements, (*,*)
confused him even more, as did space in column one, especially since it’s missing from the Quickstart tutorial. He was also unfamiliar with subroutines and the strict order of the specification part.
Furthermore, Tsoding had trouble finding good references for statements (e.g. he couldn’t find read
&print
in a list of all intrinsic functions). He was also challenged by hard to google questions, such as where to define a function and where to define a type for an interface.Finally, there are some features he just does not like.When writing the interface to raylib, he found it very annoying to repeat use iso_c_binding
in every procedure.As soon as he needed derived data types, it got even worse, because he first had to import the type into the interface, then had to repeat import
in every interface. The lack of an unsigned integer type in Fortran made it even more difficult to use these interfaces, since using transfer
or other tricks (which could lead to overflow compiler errors) is impractical.
In addition, Tsoding found it impractical that lines get truncated if they are too long, trailing commas in array constructors are not allowed (like this [1,2,]
), and name collisions with the program name as well as type names (what’s the point of wrapping them in type(my_type)
if the type name collides anyway).When using pure functions, he wished they would be evaluated at compile time when called with constant arguments.
The Ugly
There are still some problems that cannot be solved directly because they are out of our control. But I think there are still ways to improve it.
In many cases, when he wanted to search for a feature on the web (e.g. parameter
), the first thing that came up were websites for old FORTRAN standards, which led him in the wrong direction.He was also very impatient.Most of the time, he would just skip through the sites looking for a block of code to copy, missing important clues. While this was the most frustrating thing to see (for me), I think the most frustrating thing for him was compiling with his outdated GFortran compiler, which gave very misleading compiler errors (wrong lines, unrelated hints, etc). Even though it wasn’t directly GFortran or Fortran’s fault, he automatically blamed Fortran. The compiler is the language!
Conclusion
From Tsoding’s experience with Fortran streams, it is clear that while Fortran offers many powerful features, especially for scientific programming, it also poses some challenges to those venturing into it from other languages.
His appreciation of Fortran’s capabilities in array operations and implied-do is a testament to the language’s unique strengths and its applicability in certain computational domains. However, the steep initial learning curve and unfamiliar concepts make the onboarding process a daunting task for many, preventing beginners from coding the Fortran way (using arrays and array operations).
The difficulties he encountered highlight several areas for improvement:
- Documentation & tutorials: Emphasise modern Fortran practices and steer beginners away from outdated material. Perhaps even a central repository or forum for reliable Fortran resources would be beneficial.
- Compiler feedback: It is vital that compilers provide accurate and helpful feedback. Encouraging the use of updated compilers and providing clear guidelines on compiler choice can reduce a lot of frustration.
- Language features: While some of the difficulties faced by Tsoding were due to unfamiliarity, others, such as the lack of an unsigned integer type and the repetitive nature of certain constructs, are inherent to the language. Such pain points could be areas of focus for future language improvements or standards.
In addition, while Tsoding’s approach may have been impatient at times, it is indicative of the fast-paced nature of modern software development, where developers often seek quick solutions. This underlines the importance of readily available, concise and modern resources for the language.
Ultimately, the Fortran community can use this feedback to streamline the learning experience for newcomers and strengthen the language’s position in the scientific programming landscape.
Thanks for taking the time to watch Tsoding’s videos and summarize his experience. A few comments:
When writing the interface to raylib, he found it very annoying to repeat
use iso_c_binding
in every procedure .
I think he is talking about the interface
in raylib.f03. (Unrelated – it’s better to use the .f90 suffix.)
Tsoding found it impractical that lines get truncated if they are too long
The line length limit is raised to 10000 characters in Fortran 2023, and compilers already have an option to allow arbitrarily long lines.
- Documentation & tutorials: Emphasise modern Fortran practices and steer beginners away from outdated material. Perhaps even a central repository or forum for reliable Fortran resources would be beneficial.
Beside the fortran-lang site there is also list of tutorials at the Fortran Wiki, some of which I added. It’s not by accident that the Fortran 77 category is at the bottom of that page.