SOME programmers call it “spaghetti code”. Though error-strewn, it works—most of the time. It is likely to have been written in an out-of-date language, possibly more than one of them. It has grown by accretion, as different graduate students and postdocs, many long since departed to other institutions, have tweaked it, fixed it and patched it. And it is, of course, unannotated, so nobody really knows what is going on inside it.

In the rarefied atmosphere of academia, where enthusiasm is all and budgets are tight, that is generally good enough. For commercial applications, though, it is intolerable. Yet academic spaghetti code frequently contains commercially useful ideas that might be sold to outside companies or employed as the basis of new, startup businesses. So there is a market niche available to be occupied by those willing to take the stuff and untangle it.

One occupant of said niche is Oxford Computer Consultants (OCC), a firm based in the eponymous English city. A recent project it carried out was the transformation of drug-testing software developed by researchers at Oxford University into a commercial package called Virtual Assay, which can speed up preclinical trials of putative medicines. A second began with pieces of code written partly in Fortran, a programming language devised in the 1950s, and partly in Matlab, a more modern language, by researchers at Southampton University. This mixture was turned into RoCiT, a system that engineers at National Grid, the firm which (among other things) runs Britain’s electricity-distribution network, use to calculate the maximum power that underground cables can carry safely.

According to Reynold Greenlaw, one of OCC’s directors, cleaning up spaghetti code starts with the obvious but not-always-easy step of getting a copy of the program to run on one of the firm’s own machines—and, once it is running, to turn out the same results as it does on the originator’s machine. That done, each of the program’s parts can be examined and tested individually, translated into a more modern computing language if required, and upgraded as necessary. Only then, when all parts are working properly, is the spaghetti untangled, the entire program restructured into something a commercial programmer would accept, and annotation added to it so that other programmers can understand exactly how it works.

As might be expected, OCC is not alone in its mission to transmogrify academic software into something business can use. Such an industry exists in America, too. There, though, universities often try to keep the process within their walls. The Venture Development Centre of the University of Massachusetts, in Boston, is one example of an in-house spaghetti untangler for researchers who want to go commercial. The New York University School of Engineering Incubator is another. A third is the Southern Tier Startup Alliance at Cornell, also in New York state.

Untangling spaghetti code in this way would not, of course, be necessary if researchers were better programmers in the first place. But that would involve a change in their incentives, because for most academics writing software is merely a means to an end rather than an end in itself. Those who do put effort into producing good code risk being seen by their colleagues as time-wasters.

Some brave souls are, nevertheless, trying to encourage this change. One such is Neil Chue Hong, founder and head of the Software Sustainability Institute (SSI) at Edinburgh University. The SSI has the self-appointed mission (backed by government funding agencies) of encouraging British academics to code sensibly from the beginning—for their own good, as well as that of any commercial spin-offs.

Mr Chue Hong is a relative newcomer to the task of teaching good programming practices to academics, for the SSI was founded in 2010. Greg Wilson has been at it since 1998, when he started “software carpentry” workshops at Toronto University. He now runs the Software Carpentry Foundation, an international charity, but has not yet succeeded in turning the majority of computing’s academic bodgers into craftsmen. The spaghetti-untanglers, it seems, will be around for a while yet.