Recently a question was asked in SOPW that could be answered straight out of the Perl Cookbook. Not wanting to get myself in trouble by copying what was listed in the book, I answered the question with the general slant of the cookbook entry, as well as what entry number it was exactly.
I asked a couple of people (very casually) what their initial thoughts about posting code straight out of a book were, and they agreed with me that it might be pushing the bounds of fair use.
In this case, what is the best solution? Many times the solutions provided in text are very good, and trying to explain how they work or even rewriting (paraphrasing) the code yourself is not as good an answer.
I must admit to quite a bit of ignorance of copyright law, but I am pretty sure that unless the text explicitly says we are free to copy the examples we should be leaving them in the book.

Guildenstern
Negaterd character class uber alles!
  • Comment on Fair Use When Referring to Book Answers?

Replies are listed 'Best First'.
Re: Fair Use When Referring to Book Answers?
by clemburg (Curate) on Nov 17, 2000 at 20:43 UTC

    Not paraphrasing or copying the code is actually a service to your fellow monks. IMHO, it has the following advantages:

  • To get at the answer, people have to buy the book, or get the examples code from some website (usually provided). This should save on future questions, because people can then reasonably be expected to read the book (and actually learn something vs. just copy-and-paste the code).
  • It gives credit to the authors the way books are intended to work - by paying them. This is good, for otherwise we won't have any good authors.
  • It gets people into the habit of looking things up for themselves. Copy-and-paste usually fails to do this.
  • The books usually will have much, much more context information on how to use a given snippet, and that will often be very important.
  • You don't have to retype the code.
  • You have no problems with copyrights.

    That said, it is of course nice to give short, crisp answers based on a book's solution to a problem. But in the long run, just citing the book title and a page number will do the better service for all of us.

    The book to read is not the one which thinks for you, but the one which makes you think. -- James McCosh

    (See also this collection of quotations about books and reading.)

    Christian Lemburg
    Brainbench MVP for Perl
    http://www.brainbench.com

Re: Fair Use When Referring to Book Answers?
by footpad (Abbot) on Nov 17, 2000 at 23:38 UTC
    After scrounging the net for several minutes, the apprentice offers this...

    This article provides an interesting overview to the questions used to determine "fair use."

    Interestingly enough, the O'Reilly web site contains an overview in their writer's guidelines.

    Based on these, other sources, and my previous experience, I believe quoting from a Recipe is fine, provided you a) keep it reasonably limited, b) provide complete attribution (title, author, publisher, and ISBN), c) aren't competing with the publisher (e.g. charging for it), and c) don't try to pass it off as your own work (unless, of course, it _is_ your own work).

    Mind you, I'm not a lawyer and there are a number of ways you can interpret these two documents, but if you read some of opinions issued in cases involving the Fair Use doctrine, it pretty much boils down to giving credit where credit is due and not competing with the original publisher/author.

    --f

    P.S. I'm currently digging a little deeper into this; I'll update when I have more information.

(redmist) Re: Fair Use When Referring to Book Answers?
by redmist (Deacon) on Nov 17, 2000 at 21:00 UTC
    To be honest, I don't care what copyright lawyers say is Fair Use. I follow my own ethics. I copied a 6 line piece of code out of the Cookbook so that I could help Octavian out. I did not send all of O'Reilly's IP his way. I made a reasonable use of my resources to help out a Monk.

    If anything, this would help O'Reilly because Octavian could see that the Cookbook is a valuable resource and that he should buy it. I did not lessen the Cookbook's marginal value because I gave a 6 line snippet (and gave credit).

    If some lawyer has a problem with that, they can kiss my ass.

    IDENTIFICATION DIVISION.
    PROGRAM-ID.  redmist.
    AUTHOR.  God (Larry Wall/Alan Cox hybrid).
    CONTACT.  redmist@users.sourceforge.net
    
