copyright creative-commons
Does the originality requirement within U.S. copyright law mean that some Stack Overflow code snippets are not copyrightable?
<p>I understand that code on Stack Overflow is licensed under a CC BY-SA 4.0 license, and that fair use doctrine <a href="https://softwareengineering.stackexchange.com/questions/12171/how-does-fair-use-apply-to-code-snippets">may not apply to code snippets</a>.</p>
<p>I also recognize that it is ideal to rewrite code posted on Stack Overflow in our own words, both for legal reasons and for the learning experience it presents. <strong>However</strong>, what about code that would be hard or impossible to rewrite in our own words because there is only one accepted way to write it? Would it possibly be ineligible for copyright?</p>
<p>For instance, let's say that I go to Stack Overflow because a Python math function like math.modf is not working. I then see a Stack Overflow post explaining that to make math functions work, you need to enter this line:</p>
<p><code>import math</code></p>
<p>If I copy and paste the <code>import math</code> code into my own program, then release it under a non-Creative Commons license, does that mean that I am violating copyright? I'm doubtful that this would be the case due to the originality requirement within U.S. copyright law:</p>
<blockquote>
<p><strong>The Originality Requirement</strong></p>
</blockquote>
<blockquote>
<p>Originality is “the bedrock principle of copyright” and “the very premise of copyright law.” Feist Publications, Inc. v. Rural Telephone Service Co., Inc., 499 U.S. 340, 347 (1991) (citation omitted).</p>
</blockquote>
<blockquote>
<p>“To qualify for copyright protection, a work must be original to the author,” which means that the work must be “independently created by the author” and it must possess “at least some minimal degree of creativity.” Id. at 345 (citations omitted)</p>
<p><a href="https://www.copyright.gov/comp3/chap300/ch300-copyrightable-authorship.pdf" rel="nofollow noreferrer">Source</a></p>
</blockquote>
<p>The above chapter goes on to say that:</p>
<blockquote>
<p>“[T]here is nothing remotely creative” about a work that merely reflects “an age-old practice, firmly rooted in tradition and so commonplace that it has come to be expected as a matter of course.”</p>
</blockquote>
<p>A line like <code>import math</code> does not strike me as very creative; rather, it is simply a required bit of code for getting Python's math library to run within a program. I doubt it would be necessary to rewrite the code as <code>import math as m</code> when <code>import math</code> works just fine.</p>
<p>In other words, I am wondering if the originality requirement implies that some code snippets on Stack Overflow may not be original enough to be copyrightable in the U.S. Please let me know your thoughts.</p>
<p><strong>Additional notes:</strong></p>
<ol>
<li><p>I do not believe that <a href="https://meta.stackexchange.com/questions/12527/do-i-have-to-worry-about-copyright-issues-for-code-posted-on-stack-overflow">this FAQ post</a>, while informative,    addresses this specific question, since that post does not make any    reference to the originality requirement for U.S. copyright. The    answer to that post states, in part, that &quot;Anything that you post to    Stack Overflow will be under the terms of the Creative Commons    license.&quot; However, I believe there are cases (such as the one in my    example above) where a code snippet may not qualify for a Creative    Commons copyright because it fails to meet the originality    requirement. In fact, such cases may be substantial, especially for    beginner-level questions that address general programming    conventions.</p>
</li>
<li><p>tpg2114 pointed out in the Meta forum (where this question had originally been posted) that a detailed explanation + import math or similarly non-original code block + detailed explanation as a whole would qualify for a CC license. I think my main concern is about situations where the code provided is the widely accepted best practice for a particular language, rather than someone's original creative work. In other words, if the line of code reflects how thousands of programmers around the world would accomplish a task because it's the best way to do so, I'm just doubtful whether a    copyright license would apply.</p>
</li>
<li><p>tpg2114 also helped me realize that a relevant question here is: if something can't be copyrighted, does it qualify for a Creative Commons license? The following quotes from the Creative Commons website indicate that material that can't be copyrighted also can't have a Creative Commons license applied to it:</p>
</li>
</ol>
<blockquote>
<ol>
<li>&quot;CC licenses do not contractually impose restrictions on uses of a work where there is no underlying copyright.&quot;</li>
</ol>
</blockquote>
<blockquote>
<ol start="2">
<li>&quot;CC licenses are operative only when applied to material in which a copyright exists, and even then only when a particular use would otherwise not be permitted by copyright.&quot;</li>
</ol>
</blockquote>
<blockquote>
<ol start="3">
<li>&quot;You should also not apply Creative Commons licenses to works that are no longer protected by copyright or are otherwise in the public domain.&quot;<br />
Source for all 3 quotes</li>
</ol>
</blockquote>
<ol start="4">
<li>This raises a new question: even if a post + code snippet as a whole are eligible for Creative Commons (due to the originality expressed in the text, for instance), if the code snippet by itself does not qualify for copyright because it's similar to import math, would I be able to use that without releasing my own program under Creative Commons?</li>
</ol>
<p>I believe the following quote may help answer this question:</p>
<blockquote>
<p>&quot;To constitute an adaptation [which would need to be licensed under CC-BY-SA as well if the source was CC-BY-SA], the resulting work itself must be considered based on or derived from the original. This means that if you use a few lines from a poem to illustrate a poetry technique in an article you’re writing, your article is not an adaptation because your article is not derived from or based on the poem from which you took a few lines.&quot; <a href="https://certificates.creativecommons.org/cccertedu/chapter/4-4-remixing-cc-licensed-work/" rel="nofollow noreferrer">Source</a></p>
</blockquote>
<p>So in other words, if I take an excerpt like import math from a CC-BY-SA post on Stack Overflow and incorporate it into a larger project, my project may not be an adaptation of the Stack Overflow post, and therefore I may not need to release my project under CC-BY-SA as well. I say &quot;may not&quot; because (1) I'm not a lawyer, and (2) the code snippet isn't just an illustration or an example, but rather plays an important role in the functioning of my actual program.</p>
<ol start="5">
<li>I also found <a href="https://www.linkedin.com/pulse/do-code-snippets-violate-copyright-law-russ-pearlman/" rel="nofollow noreferrer">this helpful article</a> from an attorney that addresses whether simple code snippets can be copyrighted: However, this article states that Stack Overflow posts are covered by CC-BY, when in fact they're covered under CC-BY-SA.</li>
</ol>

