bind(C) philosophy: pointer-by-value or type-by-reference?

Well it’s quite new - Fortran 2018. There are not many easily findable examples available. I have only ever seen examples by @FortranFan. I believe it is used in some recent versions of MPI libraries.

You may be aware of recent efforts on linear algebra standardization in C++. This includes the introduction of the mdspan (multi-dimensional span) class in C++, along with a multiple-parameter operator[] for simple array access. This will elevate the “array” experience in C++ bringing it almost on par to Fortran. You can already test mdspan via the Compiler Explorer.

I sometimes see Fortran users who loathe C++, but once you get to know it better, it’s actually very nice to work with. I can certainly understand what Bjarne Stroustrup meant with “Within C++, there is a much smaller and cleaner language struggling to get out”. A very skilled colleague of mine put it this way:

C++ is really complex. But withdrawing to the subset of non-inheritance and value semantics, and using the STL, C++ is like Python. But that simplicity comes at a price. One needs to be disciplined. And you don’t have the freedom anymore, C++ otherwise offers. In a sense, you reduce complexity intentionally by self-restriction.

One of the things that Fortran programmers tend to miss about C++ is just the sheer size of its community. If you take a look through some the CppCon recordings, they are producing excellent material, lots of which is also highly relevant for modern Fortran programming. I’ve found that many of the lessons in Effective C++ by Scott Meyers also carry over to Fortran with some language-specific tweaks.

3 Likes