(d4vis)Re: Fair Use When Referring to Book Answers?
by d4vis (Chaplain) on Nov 18, 2000 at 00:23 UTC
    As a compliment to footpad's post:

    The "Fair Use" guidelines (Title 17 sec. 107) can be found here.

    Notwithstanding the provisions of sections 106 and 106A, the fair use of a copyrighted work, including such use by reproduction in copies or phonorecords or by any other means specified by that section, for purposes such as criticism, comment, news reporting, teaching (including multiple copies for classroom use), scholarship, or research, is not an infringement of copyright. In determining whether the use made of a work in any particular case is a fair use the factors to be considered shall include -
    (1) the purpose and character of the use, including whether such use is of a commercial nature or is for nonprofit educational purposes;
    (2) the nature of the copyrighted work;
    (3) the amount and substantiality of the portion used in relation to the copyrighted work as a whole; and
    (4) the effect of the use upon the potential market for or value of the copyrighted work. The fact that a work is unpublished shall not itself bar a finding of fair use if such finding is made upon consideration of all the above factors.

    I believe that quoting code from the perl books qualifies as fair use, this being a nonprofit, scholarly, even a teaching situation. Of course, I'm not a lawyer either...thank Dog. ;)
    Perhaps merlyn would be in a better position to answer this question than most of us?

    ~monk d4vis
    #!/usr/bin/fnord

Re: Fair Use When Referring to Book Answers?
by Malkavian (Friar) on Nov 17, 2000 at 20:29 UTC
    As far as I remember, fair use is one of these really fuzzy things that give you a lot of leeway.
    Lecturers at universities often copy examples and diagrams for a book, to illustrate their point. This is considered 'fair use'.
    Simply taking a code section from a book, to illustrate the solution to a question on PM would also be considered 'fair use', as, you've purchased the book as a reference, which it is, and used it in a correct manner to aid in problem solution.
    This would be the same as cribbing from this book to gain a solution in code used for a company you're doing work for.
    However, posting the whole chapter of the book that contained the code fragment would be overkill, and would definately be a little 'unfair'.. Thus opening you up to copyright violation charge.
    I believe that posting an application complexity chunk of code (not a quick demonstration fragment), then, you'd be infringing on fair use.
    As a rough guide (and, I believe that's all there really is to go on), small fragments of code used to indicate a solution are fair use, especially if these fragments are commonly available, and heavily used.
    Posting large sections of the book are a no-no.
    Bear in mind that here, a lot of good Perl work is bandied around. If you make a reference to the author/book you're referred to, then it would almost certainly be considered 'fair use' by the publishers, as it's a strong commendation of their product, making it more likely that others will hear, and thus purchase it themselves.
    If you really want the absolute answer in each case, it'd most likely be a case of calling the publishers, as different people are likely to call unfair use in many different circumstances.

    Cheers,

    Malk
Re: Fair Use When Referring to Book Answers?
by Adam (Vicar) on Nov 17, 2000 at 22:23 UTC
    I think that its ok to quote small pieces of a book, so long as you provide proper refences back to that book. If you want to give a longer example, keep in mind that most programming books provide the code online in addition to in the text, so you can include that url instead of posting lots of code. For example, the Perl Cookbook provides some code online at O'Reilly, although I doubt that's all of it. Another example is Lincoln Stein's Official Guide to Programming with CGI.pm for which John Wiley & Sons, inc. maintain a web page with all the code examples.

Re: Fair Use When Referring to Book Answers?
by arturo (Vicar) on Nov 17, 2000 at 21:44 UTC

    Whatever exactly "fair use" covers, it certainly covers using short bits of sample code to illustrate a concept. Like redmist (or maybe not? =) I sort of cut and pasted an answer to a question (and was, IMO, inexplicably rewarded heavily in XP for doing so) out of the Ram book (my code differed in that I used $pwd instead of $password). Sure there's more than one way to do it, but in this case it was a *three line* snippet, using the functions provided by a module. Doubtless Messrs. Christiansen and Torkington (the authors of that book) would have given the same answer gratis as well. It might even be hard to argue that something that simple counts as *intellectual property* if IP laws are anything like patent laws (the answer is kind of obvious, once you know of the existence of the module). There aren't too many different ways to do it in a way that gets at what's *essential* in this particular case, and (as has also been mentioned here), by explicitly citing the book you do emphasize (a) the provenance of the concept and (b) the value of the book.

    In all likelihood (I haven't checked) the same example, or something close to it, occurs in the documentation for that module.

    Of course, I've been in an academic setting for a while, where we're *always* citing other people and that's pretty much all that "fair use" demands. I tend to view reproducing *snippets* of code, of the size and simplicity involved in this particular case, as not at all a big deal as long as the source is acknowledged. Now, had I reproduced somebody's published algorithm for cracking RC5 without brute force, that would be another matter =)

    Not that my opinion matters, I suppose, to the copyright lawyers and judges...

    Philosophy can be made out of anything. Or less -- Jerry A. Fodor

Re: Fair Use When Referring to Book Answers?
by ivory (Pilgrim) on Nov 19, 2000 at 16:31 UTC
    I think that in general, so long as you cite the source, copying small snippits of code to answer someone's questions is fine. Technically, copyright law is supposed to protect an author's economic rights to profit from their work. So if you tried to sell code that is protected by copyright, or used it in order to produce something that you would sell (for instance, taking code right out of a book and putting it into software that you intend to sell), that's stealing. But, referencing a book when teaching someone something (assuming you are not charging them for the teaching) should be okay. Consider that the person asking the question would probably not go out and buy the book simply because you tell them that the Cookbook has an answer to their question, so you're not exactly taking money out of the pockets of authors. But, if the Cookbook answer is helpful, they might be more inclined to buy the book in case it come in handy the next time they get stuck. ivory
      Actually (in the US) the purpose of copyright law is to promote the production and dissemination of knowledge into the public domain. Preserving the ability of the author to make a profit is mechanism, not purpose.

      In point of fact it is a spectacular failure at its intent because it has proven too easy for the owners of intellectual property to manipulate the laws. It also does not matter on a practical level either. The laws are the laws and they apply whether or not you or the author planned to make money - or even if the author intended (using the GPL) to subvert the whole system!

        Although quite a few philosophers, etc. have talked about this sort of purpose in theory (think Nozick, Mill, etc.), I still think that the main purpose of copyright law (and patent law) is to preserve the author's (or inventor's) ability to profit from their work.

        In general, these older legal traditions were created with the sole intention of allowing the wealthy to retain their wealth, in this case by expanding our normal understanding of property rights to include intellectual property. The idea with property rights in general, be they real or intellectual property rights is, first and foremost, retention of economic interest.

        ivory

