2

I'm working on a programming book, which will be distributed both electronically and (potentially) in print. It includes many coding samples, which readers may wish to use. To avoid the hairy, and usually-ignored issue of whether readers can use snippets of my code in their own works, I would like to release the code (but not the text of the book) as open-source--probably with the MIT license.

What is the best way to do this? I see a couple of options:

  1. I can mention on the copyright page that the code samples are released under the MIT license, then include the MIT licence in the appendix.

  2. I can mention that the code is available for download elsewhere, and provide a link. That link could include the MIT license and appropriate notices.

  3. Something else?

In case it's unclear, I'm not seeking legal advice, only for practical advice on how to best express a software license in an otherwise non-software work.

2

Option 1 is the most widely used approach.

As a fellow programming enthusiast, the typical way I've seen this done is to

  1. Clearly spell out somewhere in the introduction that "all code samples contained in this work are licensed under [x] license."
  2. Include a copy of the license in the appendix or on the copyright page, or provide a link to a webpage that contains it.

This StackExchange answer gives you a detailed breakdown of how to use the MIT license in your works. (See the most upvoted answer.)

This comprehensive breakdown of the MIT license may be helpful if you want to learn more about what the MIT license is specifically, and how to properly reference it, since there are actually multiple versions of the MIT license and different preferred methods of using it.

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.