Scientists at MIT have developed a new tool called CodeCarbonCopy (CCC) that can automatically port code from one project to another, mapping differences and adapting the imported code to the new codebase.

The tool is not publicly available just yet, as researchers are still working on improvements, but they have successfully tested it in private.

According to the research team, they used CodeCarbonCopy to port code between six popular open-source image-processing programs. The team carried out eight experiments, seven of which were successful, as the recipient program successfully executed the ported code without errors.

CodeCarbonCopy results

CodeCarbonCopy maps code between different projects

CodeCarbonCopy was able to achieve this because of two inherent features. The first was its ability to detect and map variables from one codebase to another.

Using CodeCarbonCopy implies running the program from where a piece of code is taken and the program where it's being ported side by side.

CodeCarbonCopy identifies variables that accomplish the same role and lists them for the human operator. It also displays variables it couldn't match, so programmers could link them manually or dismiss them from the ported code.

CodeCarbonCopy works best only for a certain class of apps

In addition, besides basic variable porting, CodeCarbonCopy can also map out how the two programs represent data internally, adjusting the ported code. This refers to how each codebase handles data (e.g.: adjusting between different color formats — RGB, BGR, etc.) and in what order.

Because of this, CodeCarbonCopy is currently useful only for porting code between applications that worked with data in fixed formats, such as images, videos, audio, PDFs, and others. Research is ongoing for improving CodeCarbonCopy so it could handle more unwieldy and disorganized formats.

"CodeCarbonCopy enables one of the holy grails of software engineering: automatic code reuse," says Stelios Sidiroglou-Douskos, one of the people behind the CodeCarbonCopy project.

This is not the first time MIT is trying to revolutionize coding. In January 2016, MIT together with Adobe announced Project Helium, an initiative to help developers update older software codebases for modern-day hardware, in an attempt to combat the phenomenon of software rot, also called bit-rot.

Two months later, MIT announced a new algorithm named Polaris that could be used to reduce total page load times for online websites by up to 34%.

The CodeCarbonCopy is the work of MIT's Computer Science and Artificial Intelligence Laboratory (CSAIL). Scientists presented their work — also available for download as a PDF — at this year's ESEC/FSE 2017 conference that took place in Germany at the start of September.

Related Articles:

Get 97% off The Complete Learn to Code Masterclass Bundle Deal

New Attack Recovers RSA Encryption Keys from EM Waves Within Seconds

Get 97% off The Complete Computer Science Bundle

Critical Flaw Fixed in Packagist, PHP's Largest Package Repository