Re: Fair Use When Referring to Book Answers?
by Macphisto (Hermit) on Nov 21, 2000 at 02:54 UTC
    Macphisto walks through the monestary attempting to avert his eyes at every step as his beloved perlmonks, his last bastion of true coders/hackers, slowly but surely, turns into slashdot.

    I'm not saying slashdot is a bad thing. It's a great source of news and information ( and keeping an eye out for CowboyNeal's scrathing records ), but I can't stand to read the posts because more and more they become about posturing and people with unrelenting ego's thinking they are 100% correct.

    While I really liked redmist's ( our own Erol Flynn ) reply,as well as some others ( For once, I actually agreed with tilly that perhaps the initial idea of copyright is the dissemination of knowledge, but I still feel it has become about money. ) I was dismayed as I came to the last post and saw a relative lack of information. A lot of people have posted what they 'feel' nobody has taken the time to do a search for what the law says so we can get a bottom line, or perhaps posted a good clean article on the 'ethics' of posting the others work. If I wasn't leaving for work I'd take the time to do it myself and perhaps it'll be on my list of things to do tonight.

    I didn't like, merlyn's post and --'d it because it gave no support for why it was 'wrong' as well, it seemed like a territorial pissing to me. Just in my opinion, others, possibly Randal himself saw it otherwise.

    But please, as of late I've seen a lot more posturing on perlmonks and I know a lot of people don't want to this place turn into /. Heck, even I was voted down by Ovid because I cursed once in an early post 6 months ago, and it was explained that we were attempting to stay away from the the /. stigma. I completely agree with that view.

    This probably would have served best if I made this its own thread, but I've already started typing...so what the hey...

    regards, macphist0


    Everyone has their demons....
Re: Fair Use When Referring to Book Answers?
by lemming (Priest) on Nov 20, 2000 at 22:18 UTC
    I'm of the opinion that references should be made if you're grabbing more than a few lines. (Unless it's something real slick) I think this is such a hot topic due to Perl's cutNpaste nature.
    O'Reilly probably doesn't care too much since they do make the code that it is in their books available for download. The Cookbook code is without any attribuation, Perl for System Admin has it.

    On this group though, say where you've gotten the code so other monks can benefit from what else the source offers.
A reply falls below the community's threshold of quality. You may see it by logging in.