r/programming • • Jul 30 '15

Code 'transplant' could revolutionise programming (Wired UK)

http://www.wired.co.uk/news/archive/2015-07/30/code-organ-transplant-software-myscalpel
0 Upvotes

14 comments sorted by

View all comments

22

u/Strilanc Jul 30 '15 edited Jul 30 '15

This article is garbage with no useful details beyond the terminology the researchers happened to use.

That being said, the underlying idea sounds really interesting. Use the implementation of feature X in program A to auto-implement X in another program B. After skimming the actual paper, here's the general idea:

  • The programmer marks the functionality-to-extract in the source program by marking a function with an /* OE */ comment. The function doesn't have to be pure; it can touch globals and have side effects.

  • The programmer annotates an /* IP */ at the desired insertion point in the destination program.

  • There must be a good existing test suite for the destination program's existing features.

  • The programmer must provide new tests that exercise the expected-to-be-inserted functionality in the destination program.

  • The tool tries to make the new tests pass, without breaking the old tests, by adding code at the insertion point. The "extraction point" function acts as a hint / code snippet source to help the process along.

You still have to write the tests, and the code that gets inserted probably isn't very clean, but in the ideal world where this worked perfectly it'd be a nice 2X speedup in dev time. Definitely interesting.

0

u/[deleted] Aug 06 '15

[deleted]

1

u/Strilanc Aug 06 '15

Sometimes tests are harder to write, but sometimes they're easier. By allowing you to either ask for what you need or specify how to make it, you can try to always pick the easier route.

Also many programming tasks are ultimately a translation effort from user requests to working code. Since tests (and logic programming in general) are much closer in style to those requests ("it must do X when Y") than to imperative code, the translation should (hopefully, speculatively, with future more powerful tools that are more capable and effective than this one) become easier.