Live data from Hacker News

Translate Fortran to C++ with AI and RAG

lanl.gov

1–10 of 49 posts

Re: Translate Fortran to C++ with AI and RAG

#3
Microsoft demoed a version of their GraphRAG that translated C code to (I believe) mostly idiomatic Rust, and it ran without errors.

I tried to find reference to how they did it, does anyone know?

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.

Re: Translate Fortran to C++ with AI and RAG

#5
post #3

Microsoft demoed a version of their GraphRAG that translated C code to (I believe) mostly idiomatic Rust, and it ran without errors. I tried to find reference to how they did it, does anyone know? 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 NullPointerExcepti…

[flagged]

Re: Translate Fortran to C++ with AI and RAG

#6
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...?

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.

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.

Was I just blissfully unaware?

Re: Translate Fortran to C++ with AI and RAG

#7
post #5
post #3

Microsoft demoed a version of their GraphRAG that translated C code to (I believe) mostly idiomatic Rust, and it ran without errors. I tried to find reference to how they did it, does anyone know? 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 NullPointerExcepti…

[flagged]

Or he’s just mentioning the other major transpiler he’s heard of recently that happens to be C to Rust and wondering how it works and if it could be adapted to other language pairs. You’re the one that’s taken the conversation in a super weird direction all by your lonesome.

Re: Translate Fortran to C++ with AI and RAG

#8
post #3

Microsoft demoed a version of their GraphRAG that translated C code to (I believe) mostly idiomatic Rust, and it ran without errors. I tried to find reference to how they did it, does anyone know? 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 NullPointerExcepti…

From the looks of [1] they have a graph DB storing the code structure and acting as the RAG for an LLM.

[1] https://microsoft.github.io/graphrag/

Re: Translate Fortran to C++ with AI and RAG

#9

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...? 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. Maybe it's because it was specifically code written by scientists (i.e somewhat…

What you want isn't really "output C++ code that is pedantically equivalent to this Fortran code but with the array indexing fixed up", it's usually more like "translate this Fortran module into something that I can offload to a GPU using CUDA/ROCm/etc. with the same high level semantics, but GPU-friendly low level optimizations", and the exact composition of those low level bits probably don't look exactly like a loop-by-loop translation.

Re: Translate Fortran to C++ with AI and RAG

#10

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...? 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. Maybe it's because it was specifically code written by scientists (i.e somewhat…

I don’t know what the transpiled code would look like vs that rendered by an LLM, but maybe the hope is that latter will be more readable?
Post reply on HN