This announcement is for those of you who have expressed concerns
about the direction that Fortran development has been taking in the
recent past, and who would like to see both an alternative take on
generics, as well as modern-day OO programming capabilities in the
language.
For some time now, I’ve been designing, together with @certik, and
@tyranids, a traits (or polymorphic interfaces) system for
Fortran. Its aim is to endow the language with state-of-the-art
capabilities for both compile-time and run-time polymorphism, that
are only equalled by those of the Swift, Rust, Go, or Carbon
languages.
We have surveyed all these latter modern languages in order to distill
their very best features with respect to polymorphism, and to tie
them into a coherent and consistent package of extensions for
Fortran, that is both powerful, yet easy to use (also for
non-experts), and backwards compatible with the present language.
The result is described in the following document, whose latest
version can always be found on Github, along with the code for all its
examples: Traits for Fortran
The design features:
- Traits based, flexible, modern-day, OOP (as in Swift, Rust, Go)
- Traits based, fully type-checked, generics, interoperable with both
procedural, functional, and OO programming (as in Swift, Rust, Go) - Non-necessity for explicit instantiation of generics (as in Swift)
- Type sets as traits, to easily formulate generics constraints (as in Go)
- “Zero cost” static polymorphic method dispatch via generics (as in Rust)
- Interoperability with class inheritance, but also support of “sealed” classes
- Room for future growth, e.g. for future support of array-rank-genericity,
or compile-time polymorphic union types
@certik plans to prototype this complete design in the open source
LFortran compiler, once LFortran has reached the point of providing
stable support for Fortran’s legacy polymorphism and OO features.
Yet, I wish to point out that we have explicitly developed this design
for the benefit of the entire Fortran community, not just one
particular project. Our ultimate goal is to give Fortran users the
chance to test out, in actual compilers, all those features of modern
languages that they have been repeatedly asking for, to no avail, in
this forum.
We believe that these capabilities, once they will become widely
available in Fortran compilers, will give the language a significant
edge over its competitors in the fields of numerical, scientific, and
high-performance computing, and will thus help to establish Fortran’s
long-term dominance in these fields.
What you can do to help:
-
If you like our design, express your support! Let us also know about
any critique you may have. We welcome critique, as long as it is
constructive. -
Contribute to the development of LFortran, and other open source
Fortran compilers, so that this design can get implemented faster! -
Contact the developers of your Fortran compiler, and let them know
that you wish to see these features also in their compiler! -
If you are a Fortran compiler developer, contact us for a
collaboration! -
Once we have a first compiler implementation of the design, use it
and provide feedback, like bug reports, etc., so that we can fix any
teething issues! -
If you are proficient in Swift, Rust, Go programming, etc., we’d
like to hear from you whether there is any feature connected to
polymorphism in these languages that you are missing, and would like
to see in the present design.
Regards, Konstantinos