The new C++ 23 standard will get first class multidimensional arrays, which was the last main missing feature of C++ compared to Fortran. The main issue of using C++ for numerical computing was that each project used a different multidimensional array library (or reinvented their own) with different syntax and semantics, which prevented easy reuse of array code between projects. That will now be fixed with a unified syntax, so I expect the C++ array libraries will converge and one will be able to write numerical array code in C++ that will be reusable across projects. And with that I also expect compilers to be able to optimize multidimensional arrays more.
We can use this particular example to learn quite a few nice lessons for Fortran, and I am hoping we can improve our standardization process accordingly:
-
GitHub is used to track the proposals for this feature: P2128 Multidimensional subscript operator · Issue #845 · cplusplus/papers · GitHub, you can see all the revisions and the current status of the feature
-
Final revision paper: http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2021/p2128r6.pdf
-
The paper is nicely formatted with links, colors, syntax highlighting, etc.
-
They have a prior compiler implementation (in an open source compiler) and an online demo (both linked from the paper)
-
They have deprecated the rarely used comma operator syntax in
[ ]
in C++20, and then reused the syntax for an expected widely used feature (multidimensional arrays) in C++23. Read the “What about comma expressions?” in the FAQ part of the paper for more details. -
I assume compilers will support the old syntax with a compiler option, so that old code that would use this rare feature does not break.
-
We have a lot of old stuff in Fortran like that, which is rarely used, but which prevents new more widely used features to be introduced. There are multiple ways we can introduce new features and keep old code compiling. Not requiring
implicit none
comes to mind. There are many other such examples. -
They release on a 3 year cycle
Here are issues at our J3 GitHub repository that suggest to fix some of these:
- Consider releasing Fortran standard every 3 years instead of 5 · Issue #36 · j3-fortran/fortran_proposals · GitHub
- Proposal for Workflow · Issue #26 · j3-fortran/fortran_proposals · GitHub
- Proposal web-page generation (meta) · Issue #230 · j3-fortran/fortran_proposals · GitHub
- Eliminate implicit typing · Issue #90 · j3-fortran/fortran_proposals · GitHub
The most frequent argument that I hear why the above cannot be done is that it is too difficult, it would not work, it is not allowed by ISO rules and other objections. The C++ process clearly shows that this is not too difficult, it works, and it is allowed.
So the main reason why the above is not done is that we do not want to do it. That is indeed a very good argument (I am serious): just the fact that something is good for C++ does not necessarily mean it is good for Fortran. There are good arguments why it is better to release on a 5 (or more) years cycle, why not to use github, why not to use better formatting for papers, and why to forever keep typing implicit none
(as an example). So let’s have that discussion.
Why not do the above? That is my vision how the Fortran Standards Committee could work in the future.