An Introduction to Open-source Licenses

We teamed up with SiteGround
To bring you up to 65% off web hosting, plus free access to the entire SitePoint Premium library (worth $99). Get SiteGround + SitePoint Premium Now

Choosing an open-source license

The web community is renowned for its willingness to share. Not only do we share experiences, give advice and help each other with projects, but we also share an incredible amount of code—from small snippets to entire frameworks and applications.

Much of the software we use daily is open-source—from operating systems and servers to the apps we use to ply our trades.

Amid all of this sharing, there arises the issue of copyright and licensing. If you're using someone else's free software, or if you're sharing your own work, it's important to consider these issues.

Standard Copyright

When you create a piece of software, it's automatically protected by copyright. This means that you retain all rights to your source code and that nobody else may reproduce, distribute, or create derivative works from your work.

It may also lead to no one using your code—which obviously defeats the purpose of sharing it.

So if you really do want to share your work, but also want to protect it in some way, it's important to consider the options available for licensing your work.

Choosing a License

There are various, recognized licenses you can apply to your work to make it really clear what people can do with your code. But each license has a particular focus, so which should you choose?

In this article, I'll briefly introduce several of the most used licenses. Which one you choose will depend on what you want to achieve and how your code should be distributed.

Disclaimer: the overview that follows only provides a general sense of what each license encompasses. To understand each license fully, you'll need to do more reading.

MIT License

mit

The MIT License lets people do anything they want with your code, as long as they provide attribution back to you and don't hold you liable if something goes wrong. It's used by projects like jQuery and Rails.

What's Required of You

You need to include a copyright notice, together with a copy of the license, within the code. (Just add a License file together with the ReadMe file.)

How You're Covered

The license states that the code is provided as is, and that you can't be held liable for damages.

Comments

This is probably the best option if you want to get your baby out and leave it to the interwebz.

Having said that, you should be ready to see your creation used elsewhere without the source available, meaning that you might be unable to apply the changes upstream (yes, basically someone can create proprietary software from your open-source software).

If you don't want others to have so much freedom to use your code, it might be better to consider another license.

Apache 2.0 License

apache

The Apache License is similar to the MIT License, but it also provides an express grant of patent rights from contributors to users.

It's much longer than the MIT license, mostly due to the grant of patent rights, but also because it explicitly disallows the use of trademarks in derivate works.

This license is used by—you guessed it—Apache, as well as Google (for its Android OS).

What's Required of You

Within the code, you need to include a copyright notice, together with a copy of the license. If you're creating a derivative work with significant changes to the code, these need to be indicated also.

How You're Covered

The code is provided as is and you, as the creator, can't be held liable for damages. Also, while this may be implicitly true of all licenses, the Apache license explicitly states that users of the software may not use the names, logos, or trademarks of contributors in their own derivative works.

Comments

Although a tad more restrictive than the MIT License, the Apache license makes it easier for the creator of the code to track changes—by requiring those creating derivatives to indicate significant changes to the code.

Still, remember that code licensed under the Apache License can end up in proprietary software.

GNU General Public License v3 (GPL3)

gpl

The GNU General Public License (or GPL for short) is a copyleft license.

Copyleft is a play on copyright, and applies to licenses that require copies and modified versions of the code to carry the same license conditions as the original. So, if you place a GPL license on your work, for example, you're asking those who distribute their own versions of your code to use the same license.

Placing a GPL license on your work means that, if someone takes your code and improves it, you can incorporate their changes back into your original project.

This license is used by the likes of Linux, Git and WordPress.

What's Required of You

You need to include a copyright notice, together with a copy of the license, within the code. You must also make the source code available when you release the software.

How You're Covered

The code is provided as is and you, as the creator, can't be held liable for damages. Users of your work can't grant a sublicense to modify and distribute the software to third parties not included in the license.

Comments

Basically, if your code is licensed under GPL, it's not allowed to be used in any proprietary software (except under certain special circumstances).

There's a lot you can find out about GPL, such as the differences between GPLv3 and GPLv2, and GPL's many variations—such as Affero General Public License, which covers things like Software as a Service (SaaS).

Other Licenses

other

Though the three licenses above are the ones you'll come across most—and the ones you're most likely to choose—there are many others. I'll briefly list just a few.

Artistic

Preferred by the Perl community among others, it bears some similarities with the MIT license but requires that modified versions of the software do not prevent users from running the standard version.

Also, while this may be implicitly true of all licenses, the Artistic license explicitly states that you may not use the names, logos, or trademarks of contributors (similar to the Apache License).

If you're creating a derivative work with significant changes to the code, these need to be indicated too.

Eclipse

The commercially-friendly copyleft Eclipse license provides the ability to commercially license binaries; a modern, royalty-free patent license grant; and the ability for linked works to use other licenses, including commercial ones.

The full source code needs to be disclosed when the software is published.

BSD

A permissive license that allows people to do anything with your code with proper attribution and without warranty.

Mozilla Public License (MPL)

MPL 2.0 is maintained by Mozilla. It attempts to be a compromise between the permissive BSD license and the reciprocal GPL license.

Creative Commons (CC)

Creative Commons provides a range of licenses for refining your copyright terms. With the CC0 license, for example, you can go the whole hog and relinquish all copyright claims, thus releasing your work entirely to the public domain. (Note, however, that CC recommends using licenses like MIT, Apache and GNU for software, because CC licenses don’t address the many issues related to code.)

Wrapping Up

Hopefully this brief overview has gotten you thinking about licenses and has answered a few of your questions about them.

There's a lot of reading you can do to find out about each license. But if that seems overwhelming, in most cases even the brief descriptions above can be enough to help you decide which license is right for you.

To finish up, here are some links for further reading:

Have you needed to choose a software license? Which one did you choose, and what determined your choice? Are you still confused about which license to choose for your project? Let us know in the comments.

Also, did you know that the SitePoint forums have a Showcase section where you're invited to share your code and talk about your open-source projects?

We teamed up with SiteGround
To bring you up to 65% off web hosting, plus free access to the entire SitePoint Premium library (worth $99). Get SiteGround + SitePoint Premium Now