TE
科技回声
首页24小时热榜最新最佳问答展示工作
GitHubTwitter
首页

科技回声

基于 Next.js 构建的科技新闻平台,提供全球科技新闻和讨论内容。

GitHubTwitter

首页

首页最新最佳问答展示工作

资源链接

HackerNews API原版 HackerNewsNext.js

© 2025 科技回声. 版权所有。

Translate Fortran to C++ with AI and RAG

43 点作者 LosAlamosNerd大约 1 个月前

10 条评论

jedimastert大约 1 个月前
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-me大约 1 个月前
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 未加载
musicale大约 1 个月前
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.
WalterBright大约 1 个月前
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.
jll29大约 1 个月前
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.).
Surac大约 1 个月前
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
almostgotcaught大约 1 个月前
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 未加载
npalli大约 1 个月前
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>
pankajdoharey大约 1 个月前
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 未加载
hulitu大约 1 个月前
&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 未加载