YouTube video just posted here at the Fireship channel, which has 1.36e6 subscribers. In 3 hours, the video already has 42K views, 5K likes, and 300+ comments.
Topics Covered
History of Programming Languages
When was Fortran invented?
Who created Fortran
Is Fortran still used?
Fortran basics tutorial
What is Fortran used for?
The author uses the .f95 extension for the short code presented, unfortunately (better is .f90 to signify free source form). He spends some time explaining implicit typing and the need for implicit none. Removing implicit typing has been much discussed here. The language is spelled FORTRAN in the video title. I wish he had mentioned that modern Fortran has array operations, like Matlab.
The only problem with that video is… the 100 seconds. You can only scratch the very tip of the iceberg, and that only by speaking as fast as he does in the video. Inevitably, the past of the language takes over the majority of the extremely limited time available, since Fortran has a long history and you can’t just skip that.
Nevertheless the fact this video got many views and likes that fast is refreshing. And perhaps the fact it’s that short helped some people to a least hear about the reason terms like “high level programming language” and “compiler” were invented.
As for the file extension, I recently reluctantly adopted .f90 realizing the fact changing suffix every time a new standard is released leads nowhere, and .f90 is the de facto standard nowadays.
Regarding file name extensions, in hindsight it is unfortunate that the chosen terms “fixed” and “free” both start with “f”. As is, an extension like *.ff is somewhat ambiguous. If they had used some other synonyms for these, like “structured” and “unstructured”, then extensions like *.sf and *.uf might have worked. Ironically, the “free” form source code has more constraints on the programmer than the fixed form. Namely, spaces are required in many contexts in free form, keywords cannot have embedded spaces (with a few exceptions like enddo, endif, etc.) and literal constants cannot have spaces (1 234 567 890). In fixed form none of those constraints apply, and there is instead the column fields 1-5, 6, 7-72, 73-80 that have special meaning.
However, given the history and usage in the language, *.f and *.f90 seem adequate.
It is unfortunate that the video uses *.f95, which is mostly just confusing since there have been numerous language revisions since the 1995 standard, no one really programs using the f95 standard anyway, and actual usage of the *.f95 extension is rare.
No, the problem is not with .f95 file extension, but implicit none forcing you to declare integer :: n, doubled, which is why the sample code wouldn’t work. Unless implicit none is removed, then n is automatically an integer type, and doubled is automatically real type.
Of course, in such a brief video, only little can be shown. It is an appetizer for the language in general and not a class like e.g., the by Derek Banas. Though one may argue if the video caption already links to fortranwiki, an additional (prominent) link to fortran-lang.org or an additional slide with points of entry to the language were beneficial. Some of the commenters of the video indeed mention interest or/and a need to learn Fortran.
Yet regardless how constraint the examples advertising a language are, they must represent a benefit for the interested; else, they likely move on to the next. E.g. (with cheerful smile), a vim cup
For examples depicting code, my anticipations are that
these work when applied verbatim just as one is asked to provide a MWE addressing a question in a discussion. So not something like Amazon’s Fortran notebook mentioned earlier by Ivan (here). At present, the do loop in the short video does not meet this criterion.
that they reflect contemporary custom e.g., in terms of the syntax. Once some insight is accumulated, on still can gain additional one by looking into earlier approaches, learn to read and maintain source code inherited. Possibly because Fortran provides better backward compatibility across standards than e.g., Python 2 vs. Python 3, there still are beginner classes teaching Fortran as FORTRAN 77:
I’ve left a comment tor the creator to use an example that works and one that conveys a tad more in order to make it worth the ~10 seconds it takes up, sure to be ignored is the following:
integer :: n
do n = 1, 10
! Factorial of n
print "(i2,'! = ',g0)", n, product([( i, integer :: i=1,n )])
end do
end
Is this implied do loop correct? I couldn’t run it on GFortran. If it is correct, then I am confused because I thought all variables need to be declared in the beginning. Also, does implicit saving apply here?
With implied-do in DO CONCURRENT, array construction, FORALL and DATA statements, the scope of the construct or the statement is what applies to the index (or the indices). The type-spec of the index or indices can thus accompany those constructs / statements.
Note noimplied SAVE comes into play with the declaration of such index variables.