Researchers at MIT’s Computer Science and Artificial Intelligence Laboratory (CSAIL) have developed a new system that allows programmers to transplant code from one program into another. The programmer can select the code from one program and an insertion point in a second program, and the system will automatically make modifications necessary — such as changing variable names — to integrate the code into its new context.
Crucially, the system is able to translate between “data representations” used by the donor and recipient programs. An image-processing program, for instance, needs to be able to handle files in a range of formats, such as jpeg, tiff, or png. But internally, it will represent all such images using a single standardized scheme. Different programs, however, may use different internal schemes. The CSAIL researchers’ system automatically maps the donor program’s scheme onto that of the recipient, to import code seamlessly.
The researchers presented the new system, dubbed CodeCarbonCopy, at the Association for Computing Machinery’s Symposium on the Foundations of Software Engineering.
“CodeCarbonCopy enables one of the holy grails of software engineering: automatic code reuse,” says Stelios Sidiroglou-Douskos, a research scientist at CSAIL and first author on the paper. “It’s another step toward automating the human away from the development cycle. Our view is that perhaps we have written most of the software that we’ll ever need — we now just need to reuse it.”
The researchers conducted eight experiments in which they used CodeCarbonCopy to transplant code between six popular open-source image-processing programs. Seven of the eight transplants were successful, with the recipient program properly executing the new functionality.
Joining Sidiroglou-Douskos on the paper are Martin Rinard, a professor of electrical engineering and computer science; Fan Long, an MIT graduate student in electrical engineering and computer science; and Eric Lahtinen and Anthony Eden, who were contract programmers at MIT when the work was done.
With CodeCarbonCopy, the first step in transplanting code from one program to another is to feed both of them the same input file. The system then compares how the two programs process the file.
If, for instance, the donor program performs a series of operations on a particular piece of data and loads the result into a variable named “mem_clip->width,” and the recipient performs the same operations on the same piece of data and loads the result into a variable named “picture.width,” the system will infer that the variables are playing the same roles in their respective programs.
Once it has identified correspondences between variables, CodeCarbonCopy presents them to the user. It also presents all the variables in the donor for which it could not find matches in the recipient, together with those variables’ initial definitions. Frequently, those variables are playing some role in the donor that’s irrelevant to the recipient. The user can flag those variables as unnecessary, and CodeCarbonCopy will automatically excise any operations that make use of them from the transplanted code.
To map the data representations from one program onto those of the other, CodeCarbonCopy looks at the precise values that both programs store in memory. Every pixel in a digital image, for instance, is governed by three color values: red, green, and blue. Some programs, however, store those triplets of values in the order red, green, blue, and others store them in the order blue, green, red.
If CodeCarbonCopy finds a systematic relationship between the values stored by one program and those stored by the other, it generates a set of operations for translating between representations.
CodeCarbonCopy works well with file formats, such as images, whose data is rigidly organized, and with programs, such as image processors, that store data representations in arrays, which are essentially rows of identically sized memory units. In ongoing work, the researchers are looking to generalize their approach to file formats that permit more flexible data organization and programs that use data structures other than arrays, such as trees or linked lists.
“In general, code quoting is where a lot of problems in software come from,” says Vitaly Shmatikov, a professor of computer science at Cornell Tech, a joint academic venture between Cornell University and Israel’s Technion. “Both bugs and security vulnerabilities — a lot of them occur when there is functionality in one place, and someone tries to either cut and paste or reimplement this functionality in another place. They make a small mistake, and that’s how things break. So having an automated way of moving code from one place to another would be a huge, huge deal, and this is a very solid step toward having it.”
“Recognizing irrelevant code that’s not important for the functionality that they’re quoting, that’s another technical innovation that’s important,” Shmatikov adds. “That’s the kind of thing that was an obstacle for a lot of previous approaches — that you know the right code is there, but it’s mixed up with a lot of code that is not relevant to what you’re trying to do. So being able to separate that out is a fairly significant technical contribution.”
Learn more: Automatic code reuse
The Latest on: Automatic code reuse
- Here’s What You Need to Know About The New Facebook Store Visit Ads on October 19, 2017 at 3:16 pm
Recommended for You Webcast, October 26th: Why Automating Your Cold Calls is the Best-Kept Secret for Driving, Qualifying, and Closing More Leads at Scale Alternatively, you can use the Bulk Add feature to add stores en masse by zip code or store number. […]
- Generate WordPress Code Snippets “Magically” with WP Hasty on October 19, 2017 at 6:39 am
For example, the shortcode generator allows you to choose if the shortcode should be auto ... codes into your theme and you’re good to go! This is by far one of my favorite WordPress tools because it’s so practical and it’s something you can reuse ... […]
- Cloud powered modern applications increase IT Showcase content discoverability on October 19, 2017 at 1:55 am
Reduced maintenance costs through automatic content updates and notifications ... When they created the Windows 8 modern app, they were able to reuse code relevant to all platforms without re-coding. Note: For more information on developing once for ... […]
- NXP Announces New Automotive Processing Platform that Brings Future Vehicles to Market Faster on October 15, 2017 at 11:00 pm
2 Based on analysis of existing NXP software code in existing customers’ applications, NXP expects that software reuse will be significant both within domains and across vehicle domains at up to 90 and more than 40 percent respectively. 3 Source ... […]
- Go code-free! Create an API in IBM App Connect and call it from IBM Business Process Manager on October 13, 2017 at 3:45 pm
Because IBM BPM enables code-free process creation ... If you use similar names, you can click Auto match fields to pre-populate the form automatically. If you scroll down, you see that the relevant fields are populated. If the objects you are mapping ... […]
- Gluon provides machine learning for AWS and Azure on October 13, 2017 at 3:34 am
It will also include fully symbolic automatic differentiation of code that has been procedurally executed including ... the task of defining complex model architectures through reuse of the pre-built building blocks from the library. […]
- 9 Best Cross-Platform Mobile App Development Tools on October 12, 2017 at 7:37 am
Developers can reuse the code and can design apps that can work efficiently on ... Here comes the platform that is laced with features like automatic coding, app preview facility, and API connection, along with other various surprising features. […]
- Durable Functions and Bindings Extensibility Preview Announcement on October 10, 2017 at 8:01 am
This enabled the following: Expression of tasks in simple C# code Automatic persistence and check-pointing of ... complex serverless applications and need better mechanisms for code reuse. Triggers and bindings allow developers to focus on their code ... […]
- Terraforming Your Docker Environment on AWS on October 9, 2017 at 1:00 am
Terraform is an open-source infrastructure-as-code tool that allows you to declare your infrastructure ... The Terraform examples I provide create a couple IAM roles, a VPC, a load balancer, an auto-scaling group, multiple EC2 instances, security groups ... […]
- MIT researchers develop system that makes it easier for software developers to copy paste code on September 21, 2017 at 9:39 am
Stelios Sidiroglou-Douskos, the first author of the paper says, "CodeCarbonCopy enables one of the holy grails of software engineering: automatic code reuse. It’s another step toward automating the human away from the development cycle. Our view is that ... […]
via Google News and Bing News