The syntax conversion between programming languages isn’t the only way to convert a code from one language to another. It is the process of transforming data while preserving the structure as much as feasible. Recent research says that migrating an existing codebase to a more current or efficient language, such as Java or C++, necessitates skill in both the source and the destination languages and can be expensive. The Commonwealth Bank of Australia, for example, spent approximately $750 million over five years to switch its platform from COBOL to Java. In principle, a transcompiler can save time by eliminating the need to rewrite code from scratch. Still, they are challenging to implement in practice since different languages have different syntaxes and rely on different platform APIs, standard library functions, and variable types.
The migration of legacy code into another programming language can be accomplished at various levels, each of which is more ambitious and harder to implement. As a result, as we progress through the levels, the necessity for manual conversion grows. At the most basic level, migration is the process of converting code from one language to another. At a higher level, the system structure may be altered, for example, by converting code written in a purely procedural language to code written in a purely object-oriented language. At even higher levels, the global architecture may need to be altered. It is becoming increasingly difficult to maintain consistency between different languages as new technologies emerge daily. New features are also introduced when programming languages advance. As a result, any inter-conversion compilers linked with that language must be updated.
For example, George et al. express that, every 3-5 years, ANSI C++ is updated. New keywords may be included in the altered wording. For instance, constexpr is a new keyword in ANSI C++0x. As a result, any identifiers with the same name in early applications must be updated, or they will be misinterpreted.
Existing Transcompiler Tools
Let’s have a look at some of the tools available for translating code between programming languages.
BCX – BCX is a tiny command-line tool that takes a BCX BASIC source code file and converts it into a ‘C’ source code file that can be compiled with any C or C++ compiler.
PERTHON – Perthon translates Python source code to Perl 5.x source code that humans can read. It parses using Damian Conway’s Parse::Rec Descent and seeks to re-implement the Python language according to the Python Reference Manual and BNF grammar.
Facebook’s TransCoder AI – TransCoder, a Facebook system that can translate between C++, Java, and Python, takes an unsupervised learning approach to the problem. TransCoder starts with cross-lingual language model pretraining, which converts code fragments expressing the same instructions into equivalent representations regardless of the programming language.
The programmers’ objective is to achieve maximum conversion efficiency without sacrificing the quality of the converted system. Even though language conversion appears to be simple, it is a herculean task with numerous complexities. It is appropriately regarded as one of the top ten programming difficulties facing the globe. Even before a reliable semi-automatic converter is accessible, much progress must be achieved. It may even be feasible in the future to translate code between two entirely distinct platforms with a single click. Because a library alone cannot execute such a conversion flawlessly and spot the replacement pattern in the language, this may depend on advances in artificial intelligence. Converting a desktop programme to a web application and vice versa is a good example. Similarly, the reasoning used to design a similar desktop or web application may be applied to create mobile applications. Hence, we can expect a competent transcompiler from the research community in the near future.