What does a JOBOL program means?
Glauco Reis
LinkedIn Top Voice 2024 | Mestre em IA?? | Qiskit Certified Developer ?? | Qiskit Advocate?? | Palestrante??| IBMEr?? | Evangelista?? | Escritor??? | Modernization Expert ???? | Java Dev ?? | Quantum Ambassador at ??
When we talk about AI, what comes to mind are applications related to the text interpretation, generation and conversion of texts and languages. But AI is silently invading other areas, such as IT. It is doing unpleasant tasks for humans, such as analyzing huge LOGs for common problems, and even generating code from textual descriptions or conversions between old languages and newer ones.
What I would like to discuss here is a term that we have heard a lot, JOBOL. It appears when we try convert codes from COBOL to Java. Wow, why go back to COBOL now? I know what I'm going to write here will be repetitive, but research in 1990 showed that of the 300 billion lines of code that existed, approximately 80% or something around 240 billion lines of code were COBOL. And in 2020, an IBM estimate indicated that 200 billion lines of code were still running in COBOL. And its impossible to count COBOL line programs from GITHUB, STACK OVERFLOW and other open platforms, because many of these COBOL codes are kept under mainframes within large corporations. But why is COBOL so "immortal"?
Well, according to the words of Martin Fowler, someone who needs no introduction, COBOL is considered a DSL (Domain Specific Language). Unlike C, C++ and Java, which are general-purpose languages, COBOL is suitable for a specific niche in the market. Apparently, due to its durability, it is the most important market niche that exists. Of course, there are other languages considered DSLs as well: FORTRAN for engineers and scientists, but that was gradually replaced by Python, MathLab and Mathematica. In fact, languages like R, MathLab and Mathematica are used by mathematicians. We also had languages like Lisp and Prolog, used for AI in previous waves of technology, as well as many others. What a DSL language essentially does is bring the programming activity to a level where people who are not deeply connected to the programming activity could also carry out programmatic activities (doesn't this phrase sound like Excel macros?). In other words, it makes programming simpler for non programmer (almost that). And in fact, COBOL is a simple, incredibly well-structured language. You may hate the indentations defined for each session of the COBOL program (unless if you are a Python programmer), but it is still clear and concise. A COBOL program is ideal for business activities and handling business information. It's not suitable for modern things like extensive use of messaging, REST, SOAP, events and other things we hear a lot about today. But the point is that even business-oriented systems cannot afford to ignore modernities, such as integration with social networks, mobile technologies and other mechanisms that talk directly to customers. Therefore COBOL needs to communicate with these technologies. But this conversion cannot be "frivolous", like putting in an AI-based meat grinder that converts the 200 billion lines of code to a more "modern" language, such as JavaScript, Python, C# or Java.
Because today's modern language will be tomorrow's outdated language.
These codes have been running for 50 or 60 years, and moving everything massively will be a risk. But, what is JOBOL after all? Don't worry, we'll get there!
All languages create specific dialects throughout their existence. In Python we use the term pythonic, for example. All languages do this, and if you need help and attention from another programmer, you only receive if you follow these best practices and your code is "clean". We all know that we shouldn't create Java or C# code in a single class, with a single method with 2435 lines inside it. If the code does not follow good practices, the community that is helping will probably use the famous phrase "throw everything away and write it again!".
When a generative AI converts code, for example, it does so in the form of token interpretation (this is in the DNA of a generative AI). It picks up TOKENS from input and generates and send other TOKENS to output along the conversion. The issue is that code being generated sequentially tends to create sequential resulting code that ends up applying bad practices. Please show me this, Glauco! Look at this program in COBOL:
Ahhh, but I don't understand anything about Cobol! Me neither, but let's learn together. The COBOL program is divided into DIVISIONs, some of which in the program are "IDENTIFICATION DIVISION", "ENVIRONMENT DIVISION", "DATA DIVISION" and "PROCEDURE DIVISION". It starts by defining two structures, one on line 11 called TRANSACTION-STRUCT and the other on line 22 called TRANSACTION-RECORD. They are slightly different. In other languages, it is as if we were creating two Structs, Classes or structure that stores this data. After this, on line 33 it prints something on the screen, on line 34 it opens a file and on lines 35 and 36 it writes and closes the file. Data has been assigned in lines 28, 29 and 30. Let's use generative AI to transform this code into Java. It doesn't really matter which one I used, and you can experiment on your own even with the most famous one you find. The generated code looked like this:
Like a charm, right? He created a main class, defined the fields and assigned the values, and ahead it open a file, save the contents and close file. Thats simple! Now imagine doing this for thousands of programs on your company. But what's wrong here?
This program does not follow good programming practices, it is what we would call JOBOL. Let's get into the details. Up there we have two structures: TRANSACTION-STRUCT and TRANSACTION-RECORD. The fact that we don't use one of the structures doesn't mean we won't use it at another time. They exist, and they are different. TRANSACTION-RECORD was where we put the values, and the AI decided that it would be the only structure to create. He also didn't imagine that the structure could be used at another time, and therefore placed loose fields within the class. The code works, but it is not "JAVONIC" (like PYTHONIC). And thinking in terms of AI, it seems reasonable. The first structure was found but not referenced, in the second structure the AI collected all the data and generated the final recording. If you are a Java programmer, I imagine you have already thought of several improvements to AI-generated codes. Let's look at them: first, the ideal would be to create two classes, with constructors that receive the values in a consistent way:
All getters and setters should also be created:
That concatenation of values into a single String, generated by AI, would be much better if it were done in a Java toString() method. This way we could use it in several places without worrying.
The elegant way to compare two structures is using an equals method:
领英推荐
And if your intent is use this structures on a hashtable in the future, the best thing would be to generate a hascode() for this structure:
It would be nice if the structure class knows how to saved itself, receiving a stream as parameters, right?
And why not do the same with the other object found? After all, they are different:
Of course I will not repeat everything here, but if I were a good programmer I would generate all these codes, right? In the same way we did with data by isolating it into classes, the treatment of functionality should also be isolated:
Once these supporting classes were created, it becomes much more "object-oriented" to generate the main program code:
We choose in the programCobol71FirstSentences method which file structure will be used for recording, and we pass this structure to instances of structure classes. Next time if I need to do the same with other objects, it is far more easier. This is that moment when you would say to me, ahhhhhh but an AI will never reach this level of code generation, right?
What if I told you that these codes were generated by an IBM Cobol code conversion tool called WatsonX Code Assistant for Z?
It uses a set of technologies, which in addition to AI to generate a better quality code. This is an evolving product, but it proposes is that code conversion should be done with a much better quality than a JOBOL, and following the object orientation principles defined by Java!
Contact IBM or seek more information at this link if you need to modernize your COBOL applications, and do not want to generate a JOBOL program that will give you a headache in the future!
Wow, a very long post and at the end, a call to use Watson/X. The article says it doesn't matter which AI you use, but in fact it does. There are 2 problems: first, when you paste the customer's source code into most AI prompts, you expose that code. Most customers don't want their COBOL source code exposed -- but right now, customers don't know what their staff and contractors are doing along those lines. The second and much larger problem is that all the AI implementations right now, including Watson/X, require a very large number of tokens to convert programs to different languages. A few hundred lines of old code? Not a problem, but over 1,000, problems survace. In contrast, ResQSoft Engineer will take over 40,000 lines of COBOL (or JOBOL) and produce a Spring Boot equivalent with good structure and modularity -- with no access to the internet. About JOBOL: when you convert COBOL to Java line by line, the Java emulates COBOL. Every COBOL statement becomes a call to a proprietary API. The result is that you have to know both COBOL and Java to work with JOBOL source code efficiently. It's the COBOL emulation that gives JOBOL its name, not the procedural nature of the code.
A lead Solutions Architect and Presales Consultant | Mainframe Modernization and Migration | Azure and AWS | Mainframe Workload Optimization | US and European Business of Banking | Project Management | Core Programmer
9 个月Excellent!!!!……Business enterprises may convert COBOL code into JAVA, move away from MF…. Then what next???. Do business enterprises believe in Cloud infrastructures like they have been in Mainframe ?
Mainframe and DevOps Senior Expert, Head of Mainframe Chapter. AI for Mainframe knower
9 个月Yes we know that is a no sens??
z/OS Technical Support
9 个月Thanks for sharing Glauco!