System makes modifications necessary to transplant code from one program into another.
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.
Mutatis mutandis
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.
New order
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
[google_news title=”” keyword=”automatic code reuse” num_posts=”10″ blurb_length=”0″ show_thumb=”left”]- Renault SA (RNSDF) H1 2024 Earnings Call Transcripton July 29, 2024 at 1:56 pm
On LCVs, Renault brand enjoyed an impressive growth of 19.2% in a market of 13%, thanks to the successes of Kangoo, Express and Master all leaders in their segments, while traffic now ranks number ...
- How to choose the right low-code, no-code, or process automation platformon July 29, 2024 at 12:51 pm
Which low-code, no-code, or process automation platform is right for your organization? It depends on how well the platform meets your business objectives. Here are seven questions to help you narrow ...
- Keep the code behind AI open, say two entrepreneurson July 28, 2024 at 5:00 pm
But a doctrinal dispute continues to rage over the design of AI models, namely whether the software should be “closed-source” or “open-source”—in other words, whether code is proprietary, or public ...
- Supercheap Auto Discount Codes 2024on July 27, 2024 at 5:00 pm
Check often for the chance to score an exclusive Supercheap Auto discount code to save on your next purchase! Has your car broken down at a time that’s bad for your bank balance? Try Supercheap ...
- Tesla has rivals in bid for digital dominanceon July 27, 2024 at 12:00 pm
The U.S. EV maker relies on a central computer and a backup system, while rivals are trying to bolt together multiple central computers to achieve digital dominance.
- Federal Adaptive Reuse Bill Introduced in House of Representativeson July 23, 2024 at 5:00 pm
U.S. Reps. Mike Carey (R-OH) and Jimmy Gomez (D-CA) introduced the bipartisan “Revitalizing Downtowns and Main Streets Act” in the House of Representatives on July 12, 2024. Modeled after the Historic ...
- eTBc: A Semi-Automatic Testbench Generation Toolon July 21, 2024 at 5:00 pm
This paper presents a semi-automatic testbench generation tool called eTBc and a methodology called VeriSC (which allows for testbench simulation before RTL without additional code writing ... Other ...
- New regulations as Labour tries to answer public anger over water companieson July 18, 2024 at 1:42 am
The Government is bringing in measures to strengthen regulation of the water industry as it attempts to answer public anger over sewage polluting rivers, lakes and seas.The Water (Special Measures) ...
- We Track Sales For A Living. These Are The Ones Worth Your Money On Prime Day.on July 16, 2024 at 10:00 pm
We've rounded up only the most worthwhile deals that you can get on Amazon for the next two days, across every single category and price point.
- Preservationists concerned Columbus zoning overhaul could imperil historic buildingson July 11, 2024 at 4:06 am
While Columbus' main local historic preservation agency has largely kept a low public profile concerning the city's massive "Zone In" rezoning proposal speeding toward a City Council vote as early as ...
via Google News and Bing News