{"id":13353,"date":"2017-10-13T10:34:00","date_gmt":"2017-10-13T10:34:00","guid":{"rendered":"https:\/\/www.revoscience.com\/en\/?p=13353"},"modified":"2017-10-13T10:34:00","modified_gmt":"2017-10-13T10:34:00","slug":"automatic-code-reuse","status":"publish","type":"post","link":"https:\/\/www.revoscience.com\/en\/automatic-code-reuse\/","title":{"rendered":"Automatic code reuse"},"content":{"rendered":"<p style=\"text-align: justify;\"><span style=\"color: #000000;\"><em><strong>System makes modifications necessary to transplant code from one program into another.<\/strong><\/em><\/span><\/p>\n<figure id=\"attachment_13354\" aria-describedby=\"caption-attachment-13354\" style=\"width: 639px\" class=\"wp-caption alignnone\"><img loading=\"lazy\" decoding=\"async\" class=\"size-full wp-image-13354\" src=\"https:\/\/www.revoscience.com\/en\/wp-content\/uploads\/2017\/10\/MIT-CopyingCode-01_0.jpg\" alt=\"\" width=\"639\" height=\"426\" title=\"\" srcset=\"https:\/\/www.revoscience.com\/en\/wp-content\/uploads\/2017\/10\/MIT-CopyingCode-01_0.jpg 639w, https:\/\/www.revoscience.com\/en\/wp-content\/uploads\/2017\/10\/MIT-CopyingCode-01_0-300x200.jpg 300w\" sizes=\"auto, (max-width: 639px) 100vw, 639px\" \/><figcaption id=\"caption-attachment-13354\" class=\"wp-caption-text\">\u201cCodeCarbonCopy enables one of the holy grails of software engineering: automatic code reuse,\u201d says Stelios Sidiroglou-Douskos, a research scientist at CSAIL.<br \/>Image: MIT News<\/figcaption><\/figure>\n<p style=\"text-align: justify;\"><span style=\"color: #000000;\">CAMBRIDGE, Mass. &#8212;\u00a0Researchers at MIT\u2019s 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 \u2014 such as changing variable names \u2014 to integrate the code into its new context.<\/span><\/p>\n<p style=\"text-align: justify;\"><span style=\"color: #000000;\">Crucially, the system is able to translate between \u201cdata representations\u201d 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\u2019 system automatically maps the donor program\u2019s scheme onto that of the recipient, to import code seamlessly.<\/span><\/p>\n<p style=\"text-align: justify;\"><span style=\"color: #000000;\">The researchers presented the new system, dubbed\u00a0<a href=\"http:\/\/mit.pr-optout.com\/Tracking.aspx?Data=HHL%3d81%3a5%3b8-%3eLCE9%3b4%3b8%3f%26SDG%3c90%3a.&amp;RE=MC&amp;RI=4334046&amp;Preview=False&amp;DistributionActionID=41305&amp;Action=Follow+Link\" target=\"_blank\" rel=\"noopener\" data-saferedirecturl=\"https:\/\/www.google.com\/url?hl=en&amp;q=http:\/\/mit.pr-optout.com\/Tracking.aspx?Data%3DHHL%253d81%253a5%253b8-%253eLCE9%253b4%253b8%253f%2526SDG%253c90%253a.%26RE%3DMC%26RI%3D4334046%26Preview%3DFalse%26DistributionActionID%3D41305%26Action%3DFollow%2BLink&amp;source=gmail&amp;ust=1507976968115000&amp;usg=AFQjCNFmzXggCCw5IBwlLGkpHv5zVhv9nw\">CodeCarbonCopy<\/a>, at the Association for Computing Machinery\u2019s Symposium on the Foundations of Software Engineering.<\/span><\/p>\n<p style=\"text-align: justify;\"><span style=\"color: #000000;\">\u201cCodeCarbonCopy enables one of the holy grails of software engineering: automatic code reuse,\u201d says Stelios Sidiroglou-Douskos, a research scientist at CSAIL and first author on the paper. \u201cIt\u2019s 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\u2019ll ever need \u2014 we now just need to reuse it.\u201d<\/span><\/p>\n<p style=\"text-align: justify;\"><span style=\"color: #000000;\">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.<\/span><\/p>\n<p style=\"text-align: justify;\"><span style=\"color: #000000;\">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.<\/span><\/p>\n<p style=\"text-align: justify;\"><span style=\"color: #000000;\"><strong>Mutatis mutandis<\/strong><\/span><\/p>\n<p style=\"text-align: justify;\"><span style=\"color: #000000;\">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.<\/span><\/p>\n<p style=\"text-align: justify;\"><span style=\"color: #000000;\">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 \u201cmem_clip-&gt;width,\u201d and the recipient performs the same operations on the same piece of data and loads the result into a variable named \u201cpicture.width,\u201d the system will infer that the variables are playing the same roles in their respective programs.<\/span><\/p>\n<p style=\"text-align: justify;\"><span style=\"color: #000000;\">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\u2019 initial definitions. Frequently, those variables are playing some role in the donor that\u2019s 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.<\/span><\/p>\n<p style=\"text-align: justify;\"><span style=\"color: #000000;\"><strong>New order<\/strong><\/span><\/p>\n<p style=\"text-align: justify;\"><span style=\"color: #000000;\">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.<\/span><\/p>\n<p style=\"text-align: justify;\"><span style=\"color: #000000;\">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.<\/span><\/p>\n<p style=\"text-align: justify;\"><span style=\"color: #000000;\">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.<\/span><\/p>\n","protected":false},"excerpt":{"rendered":"<p>System makes modifications necessary to transplant code from one program into another. CAMBRIDGE, Mass. &#8212;\u00a0Researchers at MIT\u2019s 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 [&hellip;]<\/p>\n","protected":false},"author":6,"featured_media":13354,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[43,47],"tags":[],"class_list":["post-13353","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-computer-science","category-it"],"featured_image_urls":{"full":["https:\/\/www.revoscience.com\/en\/wp-content\/uploads\/2017\/10\/MIT-CopyingCode-01_0.jpg",639,426,false],"thumbnail":["https:\/\/www.revoscience.com\/en\/wp-content\/uploads\/2017\/10\/MIT-CopyingCode-01_0-150x150.jpg",150,150,true],"medium":["https:\/\/www.revoscience.com\/en\/wp-content\/uploads\/2017\/10\/MIT-CopyingCode-01_0-300x200.jpg",300,200,true],"medium_large":["https:\/\/www.revoscience.com\/en\/wp-content\/uploads\/2017\/10\/MIT-CopyingCode-01_0.jpg",639,426,false],"large":["https:\/\/www.revoscience.com\/en\/wp-content\/uploads\/2017\/10\/MIT-CopyingCode-01_0.jpg",639,426,false],"1536x1536":["https:\/\/www.revoscience.com\/en\/wp-content\/uploads\/2017\/10\/MIT-CopyingCode-01_0.jpg",639,426,false],"2048x2048":["https:\/\/www.revoscience.com\/en\/wp-content\/uploads\/2017\/10\/MIT-CopyingCode-01_0.jpg",639,426,false],"ultp_layout_landscape_large":["https:\/\/www.revoscience.com\/en\/wp-content\/uploads\/2017\/10\/MIT-CopyingCode-01_0.jpg",639,426,false],"ultp_layout_landscape":["https:\/\/www.revoscience.com\/en\/wp-content\/uploads\/2017\/10\/MIT-CopyingCode-01_0.jpg",639,426,false],"ultp_layout_portrait":["https:\/\/www.revoscience.com\/en\/wp-content\/uploads\/2017\/10\/MIT-CopyingCode-01_0.jpg",600,400,false],"ultp_layout_square":["https:\/\/www.revoscience.com\/en\/wp-content\/uploads\/2017\/10\/MIT-CopyingCode-01_0.jpg",600,400,false],"newspaper-x-single-post":["https:\/\/www.revoscience.com\/en\/wp-content\/uploads\/2017\/10\/MIT-CopyingCode-01_0.jpg",639,426,false],"newspaper-x-recent-post-big":["https:\/\/www.revoscience.com\/en\/wp-content\/uploads\/2017\/10\/MIT-CopyingCode-01_0.jpg",540,360,false],"newspaper-x-recent-post-list-image":["https:\/\/www.revoscience.com\/en\/wp-content\/uploads\/2017\/10\/MIT-CopyingCode-01_0.jpg",95,63,false],"web-stories-poster-portrait":["https:\/\/www.revoscience.com\/en\/wp-content\/uploads\/2017\/10\/MIT-CopyingCode-01_0.jpg",639,426,false],"web-stories-publisher-logo":["https:\/\/www.revoscience.com\/en\/wp-content\/uploads\/2017\/10\/MIT-CopyingCode-01_0.jpg",96,64,false],"web-stories-thumbnail":["https:\/\/www.revoscience.com\/en\/wp-content\/uploads\/2017\/10\/MIT-CopyingCode-01_0.jpg",150,100,false]},"author_info":{"info":["Amrita Tuladhar"]},"category_info":"<a href=\"https:\/\/www.revoscience.com\/en\/category\/computer-science\/\" rel=\"category tag\">Computer Science<\/a> <a href=\"https:\/\/www.revoscience.com\/en\/category\/news\/it\/\" rel=\"category tag\">IT<\/a>","tag_info":"IT","comment_count":"0","_links":{"self":[{"href":"https:\/\/www.revoscience.com\/en\/wp-json\/wp\/v2\/posts\/13353","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.revoscience.com\/en\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.revoscience.com\/en\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.revoscience.com\/en\/wp-json\/wp\/v2\/users\/6"}],"replies":[{"embeddable":true,"href":"https:\/\/www.revoscience.com\/en\/wp-json\/wp\/v2\/comments?post=13353"}],"version-history":[{"count":0,"href":"https:\/\/www.revoscience.com\/en\/wp-json\/wp\/v2\/posts\/13353\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.revoscience.com\/en\/wp-json\/wp\/v2\/media\/13354"}],"wp:attachment":[{"href":"https:\/\/www.revoscience.com\/en\/wp-json\/wp\/v2\/media?parent=13353"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.revoscience.com\/en\/wp-json\/wp\/v2\/categories?post=13353"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.revoscience.com\/en\/wp-json\/wp\/v2\/tags?post=13353"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}