Gists are a popular method of providing code snippets to the community. These snippets frequently express complete implementations of an algorithm (for example, QuickSort in C) or smaller chunks of examples.
I recently came across this implementation of a circular buffer in Swift to help with an upcoming chat client blog post. Unfortunately I cannot use this code as I pay close attention to the copyright statements of all source code and adhere to their caveats, restrictions, and limitations. This is one reason I’m not comfortable with including code that uses the Affero GPL.
The circular buffer gist in question above uses the phrase All rights reserved in its copyright statement:
Copyright (c) 2014 Pelfunc, Inc. All rights reserved.
Strictly speaking copyright law does not require this statement, as all copyright rights are reserved by default, regardless of whether or not there is a copyright statement. In other words, you are granted no rights to a copyrighted work without explicit permission. The conclusion is I may not copy or use the code in this gist without permission from the author, even if it is for my own personal use.
Now, let’s be honest. I seriously doubt that was the intent of the author; after all, the code was posted to a gist. If the intent wasn’t for others to make use of the code, why was it posted? One might argue gists can be used as one’s own frequently used snippet bucket, but I find that relatively implausible considering that in this case it is a corporation (Pelfunc, Inc.) holding copyright. The more likely explanation is that people don’t put much consideration into the copyright statement and reflexively type something they’ve seen elsewhere, namely the phrase
Copyright (c) 2016 Megaco, Inc. All rights reserved..
Make it Easy for Others to Use Your Code
Gists are for sharing, and there are ways to make it easy for others to use the code which you’ve kindly shared with the community. The easiest method is to add a simple statement referring to the Unlicense license or using the phrase “This is free and unencumbered software released into the public domain.” If you do want to retain some rights, choose from the MIT, BSD, or ISC licenses and include a URL to the license text. And of course, you can always choose from one of the copyleft licenses.
Under almost no circumstances, though, should you use the phrase All rights reserved in your gists if you actually want to share and have others make use of your code! I can only think of one exception and that would be if you wanted to get e-mails asking if you’d please give permission to use. If that’s the case go ahead and add that to your gist as the uninitiated might just copy it anyway.
After writing this post I went on the hunt for another circular buffer implementation in Swift, and found this one that has purports to use the MIT license. Of course I went to lift out the implementation file CircularBuffer.swift and it has the onerous All rights reserved phrase, ostensibly as a result of the defaults set in Xcode. I genuinely believe the author’s intent was to provide this as an open source framework, and have issued a pull request to update the license in each of the
.swift file copyright statements.