<p>You are in general correct,  KBurchfiel. A code snippet such as</p>
<pre><code>import math;
</code></pre>
<p>or</p>
<pre><code>For i := 1 to 10  
  print i;
</code></pre>
<p>has no originality, and is not protected by copyright. A post eplaining the meaning an usage of such a snippet might well be original enough to be protected by US copyright, indeed it probably would. But the code on its own would not be. Anyone could read such a post, and if s/he understood it, use the code snippet and not be in violation of copyright, not compelled to place the entire program in which such a snippet was used under a CC-=BY-SA license.</p>
<p>The creative commons people would prefer that a CC license not be applied to a publication that is not protected by copyright, and if it is so applied it is legally meaningless. But they have no legal way to enforce such a preference.</p>
<p>A stack exchange post that consisted of <strong>nothing</strong> but such an uncopyrightable code snippet, with no explanation r discussion, might well be downvoted or even deleted. But that is a matter of site policy on what is a useful answer, not a matter of copyright.</p>
<p>Using an excerpt from a copyrighted work so small that the excerpt alone would be uncopyrightable, would probably be fair use under US law, and might well be fair dealing in UK law.</p>
<p>Something that is fair use does not compel the reuser to abide by the terms of a CC license, because those terms apply <strong>only</strong> when the content could not be reused without the CC license's permission.</p>
<p>However, a code snippet does not need to be very much more original than the above examples before it becomes copyrightable. Whether it can be used via fair use rather than via the CC-BY-SA license is a very fact-based decision (the usual four-factor analysis is spelled out in 17 USC 107).. But if the snippet can be rewritten to express the same concepts but in a different expression, then there is no copyright issue, and again the CC license will not apply.</p>
<p>If the snippet is complex and original enough to be copyrightable (a fairly low bar) and it is re-used unchanged, under conditions where fair use does not apply, then the CC-BY-SA license's terms must be complied with for the use to be legal. That is several &quot;IFs&quot; however. The exact details of a specific case will matter in such cases, there is <strong>not</strong> one rule for all snippets, all posts, or all programs.</p>
