Unnatural language processing
Larry Wall, creator of the Perl programming language, created a custom degree plan in college, an interdisciplinary course of study in natural and artificial languages, i.e. linguistics and programming languages. Many of the features of Perl were designed as an attempt to apply natural language principles to the design of an artificial language.
I've been thinking of a different connection between natural and artificial languages, namely using natural language processing (NLP) to reverse engineer source code.
The source code of computer program is text, but not a text. That is, it consists of plain text files, but it's not a text in the sense that Paradise Lost or an email is a text. The most efficient way to parse a programming language is as a programming language. Treating it as an English text will loose vital structure, and wrongly try to impose a foreign structure.
But what if you have two computer programs? That's the problem I've been thinking about. I have code in two very different programming languages, and I'd like to know how functions in one code base relate to those in the other. The connections are not ones that a compiler could find. The connections are more psychological than algorithmic. I'd like to reverse engineer, for example, which function in language A a developer had in mind when he wrote a function in language B.
Both code bases are in programming language, but the function names are approximately natural language. If a pair of functions have the same name in both languages, and that name is not generic, then there's a good chance they're related. And if the names are similar, maybe they're related.
I've done this sort of thing informally forever. I imagine most programmers do something like this from time to time. But only recently have I needed to do this on such a large scale that proceeding informally was not an option. I wrote a script to automate some of the work by looking for fuzzy matches between function names in both languages. This was far from perfect, but it reduced the amount of sleuthing necessary to line up the two sets of source code.
Around a year ago I had to infer which parts of an old Fortran program corresponded to different functions in a Python program. I also had to infer how some poorly written articles mapped to either set of source code. I did all this informally, but I wonder now whether NLP might have sped up my detective work.
Another situation where natural language processing could be helpful in software engineering is determining code authorship. Again this is something most programmers have probably done informally, saying things like "I bet Bill wrote this part of the code because it looks like his style" or "Looks like Pat left her fingerprints here." This could be formalized using NLP techniques, and I imagine it has been. Just as Frederick Mosteller and colleagues did a statistical analysis of The Federalist Papers to determine who wrote which paper, I'm sure there have been similar analyses to try to find out who wrote what code, say for legal reasons.
Maybe this already has a name, but I like "unnatural language processing" for the application of natural language processing to unnatural (i.e. programming) languages. I've done a lot of ad hoc unnatural language processing, and I'm curious how much of it I could automate in the future.