Monday, May 13, 2013

Copied code or Unfortunate coincidence?

My blog post today is another reposting of an item I'd originally submitted to the Udacity CS101 forum. This item isn't at all Python-specific. A student there wanted to know how code similarities are handled in the real business world. How to distinguish copied code from an unfortunate coincidence? If you'd like to see the original discussion thread, see:

My answer to the question was this:

There is a distinction between copyright and patent. I'm pretty sure that cleanroom techniques can be used to duplicate a piece of copyrighted code without getting into trouble. That is, the people who have seen the original code don't write the copy, but just pass the requirements and specifications through to people who never saw the original code. But if there is a piece of patented code, and you write your own code that inadvertently infringes on the patent, then you've got potential legal woes even though you didn't even know about the patented code. This is why there is such strong opposition to the notion of software patents. For example, see this article in Forbes or this blog from the Electronic Frontier Foundation.

It is also worth noting that not all copyright holders insist that you not copy their code. The GNU GPL license is a form of copyright that declares you are free to copy the code, but, if you do so, you need to make your modified version of the code freely available under a GPL license itself. The GPL is sufficently different from a typical copyright, that the slang term "copyleft" is often used for the GPL. The "contagious" properties of the GPL are fairly terrifying to companies that regard their code as proprietary secrets. If they inadvertently incorporate some GPL'ed code into their package, they might have a court declare that they have to release all that package's source code under GPL terms. The BSD license is different. As I understand it, BSD licensed code is free to copy without imposing restrictions on what you then do with your adaptation of the code.

There are many different software licenses. If you have occasion to reuse a piece of code, be sure you know the license terms. Some licenses are incompatible with some other licenses, so it is possible to pick up code with incompatible licenses and produce a program that cannot legally be released. There are companies (e.g. Black Duck Software) in the business of helping folks track down the origins of their code to make sure it is properly licensed.