I'm trying to think of a reason this couldn't be done more directly with a pretty run-of-the-mill transpiler. Like I understand if this is a technical demo and there is a LOT of Fortran code, but...?<p>I've actually had to do this with a couple of different Fortran projects when I was in college, I translated them to C for various reasons.<p>Maybe it's because it was specifically code written by scientists (i.e somewhat brute force and very straightforward) but there really wasn't very many features that I can recall that didn't have a direct C counterpart, other than column major ordering and arrays staring at 1.<p>Was I just blissfully unaware?
Microsoft demoed a version of their GraphRAG that translated C code to (I believe) mostly idiomatic Rust, and it ran without errors.<p>I tried to find reference to how they did it, does anyone know?<p>It sounds like this approach of translating old code could help speed up teams that are looking at rewrites. I also have some old code that's in Kotlin that I'd like to move to something else. I had a bad NullPointerException take down my application after missing a breaking change in a Kotlin update.
Good idea. I'd much rather write<p><pre><code> do concurrent (i = 1:n)
y(i) = y(i) + a*x(i)
enddo
</code></pre>
and then let the a compiler translate it into<p><pre><code> std::transform(par, x, x+n, y, y,
[=](float x, float y){ return y + a*x; }
);
</code></pre>
if C++ is required for some reason.
A member of our community accidentally discovered that the D compiler could translate C code to D code.<p>D has a module system, where you import a module and it pulls the global declarations out of it. To speed up this process, there's a compiler switch to output just the global declarations to another file, a .di file, that functions much like a .h file in C.<p>Then there came along ImportC, where a C lexer/parser was welded onto the D compiler logic.<p>aaaand it wasn't long before the switch was thrown to generate a .di file, and voila, the C code got translated to D!<p>This resulted in making it dramatically easier to use existing C headers and source files with D.
As a slight tangent, a re-write in another language is also an opportunity for the human engineer to re-design parts of the software that was clunky before or so that in the new target language idioms can be used.<p>Using automatic tools - whether AI-based or transpilers - leaves that opportunity unused, and both approaches are likely to create some additional technical debt (errors in translation, odd, non-idiomatic ways of doing things introduced by the automatism etc.).
What is the point of this? Fortran is both faster than cpp and easier to write than cpp. It's also by no means a dead or dying or whatever language. Smells like literally "your scientists were so busy they forgot to ask why".
This is great effort, wonder how it compares to Fortran2Cpp<p><a href="https://github.com/HPC-Fortran2CPP/Fortran2Cpp">https://github.com/HPC-Fortran2CPP/Fortran2Cpp</a>