Imagine a situation where a large organization is looking to migrate their codebase from an old traditional language to an efficient language for better performance. You are surely aware that the skills that are required for accomplishing this monumental task will be very demanding and even the cost involved in such kind of task burns a big hole in the organization’s pocket. But not anymore, Facebook AI Research new Deep Learning model, TransCoder can now translate code from one language to another!
Recently, Facebook AI Research introduced TransCoder, which uses the power of unsupervised deep-learning for converting code from one programming language to another. The TransCoder can translate the code written in Python, Java, C++ between each other.
How is TransCoder Built?
At the core, TransCoder leverages neural machine translation for translating text available in one natural language to another. Facebook trained the Deep Learning model on almost 3 million open-source projects.
To achieve high-performance standards, the researchers’ team at Facebook had built a dataset of 852 functions and related unit tests. This dataset was used as a validation set for the target languages which were Java, Python, and C++. Astonishingly, TransCoder’s performance on the validation set was 33 times better than already present commercial options, mainly the Java-to-Python translator.
At present, TransCoder supports three languages but in the future, it is expected to support multiple programming for translating code.
Evaluating TransCoder’s Performance
After obtaining different types of functions for each language, the model used sequence-to-sequence architecture consisting of attention-based encoder and decoder, enabled by the transformer. As transcoder was tested for different conversions involving the 3 languages, the following are the results obtained.
- For C++ to Java and Java to Python conversions, TransCoder was able to produce almost 75% and 69% expected results respectively.
- In the case of Java to C++, this unprecedented model achieved its best performance with 91.6% results matching the expected outputs.
- Talking about C++ to Python, transcoder performed well with 67.2% of correct results.
- At last, the conversions that involved Python as the source language saw a dip in the results. Python to C++ and Python to Java conversion results were 57.8% and 56.1% respectively.
Coming to the end of this article, we looked at a new unsupervised deep-learning system TransCoder built by the research team of the tech giant Facebook. It has the potential of becoming a game-changer for migrating code base from one language to another. As a future scope, the research team looks to cover more programming languages and also enhance the performance of TransCoder. Apart from this, the FAIR team is on the lookout to find more applicable use cases for this system.