By Tom Malick, Vice President of Software Architecture
How do you translate millions of lines of legacy code from one language or framework, platform, or chipset to another? It’s a problem many Federal agencies are facing as they upgrade aging legacy systems. And with aging legacy systems, also comes dated or no documentation. To reduce costs and timelines for code modernization, some agencies are turning to automated software programs for refactoring.
Most of these programs will only get a code modernization project about 50-60% of the way to completion. To understand why, we need to look at the difference between syntax and intent. An artificial intelligence (AI) that understands the intent of the code it is refactoring can produce code that is cleaner, more accurate and more efficient than is possible with a direct 1:1 translation.
Want to learn more about the power of intent for code modernization? Contact us to learn how we can slash code modernization costs and timelines with intent-based AI.
Direct Translation vs. Meaning and Intent
To understand the difference between a syntax-based vs. intent-based approach to code refactoring, think of the difference between translating a document using the automated Google Translate tool and relying on a master human translator. Google Translate is an impressive program; it does a pretty good job of getting the general idea across when translating from any human language into any other human language. However, its (sometimes hilarious) misses are the subject of countless internet memes. There is a reason that publishing houses still hire human translators to translate novels, scientific papers and important documents.
The reason humans still do better at many translating tasks comes down to understanding intent—what the words actually mean. Instead of simply translating a phrase or sentence exactly word for word, master translators can use their understanding of the meaning to find the most efficient and logical way to get that meaning across in the new language.
The concept of “intent” in computer code is similar to the concept of “meaning” in human languages. Intent refers to what the code is meant to do, regardless of the language it is written in or exactly how the programmer has chosen to code it. If you want a computer to calculate the sum of two numbers input by a user, there are many different ways to write that in code, depending on the language you are using. But the intent is the same, no matter which language the programmer uses. And so is the result: the program will generate the sum of whatever two numbers the user provides.
When an automated code refactoring program understands the intent of a piece of code, it can recreate that same intent in any other language. Rather than simply translating based on syntax (e.g., “_______ in FORTRAN = _______ in JAVA”), the AI can look at what the code is intended to do and replicate that in the most efficient and secure way possible in a different programming language.
Teaching an AI to Understand Intent
Built on our NCI Shai® (Scaling Humans with Artificial Intelligence) philosophy, our NCI Empower™ platform uses tools and engineering to teach AI to understand the intent. Holonic Technologies CodeIntent™ is a semantic learning platform that enables the AI to learn any computer language by feeding it large amounts of example code. With enough practice, it learns how to analyze code both for syntax (how the code is put together) and semantics (what the code is intended to do).
Once the AI has learned a new language, it can take a piece of code and put it into what we call “intent space”—the language of pure mathematics. This is the underlying mathematics that is the basis for all computer programming.
Once the intent has been expressed in mathematical terms, the AI can create that same intent in any other computer language by using deterministic AI principles. The AI is not translating directly from one computer language to another. Instead, it is breaking down the old language into its intent and building that same intent back up in a new language. Intent space abstracts away the “how” in a computer program—the exact way that the programmer solved the problem and the language the solution is written in—and focuses only on “what is this code intended to do.”
The Power of Intent in Code Refactoring
When it comes to code refactoring, intent matters. When we analyze code for semantics as well as for syntax, we can create new code that is more secure and efficient and better documented than is possible by performing a direct 1:1 translation.
This is especially important when refactoring older legacy programs. These programs tend to develop “code bloat” over time as new functionality is added. An automated program conducting a direct 1:1 translation also brings over redundancies, dead ends and inefficiencies that build up in old code through years of successive updates by different programmers. Breaking the program down into intent space allows the AI to eliminate bloated code and create a new, streamlined version—in a brand-new language, or even in the same language.
The ability to understand intent also provides other powerful benefits.
- It improves the accuracy of code refactoring and reduces the risk of introducing unexpected behaviors or bugs that can result from a direct 1:1 translation.
- It can be used to generate missing documentation so that the code is easier to maintain in the future.
- It allows the AI to find and fix security vulnerabilities and other problems with the code while it is performing the migration.
Using intent space, we can even have the AI introduce new functionality as part of the code refactoring process. This eliminates “code freeze,” allowing agencies to continue to expand functionality and address the needs of their users while code is being migrated. The software not only ingests existing code into intent space, but is also can ingesting design documentation, such as UML and SysML, into intent space, as well as binaries into intent space, if source code or design docs aren’t available.
Holonic’s AI software has already been trained on 14 legacy and modern languages—and it’s capable of learning many more. It typically takes about 2 weeks to train the AI on a language it doesn’t already know. It has already been put to the test for several code modernization projects for Federal agencies and U.S. DoD clients.
Read our previous blog, Four Reasons Federal Agencies Should Modernize Legacy Systems Now, to learn why NCI engineers, using Holonic Technologies AI-driven software, can quickly modernize your legacy code and reduce your program costs. Contact us to learn more and receive a demo.