One of the goals of my programming language Ix is to support the evolution of programs in a first-class way. I haven't figured out all of the details, but the idea is for the language to know about version 1 and version 2 of the program, and to provide warnings when certain kinds of dangerous transformations occur.
Having a static type system also provides similar functionality without any explicit notions of transformations through time; if you change a function to remove a parameter, then client code which needs to be changed will fail to compile. Thus the static type system provides implicit support for verifying program changes.
Could a language support something more powerful? Some others were thinking along these lines and developed
Semantic Patches:
Our goal is to document and automate the kinds of collateral evolutions that occur in code. Because programmers are accustomed to manipulating program modifications in terms of patch files, we base our transformation language on the patch syntax, extending patches to semantic patches. But as opposed to a traditional patch, a single small semantic patch can modify hundreds of files, at thousands of code sites. This is because the features of our semantic patch language (SmPL) make a semantic patch generic by abstracting away the specific details and variations at each code site among all drivers. Semantic patches, and the associated transformation engine spatch, abstract away:
- Differences in spacing, indentation, and comments
- Choice of names given to variables (use of metavariables)
- Irrelevant code (use of '
...' operator)
- Other variations in coding style (use of isomorphisms) e.g.
if(!y) <=> if(y==NULL) <=> if(NULL==y)
A natural extension of this technology is to perform validation along with the transformation.