Can ChatGPT find new life for punch card era code?
Back in 2021 I wrote an article about using OpenAI’s Codex to translate COBOL code to JavaScript. Codex did a decent job translating simple COBOL programs. Now that ChatGPT is available, I wanted to see whether it was able to tackle more complex COBOL programs. In this article I share some examples of ChatGPT generating JavaScript from COBOL and talk about the overall experience of using ChatGPT to drag COBOL code into the twenty-first century.
To exercise with ChatGPT, I returned to the same excellent article I used in my 2021 article: 7 cobol examples with explanations, which contains a set of straightforward COBOL examples that can put ChatGPT through its paces. I used OpenCobol IDE to compile and run the COBOL programs.
Example 1 — hello world
To get ChatGPT to translate COBOL to JavaScript, I used the prompt “translate the following COBOL program to JavaScript:” followed by the COBOL code I wanted to get translated.
Here’s an example of exactly what the prompt and output looks like: