A code converter makes it possible to convert source code from one high-level programming language to another. Facebook researchers have developed TransCoder AI. It is a system that makes it possible to convert code between programming languages, such as Java , Python, and C++. Migrating an existing code base to a more modern or efficient language requires a huge amount of resources. Specifically, it requires both financial resources and human resources. Theoretically, a converter can help eliminate the cost of rewriting code from scratch. However, this is a difficult process, since the source language and the target language have different syntax, variable types, standard library functions, and platform APIs
TransCoder AI: Code converter for any programming language
Facebook’s TransCoder AI can run unsupervised with minimal human intervention to find undetected patterns in unlabeled datasets and outperform rule-based algorithms by a “significant” margin. It can map code snippets that represent the same instructions to identical code snippets, regardless of the programming language used. The best part about Facebook’s TransCoder AI is that it can be easily generalized to any programming language and doesn’t require any specialized knowledge to convert code from one programming language to another.
Accuracy of TransCoder AI
Facebook researchers trained TransCoder AI on publicly available code across more than 2.8 million open-source GitHubto focus on translating code at the function level. To evaluate TransCoder AI’s performance, they selected 852 parallel functions in the C++, Java, and Python programming languages from GeeksforGeeks — a popular platform that teaches coding through problems and offers solutions in various programming languages. Using this data, the researchers developed a new metric called “computational accuracy,” which tests whether translated functions produce the same outputs with the same inputs as in the source language.

Results of TransCoder AI
Regarding the accuracy level in the results obtained from TransCoder AI during code conversion, the following are observed:
- From C++ to Python: 67.2%
- From C++ to Java:74,8%
- From Java to C ++: 91,6%
- From Java to Python: 68,7%
- From Python to Java: 56,1%
- From Python to C ++: 57,8%
The researchers claim that TransCoder AI has “understood” the syntax of each language (Java, Python , and C++) along with their data structures. It was even able to correctly align libraries in each language, while adapting to small modifications, such as renaming a variable in the input.
However, Transcoder AI is not perfect, as it failed to take into account certain types of variables when generating code. However, it went beyond the scope of manually “rebuilding” code from scratch, based on the knowledge of specialized human resources.
