TE
TechEcho
Home24h TopNewestBestAskShowJobs
GitHubTwitter
Home

TechEcho

A tech news platform built with Next.js, providing global tech news and discussions.

GitHubTwitter

Home

HomeNewestBestAskShowJobs

Resources

HackerNews APIOriginal HackerNewsNext.js

© 2025 TechEcho. All rights reserved.

Translate Fortran to C++ with AI and RAG

43 pointsby LosAlamosNerdabout 1 month ago

10 comments

jedimastertabout 1 month ago
I&#x27;m trying to think of a reason this couldn&#x27;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&#x27;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&#x27;s because it was specifically code written by scientists (i.e somewhat brute force and very straightforward) but there really wasn&#x27;t very many features that I can recall that didn&#x27;t have a direct C counterpart, other than column major ordering and arrays staring at 1.<p>Was I just blissfully unaware?
评论 #43740735 未加载
评论 #43742115 未加载
评论 #43740737 未加载
nevi-meabout 1 month ago
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&#x27;s in Kotlin that I&#x27;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.
评论 #43740617 未加载
评论 #43747004 未加载
评论 #43742065 未加载
评论 #43740581 未加载
musicaleabout 1 month ago
Good idea. I&#x27;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.
WalterBrightabout 1 month ago
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&#x27;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&#x2F;parser was welded onto the D compiler logic.<p>aaaand it wasn&#x27;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.
jll29about 1 month ago
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.).
Suracabout 1 month ago
there is no place for AI or C++ in this game. Just use a Fortran to C Transpiler . But i get it anything AI sounds modern and C++ because of reasons
almostgotcaughtabout 1 month ago
What is the point of this? Fortran is both faster than cpp and easier to write than cpp. It&#x27;s also by no means a dead or dying or whatever language. Smells like literally &quot;your scientists were so busy they forgot to ask why&quot;.
评论 #43741079 未加载
评论 #43741802 未加载
评论 #43740987 未加载
评论 #43740875 未加载
npalliabout 1 month ago
This is great effort, wonder how it compares to Fortran2Cpp<p><a href="https:&#x2F;&#x2F;github.com&#x2F;HPC-Fortran2CPP&#x2F;Fortran2Cpp">https:&#x2F;&#x2F;github.com&#x2F;HPC-Fortran2CPP&#x2F;Fortran2Cpp</a>
pankajdohareyabout 1 month ago
LLM as translators for Cobol code to Java or Go should be attempted. And Shut down the IBM mainframe rent seek business for good permanently.
评论 #43741772 未加载
评论 #43742947 未加载
评论 #43741717 未加载
评论 #43742215 未加载
hulituabout 1 month ago
&gt; Translate Fortran to C++ with AI and RAG<p>f2c ? But yeah, 1 level of abstraction sucks. We need around 10 to be satisfied.
评论 #43744791 未加载