Live data from Hacker News

Translate Fortran to C++ with AI and RAG

lanl.gov

11–20 of 49 posts

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

#11
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]

I mentioned neither of the things you're shouting at me about.

> I also have some old code that's in Kotlin that I'd like to move to something else.

Something else was left unmentioned because I'm not even talking about Rust. My reference to it was that I've seen the approach before where a RAG is used to aid in translating C code, and it's an interesting thing which with more examples, might be easier to non-experts like me.

Translating languages is of great interest to various communities. I have friends stuck with a Scala codebase written by geniuses who are no longer around, and they want to move it to something else that the team is comfortable with.

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

#13

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. If someone can't correctly articulate the advantages of Fortran they shouldn't be migrating away from it. This is not to say that migrations should never happen.

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

#15
post #11
post #5

Earlier quoted context omitted.

[flagged]

I mentioned neither of the things you're shouting at me about. > I also have some old code that's in Kotlin that I'd like to move to something else. Something else was left unmentioned because I'm not even talking about Rust. My reference to it was that I've seen the approach before where a RAG is used to aid in translating C code, and it's an interesting thing which with more examples, might be easier to non-experts…

My bad. Sorry. Didn't read the full comment and you didn't deserve the accusations from me.

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

#16
post #13

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. If someone can't correctly articulate the advantages of Fortran they shouldn't be migrating away from it. This is not to say that migrations should never happen.

Chesterton's Fence

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

#17

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".

I wonder if they feel that the toolchains are just rotting.

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

#18

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 lo…

Doesn't CUDA handle FORTRAN as such?

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

#19
Good idea. I'd much rather write

   do concurrent (i = 1:n) 
     y(i) = y(i) + a*x(i)
   enddo
and then let the a compiler translate it into

    std::transform(par, x, x+n, y, y,
      [=](float x, float y){ return y + a*x; }
    );
if C++ is required for some reason.

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

#20
post #17

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".

I wonder if they feel that the toolchains are just rotting.

But they're not

https://github.com/flang-compiler/flang

https://flang.llvm.org/docs/

Post reply on HN