Can Amazon Q assist with my mainframe COBOL programs?

3 minute read
Content level: Intermediate
2

This article explains how you may use Amazon Q to describe and understand a mainframe COBOL program logic in natural language.

Overview

Amazon Q is a new type of generative artificial intelligence (AI) powered assistant, that brings a set of capabilities to support developers and IT professionals. Among others, one feature provide conversational capabilities and assistance within the developer's IDE such as IntelliJ, Visual Studio (VS) Code, etc. It is integrated with with Amazon CodeWhisperer within the IDEs.

It provides expert assistance to a long list of programming languages like Java, Python, C, Go, etc. COBOL is not officially listed as supported language at this time. It's early days for Generative AI with COBOL, and the models are continuously learning and evolving every day. Thought will give a spin and see what wonder it can do with COBOL code.

Steps I followed:

  1. I downloaded the open source COBOL CICS carddemo application from github repo

  2. Used VS Code as IDE to try out Amazon Q. Followed the instructions here on youtube to install CodeWhisperer. Once I signed in to Amazon CodeWhisperer, it automatically activated the Amazon Q conversational capability in the IDE.

  3. On VS Code menu navigated to File > Open Folder... and selected the app folder of the downloaded carddemo application.

  4. From explorer window opened a medium complexity program COTRN02.cbl from cbl folder. Clicked on Amazon Q (Preview) on the left menu bar [5] to open the Chat window.

Choose COBOL

  1. On the Amazon Q chat window asked to 'Explain the source code'. It summarized the program functionality in bullet points.

Explain Program

  1. Next highlighted a section of code and right-clicked the to bring up the context menu. Selected Send to Amazon Q and then Explain.

Right Click

  1. It explained in details the COBOL code snippet logic in natural language. Pretty impressive.

Code snippet explain

  1. Next, tried to list all the COPY statements. It listed them correctly.

List COPY

  1. Asked to find the data type definition of a working storage variable. Bingo !!

Describe Data Type

  1. Gave another try on a different code snippet. I can definitely work with that..

Explain Add Transaction


Conclusion

Amazon Q behind the scenes is running a number of LLMs (Large Language Models) and the requests get routed and personalized depending on the trend of questions you ask or feedbacks you provide to the responses. Sometimes asking the question in a different way or using different wording can provide better response.

What it is able to achieve in its nascent stage is pretty impressive. It will learn and get better every day, and eventually will catch up with other programming languages.