On 2014-04-10 3:10 AM, FortranFan wrote:
...
> The authors make pointed comments about some of the limitations they
> faced with Fortran, "Three issues specific to Fortran that resulted
> in employment of a more repetitive or cumbersome syntax than in C++
> or Python were observed:
> * Fortran does not feature a mechanism allowing to reuse a single
> piece of code (algorithm) with different;
Sort of true, and sort of not true. There are reasonably well known
"tricks" that you can play with INCLUDE and implicit typing that allow
you to use a single piece of source code with different types. But it
is a bit of a hack and it I strongly think better support for "generic
programming" should be added to future revisions of the language.
If and when this feature is added to the language I hope that the
experience from C++ and other languages is taken into account - C++'s
template mechanism operates at a level that is marginally above dumb
token substitution. When things go wrong the programmer then tends to
get a morass of dumb error messages (mentioned in the paper). There
have been subsequent attempts by the C++ community to fix this at a
language level - I've lost track of where they are with that.
Consequently I hope that the Fortran approach comes in at a higher
level. Please make generic programming much more than just text
substitution.
> * Fortran does not allow function calls to appear on the left hand
> side of assignment
Not true - this was added to the language in Fortran 2008. But sort of
true, in that compiler support is very limited.
> * Fortran lacks support for arrays of arrays (cf. Sect. 2.2)."
It lacks built-in support for these - but as the authors have done, you
can easily enough define the type that achieves arrays of arrays, *and
then some*. When you look at the design in total (which requires full
F2003), I think it makes more sense.
At times this, and the resulting verbosity, has annoyed me, but I think
initially it is best dealt with using the generic programming alluded to
above. I have a half baked idea for some sort of "forwarding" system
for types that could help alleviate this too, plus offer other capability.
There is also an element of needing to adapt your coding style to suit
the idioms of the language here.
Related to this (because it is part of the broader language design) - if
they used (or were able to use) derived types with length type
parameters I think their code would be simplified somewhat. There are a
few things that are a little bit hacky that could probably be dispensed
with (e.g. use of allocatable attribute such that a dummy array argument
picks up the bounds of the actual argument), storing a length in
addition to the implicitly stored length of allocatable components, the
need to explicitly write a constructor for some types).
> "Fortran is a domain-specific language while Python and C++ are
> general-purpose languages with disproportionately larger users'
> communities."
True, though why "*dis* poprortionately"? The user base proportions
seem about right to me.
> The OOP features of Fortran have not gained wide popularity among
> users.
Without hard data to support my case, bar observation of forums and
newsgroups like this, I don't think this is a reasonable statement, or
requires qualification. Compiler support for this feature is still
relatively fresh - a mere five years ago I don't think it would have
been possible for these features to practically be used. Existing code
bases are also often subject to coding standards based on the available
language capability at the time the code base was commenced and there is
considerable inertia associated with revision of those coding standards.
Where compiler support and coding standards allow, I think these
features are reasonably popular.
The absence of editor syntax highlighting for some editors is one of the
reasons that the authors made this assertion. I think that not
particularly relevant (plus there are other editors in popular use out
there that do support the relevant highlighting).
> Fortran is no longer routinely taught at the universities [28],
> in contrast to C++ and Python. An example of decreasing popularity
> of Fortran in academia is the discontinuation of Fortran printed
> editions of the "Numerical Recipes" series of Press et al."
I think some of those observations are more a consequence of the domain
specific nature and potential user base size, or reflect real but now
historical decreases in the popularity of the language.
I suspect, again without hard data, the revisions to the language, in
F2003 in particular, have resulted in an increase in the popularity of
the language, in absolute terms.
> The built-in standard libraries of Python and C++ are
> richer than those of Fortran and offer versatile data types,
> collections of algorithms and facilities for interaction with host
> operating system.
The first part is true enough. The "interaction with host operating
system" part is a bit silly - it is a bit hard to imagine a practical
language (or language plus basic library) that didn't provide facilities
for interaction with the host operating system. By all means argue
about the scope of that interaction, but in terms of true standards, the
facilities provided with F2008 aren't that far removed from those
provided with C++.
> In the authors' experience, the small popularity of
> OOP techniques among Fortran users is reflected in the library
> designs (including the Fortran's built-in library routines).
Correlation is not cause. The designs of the "built in library"
(intrinsic procedures) and user libraries simply reflect the capability
of the language (and compilers for the latter) at the time the intrinsic
or user library thing was added.
"New" libraries written for the current standards and current compiler
capability use new language features.
> What makes correct use of external libraries more difficult with Fortran
> is the lack of standard exception handling mechanism, a feature long
> and much requested by the numerical community
Really? As a former C++ programmer, this surprises me - exceptions
aren't something I particularly miss. I think they have their uses in
the context of that language, but even then, there's much debate about
when and how exceptions should be used.
You need to adapt your coding style to suit Fortran, but that adaptation
isn't exactly extreme or unnatural.
C doesn't have a standard exception handling mechanism, but that doesn't
appear to have constrained the range of libraries available for or
written in that language. As of F2003, those libraries are practically
easy enough to use from standard Fortran too. Given the experience of
that language, I think the rationale in the quoted sentence is rather
dubious.
Some capability for handling numerical "exceptions" has been added to
the language - with the IEEE stuff.
That said, I would like to see more general purpose libraries written
for Fortran. I think some aspects of the language do hinder the writing
of those libraries - here I will plug the generic programming angle
again. I think it is a mistake to try and load too much stuff into the
intrinsic procedure side of things.
I see some familiar names in the Acknowledgements!
I had a quick look at the code. It makes user of pointer result
functions (and pointers in general) which makes me a bit nervous, but
I'd have to spend more time understanding how they work things in order
to comment further. Perhaps not material, but there are a few arguments
could do with the INTENT attribute, a few functions could be marked
PURE, I think there might be the occasional stray POINTER attribute and
naming free form source with a .f extension is a bit odd).