Live data from Hacker News

Translate Fortran to C++ with AI and RAG

lanl.gov

31–40 of 49 posts

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

#31
post #29

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.

The soon to be GCC 15 release will contain a COBOL frontend. Also other non mainframe compilers have existed for a long time, both proprietary and FOSS. Thus, availability of a compiler is but a small piece of the puzzle. The real problem is the spider web of dependencies on the mainframe environment, as the enterprises business processes have been intertwined into the mainframe system over decades.

Which is why i think cross compiling to other dependencies and porting to other languages is a better solution. Many of these dependencies could be hardware specific. As long as core business solutions could be ported would be a win for everyone stuck in decades of vendor lockin.

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

#32
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.

Unlike C++, they even got their standard package manager - fpm[1].

[1] https://fpm.fortran-lang.org/

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

#33
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…

I do not believe it ran without errors on all cases.

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

#34

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?

Yeah, but there's also N% chance that it's silently wrong.

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

#35

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…

Yeah I've used FORTRAN to C transpilers before too and they worked fine. There were some downsides though like it has to add and subtract 1 everywhere to deal with FORTRAN's 1-based indexing.

In theory AI could do a more idiomatic translation, but I think I would still prefer the janky but correct translation over the looks nice but probably subtly buggy AI one.

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

#36

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.

Apart from cobol is only part of the reason for running on a mainframe. The other part is the orchestration and "resilience" of the mainframe platform

You can run cobol on x86, there are at least two compilers.

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

#37
post #32
post #17

Earlier quoted context omitted.

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

Unlike C++, they even got their standard package manager - fpm[1]. [1] https://fpm.fortran-lang.org/

It is as standard as vcpkg and conan.

ISO Fortran does not acknowledge the existences of FPM, just like any programming language ISO standard, the ecosystem is not part of the standard.

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

#38

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.

Apart from cobol is only part of the reason for running on a mainframe. The other part is the orchestration and "resilience" of the mainframe platform You can run cobol on x86, there are at least two compilers.

Resilience == redundancy, it has been successfully replicated by almost every organisation without mainframes. M-MANGA (Meta, Microsoft, Apple, Netflix, Google, Amazon) Infrastructure is quite resilient.

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

#39
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.

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

Post reply on HN