3.7 Open Source Licensing
The objectives of this section are:
- Recall the principles of open source software
- Recall two open source licenses
You can specify how your R package is licensed in the package DESCRIPTION file
License: section. How you license your R package is important
because it provides a set of
constraints for how other R developers use your code. If you’re writing an R
package to be used internally in your company then your company may
choose to not share the package. In this case licensing your R package is less
important since the package belongs to your company. In your package DESCRIPTION
you can specify
License: file LICENSE, and then create a text file called
LICENSE which explains that your company reserves all rights to the package.
However if you (or your company) would like to publicly share your R package you should consider open source licensing. The philosophy of open source revolves around three principles:
- The source code of the software can be inspected.
- The source code of the software can be modified.
- Modified versions of the software can be redistributed.
Nearly all open source licenses provide the protections above. Let’s discuss three of the most popular open source licenses among R packages.
3.7.1 The General Public License
Known as the GPL, the GNU GPL, and GPL-3, the General Public License was
originally written by
Richard Stallman. The GPL is
known as a copyleft license, meaning that any software that is bundled with
or originates from
software licensed under the GPL must also be released under the GPL. The exact meaning of “bundle” will depend a bit on the circumstances. For example, software distributed with an operating system can be licensed under different licenses even if the operating system itself is licensed under the GPL. You can
use the GPL-3 as the license for your R package by specifying
in the DESCRIPTION file.
It is worth noting that R itself is licensed under version 2 of the GPL, or GPL-2, which is an earlier version of this license.
3.7.2 The MIT License
The MIT license is a more permissive license compared to the GPL. MIT licensed
software can be modified or incorporated into software that is not open source.
The MIT license protects the copyright holder from legal liability that might
be incurred from using the software. When using the MIT license in a R package
you should specify
License: MIT + file LICENSE in the DESCRIPTION file. You
should then add a file called LICENSE to your package which uses the following
YEAR: [The current year] COPYRIGHT HOLDER: [Your name or your organization's name]
3.7.3 The CC0 License
The Creative Commons licenses are usually used
for artistic and creative works, however the CC0 license is also appropriate for
software. The CC0 license dedicates your R package to the public domain, which
means that you give up all copyright claims to your R package. The CC0 license
allows your software to join other great works like Pride and Prejudice,
The Adventures of Huckleberry Finn, and The Scarlet Letter in the public
domain. You can use the CC0 license for your R package by specifying
License: CC0 in the DESCRIPTION file.
3.7.4 Why Open Source?
You’ve put weeks of sweat and mental anguish into writing a new R package, so why should you provide an open source license for software that you or your company owns by default? Let’s discuss a few arguments for why open sourcing your software is a good idea.
22.214.171.124 Paying it Forward
Software development began in academic settings and the first computer programs with code that could be shared and run on multiple computers was shared between academics in the same way that academics share other kinds of scientific discoveries. The R programming language is open source, and there are hundreds of high-quality R packages that are also open source. A programming language can have lots of exciting features but the continued growth and improvement of a language is made possible by the people contributing to software written in that langauge. My colleague Amy said it succinctly:
So with that in mind, if you feel that the R language or the R community has contributed to your success or the success of your company consider open sourcing your software so that the greater R community can benefit from its availability.
126.96.36.199 Linus’s Law
Now let’s turn off the NPR pledge campaign and move our line of thinking from the Berkeley Kumbaya circle to the Stanford MBA classroom: as a business person why should you open source your software? One great reason is a concept called Linus’s Law which refers to Linus Torvalds, the creator of Linux. The Linux operating system is a huge open source software project involving thousands of people. Linux has a reputation for security and for its lack of bugs which is in part a result of so many people looking at and being able to modify the source code. If the users of your software are able to view and modify the source code of your R package your package will likely be improved because of Linus’s Law.
Open source software’s relationship with hiring is a two-way street: if you open source your software and other people send you improvements and contributions you can potentially identify job candidates who you know are already familiar with your source code. On the other hand if you’re looking for a job your contributions to open source software can be a part of a compelling portfolio which showcases your software skills.
However there are pitfalls you should be aware of when weighing a candidate’s open source contributions. Many open source contributions are essentially “free work” - work that a candidate was able to do in their spare time. The best candidates often cannot afford to make open source contributions. The most meaningful ways that an individual contributes to their community usually has nothing to do with writing software.
Licensing and copyright laws vary between countries and jurisdictions. You shouldn’t consider any part of this chapter as legal advice. If you have questions about open source licensing software you’re building at work you should consult with your legal department. In most situations software that you write on your own time belongs to you, and software that you write while being paid by somebody else belongs to whoever is paying you. Open source licensing allows you to put restrictions on how your software can be used by others. The open source philosophy does not oppose the commercial sale of software. Many companies offer an open source version of their software that comes with limitations, while also offering a paid license for more expansive commercial use. This business model is used by companies like RStudio and Highcharts.