91 points · by armorer · 2y ago · 49 comments
- Program / Section-level flowchart generation based on AST (SVG or PNG) - Parse Tree generation (with export to JSON) - Control Flow Tree generation (with export to JSON) - Allows embedding code comments as comment nodes in the graph - The SMOJOL Interpreter (WIP) - Injecting AST and Control Flow into Neo4J - Injecting Cobol data layouts from Data Division into Neo4J (with dependencies like MOVE, COMPUTE, etc.) + export to JSON - Injecting execution traces from the SMOJOL interpreter into Neo4J - Integration with OpenAI GPT to summarise nodes using bottom-up node traversal (AST nodes or Data Structure nodes) - Exposes a unified model (AST, CFG, Data Structures with appropriate interconnections) which can be analysed through [JGraphT](https://jgrapht.org/), together with export to GraphML format and JSON. - Support for namespaces to allow unique addressing of (possibly same) graphs - ALPHA: Support for building Glossary of Variables from data structures using LLMs - ALPHA: Support for extracting Capability Graph from paragraphs of a program using LLMs - ALPHA: Injecting inter-program dependencies into Neo4J (with export to JSON) - ALPHA: Paragraph similarity map
Contributions / use cases are welcome!
If someone built a tool to translate the AST generated by this into one of these newer theorem-proving dependently-typed languages (examples: Idris/Idris2 come to mind, but also the Coq/Rocq theorem prover, Agda, Lean), would it be theoretically possible to not only translate this code into a newer language but also suss out bugs and literally prove correctness? (Given how important some of this COBOL code seems to be, such as at Medicare)
I know that one of the risks of changing the language that logic and computation is written in is unexpectedly changing the behavior or introducing new bugs; wondering if this might mitigate or almost entirely prevent that
All variables (well, in "classical COBOL" at least) are global variables. Since memory is constrained, a really common idiom is to have great swathes of punned, overlayed variables; in C terms it would be unioned structs. Subroutine A would have a var A-TEMPS divided into A-TEMP-VAR1 and A-TEMP-VAR2. Since routine B isn't on the same call path, that _same area_ could be also divided into B-TEMPS, B-TEMP-X, B-RESULT, and C-MOVEIN (because hey, code got changed). When you port this mess to Java you can (a) emulate unions with mind-boggling complex , huge, and fragile idioms, (b) tease out the actual code flow graphs and intent, or (c) some combination.
And no, automated doesn't go very far for (b); although the computer might be able to figure out that March doesn't have a leap day and so this path won't execute because of that, it _is_ the end of a quarter and so has an artificial closing-day tacked on _if_ this is for subsidiary Foo, but not Bar because they have a 0-day on the following month. Too many combinations to exhaustively compute, and requires a lot of human smarts to prune possibilities.
Especially as ground-up rewrites are often risky, and bringing it into a modern language might make it easier to incrementally improve/refactor over time.
I could write a cobol to c translator in a weekend. Nobody would buy it. Source: I've spent the last year and a half consulting on a huge project to rewrite a cobol codebase.
The only thing I've used like it recently was OQL (Object Query Language) for querying the Java heap.
I remember Intellij had some static dataflow analysis and I do miss it working in RubyMine.
This moves the focus from Cobol specific tools to Cobol agnostic tools.
Maintaining and modernizing these critical systems is important work.
Edited to specify not a bank.
In the 80s (and probably before), every system I worked on had at least one critical COBOL program missing source code.
I am wondering if you noticed the same with this project.
Any "lets move this COBOL to something else" will, more often than not, flounder on the fact that "rewrite all this functionality" will cost massively more than "just find someone to extend what we already have".