When I write a book or magazine article, I almost always include some illustrative code. This gives my readers a starting point for their own work. I’ve often been frustrated trying to reproduce someone’s ideas without working code, so I try hard to make sure my programs compile and work properly.

To a book or magazine publisher, source code is just another kind of text. And in their world, that means it must be copyrighted. The idea of giving words away pains them deeply. So they publish the code using virtually the same copyright they use for everything else. That copyright gives you, the buyer, the right to read the book and not much else! This is of course, foolish.

The Real World

On a regular basis, readers ask if it’s okay for them to use the code from one of my books or articles. They read the copyright notices and get a little nervous. Or even worse, their managers get a little nervous! Here is what I tell them:

  • It is my intention that anyone who buys the book or magazine be free to use the source code in any form they please. I only request that any use that involves public reproduction include proper attribution.
  • I assert that in no case will I initiate or cooperate with any attempt to enforce the copyright on the source code, whether it belongs to me or a publisher.
  • The code I publish is written for clarity, not efficiency. Once you massage the code to work with your product, it is likely to be significantly different from the published code anyway.
  • Nobody from any of the companies that publish my work is even remotely interested in pursuing people for unauthorized use of source code. They don’t have anyone on their staffs to deal with problems like this, and they probably don’t even want to think about it.
  • What the publishers are concerned about is you writing books or articles that copy their stuff. Don’t do that, and you can be certain that they will be happy.
  • None of the code I publish is warranted in any way by me or the publisher to be free of defects. If you need bullet-proof software that is guaranteed to work as promised you will need to adopt a methodology considerably more rigid than that of simply purchasing a book or magazine.

Still Not Happy?

If your project is such a big deal that you still aren’t satisfied with these assurances, there probably isn’t much more I can offer. Even more importantly, once you start talking about contracts and lawyers, you are talking about spending real money. Once you’ve reached that point, spend the money on a commercial third party library instead! You can get an awful lot of decent code for what you would pay an attorney for a day’s work.