Many books on computer programming publish source code listings and example programs as part of the printed book to demonstrate some aspect of the language. When I'm learning from such books, I typically copy one or more examples from the book into my computer in order to run them, study them, run them using a debugger, etc. I copy the version from the printed book and do not use any other included media such as CD-ROMs or Web sites. I had always assumed this sort of copying for personal use on my own computer would not be considered copyright infringement, but now I'm not so sure.

Sometimes, the book does mention an implied license near the beginning that clarifies how the source code can be used. In this case, the license normally allows copying for the sort of purpose I'm talking about. But in the large majority of cases, there is no license mentioned at all pertaining to how the source code included in the book may be used. If there are electronic media provided with the book (CD-ROM, Web site, etc.), the electronic versions of the source code typically do mention a license, but I do not typically make use of such media, so for the purpose of this question I want to ignore them.

In one unusual example, there is a well-known programming book that explicitly forbids any personal use of the source code in the book on a computer without first obtaining a license:

You must read this section if you intend to use the code in this book on a computer [...]. Without the license [...] this book is intended as a text and reference book, for reading and study purposes only.

It then goes on to clarify the granted personal use license:

If you personally keyboard no more than 10 routines from this book into your computer, then we authorize you (and only you) to use those routines (and only those routines) on that single computer.

However, I cannot accept this license due to the restrictions. For example, I may want to keyboard more than 10 routines. And I may want to use some method of copying other than to "personally keyboard" them (e.g. automatic dictation software).

My questions:

  1. For the case that a book does not include a license that mentions copying the source code from the book version, is it allowed for the reader to make personal copies of the source code to run on one's own computer?

  2. For the case that a book does include a license, but that license is found to be unacceptable by the reader, is it allowed for the reader to make the personal copies? Does the fact that there is a license offer that the reader does not agree to make any legal difference as compared with case 1 (no license offered at all)?

Assume that the source code to be copied would normally qualify for copyright protection (i.e. do not consider trivial source code examples that by themselves may not be eligible for copyright), and that the reader either owns or is borrowing (e.g. from a lending library) a legal copy of the book.

  • 2
    I don't want to repeat what has already been written here. (In short, judgement of fair use is a 4-factor case-by-case analysis, and we wouldn't be able to tell you definitively whether the use in your question is fair use. Non-profit educational use is one of the example purposes, but that doesn't short-cut consideration of the other three factors.) Is there anything that other answer doesn't answer for you?
    – user3851
    Aug 23, 2016 at 16:47
  • 1
    I might go a little bit further, and say that the question "is this fair use?" cannot be answered here. The reason is that fair use is a highly subjective analysis, and I believe that the only people qualified to say whether a fair use defense is likely to succeed in a particular context are IP attorneys advising clients. For us to say that X would or would not be fair use skates perilously close to giving legal advice.
    – user6726
    Aug 23, 2016 at 17:20
  • 1
    @DaleM, I believe "subjective" is exactly correct. The jury subjectively determines how the 4 factors are "balanced", and the law does not say anything about how they could possibly reach an objective decision based on the law.
    – user6726
    Aug 23, 2016 at 23:51
  • 1
    @DaleM Legal decisions are not always objective tests. There are subjective aspects, like in the 4th Amendment's reasonable expectation of privacy test. It has both an subjective and an objective component. "The law is clear that the Fourth Amendment protects against government intrusion that upsets an actual (subjective) expectation of privacy that is objectively reasonable." Bond v. United States 529 U.S. 334 (2000) - emphasis mine.
    – user3851
    Aug 24, 2016 at 0:05
  • 1
    @Dawn, that's correct: the decision is made subjectively, i.e. the outcome depends on a subjective evaluation by the fact-finder. Good point about "subjective test" being a term of art.
    – user6726
    Aug 24, 2016 at 0:50

2 Answers 2


Ignoring fair use, copying code in which copyright subsists would be copyright infringement.

... the owner of copyright under this title has the exclusive rights [...] to reproduce the copyrighted work (17 USC 106)

Code is eligible for copyright as a literary work.

Copyright protection subsists [...] in original works of authorship fixed in any tangible medium of expression [...] Works of authorship include [...] literary works [...] (17 USC 102)

Oracle v Google. (Fed. Cir. 2014):

It is undisputed that computer programs— defined in the Copyright Act as a set of statements or instructions to be used directly or indirectly in a computer in order to bring about a certain result, 17 U.S.C. § 101—can be subject to copyright protection as literary works.

One way that copying the code would not be infringement is under a scenes a faire or merger analysis. In some circuits (e.g. 6th Circuit), scenes a faire/merger can preclude copyrightability. In other circuits (e.g. 2nd and 9th Circuits), these apply as affirmative defences after an initial finding of infringement. In either case, just as in fair use, this would be a case-by-case analysis, so we can't provide a blanket answer.

  • Thank you for the answer. But I'm still interested in the licensing issue. For example, sometmies an author/publisher includes a license that says personal copying is permitted, but usually there is no license mentioned. In a few books I've seen, there is no license as such, but the author makes a statement such as "Type in and test the following code on your system." Would a statement such as that qualify as a license to copy the portion he is referring to (on my own system, for the purpose of testing, etc.)?
    – Brandin
    Aug 24, 2016 at 14:37
  • @Brandin If they tell you to do something with the code, that is an implied licence to do that thing. However, that might not even be necessary, because of fair use, but you asked this question to not be about that. So you are getting answers to possibly irrelevant issues.
    – user3851
    Aug 24, 2016 at 14:41

The scenes-a-faire (required scenes, or literally "scenes to be made") doctrine recognizes that some aspects of a copyrighted work in some genre may be traits of the genre, and thus not copyrightable in and of themselves. Further, the merger doctrine says that if there only a very limited number of ways of expressing something, none are copyrightable in and of themselves. Many code examples in programming books, chip vendor data sheets, etc. are intended to show the essence of what would be expected in a generic application that performs a particular task. For example, a typical UART transmit routine would look something like:

void put_char(unsigned ch)
  UART0->TXDATA = ch;

using identifier names that match those given in the device manufacturer's data sheet or technical reference manual. While there might potentially be a small amount of creativity in the choice of whether to use the ! operator or compare the result of the bit mask with zero, how to format the dummy statement in the loop, etc. there are only a small number of ways of expressing something like the above without being gratuitously unclear.

In a sense, many programming examples in books are designed to show how a construct might be implemented in code if the programmer makes no attempt to be original. If an example intended to avoid being particularly "original", that would imply that the author was not trying to satisfy the copyright laws' rule that only original works can be copyrighted.

The fact that individual code snippets aren't copyrightable doesn't mean another author could simply copy all of them. If an author is seeking to make a number of programming examples fit together well for pedagogical purposes, minor differences that would be irrelevant when code is fed to the machine may make it easier or harder for readers to understand what is going on, and as a consequence the design of code snippets designed for teaching may require more originality and creativity than the design of snippets that are intended to direct machines to accomplish useful tasks.

  • "*scenes-a-faire *" might better be translated as "required scenes", particularly in the context of copyright law. Sep 30, 2022 at 14:11
  • @DavidSiegel: Thanks for the suggestion. Do you like my adjustment to the parenthetical?
    – supercat
    Sep 30, 2022 at 19:43

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .