20

The Stack Overflow site footer says:

user contributions licensed under cc by-sa 3.0 [Creative Commons Attribution-ShareAlike 3.0 Unported] with attribution required

And one of the terms of CC BY-SA is:

If you remix, transform, or build upon the material, you must distribute your contributions under the same license as the original.

Does the ShareAlike part mean that code from answers can't be used in closed-source software?

6
  • 4
    No, use in closed source is fine. But this is not legal advice and you should not trust it. If this really matters to you, you need to have your lawyer read and understand the license.
    – Dave S
    Jun 12, 2017 at 16:49
  • Dave S, doesn't your statement contradict the term of CC BY-SA added above?
    – awvalenti
    Jun 12, 2017 at 18:01
  • 4
    Like I said, I'm not a lawyer and this is not legal advice :) . StackOverflow answers are tiny fragments of code not usable programs. I've never heard of any attempt to enforce copyright on scraps and snippets like this when used individually as opposed to bulk use like cloning a site to scam ad dollars.
    – Dave S
    Jun 12, 2017 at 18:04
  • Don't forget that not all code snippets are copyrightable (you'd need to be able to perform the same task in multiple ways, and have the way it was done not be likely for two programmers to create independently). Some snippets certainly are copyrightable, though, but remember it's the creative parts of it that are copyrightable (you can't copyright ideas). Sep 13, 2018 at 2:53
  • @DaveS, meta.stackoverflow.com/a/370418/632951
    – Pacerier
    Aug 20, 2020 at 19:26

2 Answers 2

13

I am not a lawyer

There is no real plausible reason to need to copy/paste, and then use, large pieces of code verbatim from Stack Overflow. Most of it is example code that applies to what is supposed to be a demo, or a minimal example.

Perhaps it makes sense if there is a simple css class with a set of transitions you like, however, a single css class would constitute fair use; just as one line of code would (provided it isn't golfed or something).

That said, if you do need to copy code verbatim from Stack Overflow in a decently large quantity, and use it in production, then you must abide by the license. There needs to be a citation in the production base for the author of the code.

Most programmers will use the idea or code from a Stack Overflow solution as a template or as a guide, but not as their actual implementation.

1
  • 10
    You state the attribution requirement ("There needs to be a citation") but say nothing about share-alike, which is the crux of the matter in the context of the question.
    – user6655984
    Jun 16, 2017 at 3:05
4

First as many where, I am not a lawyer. But, AFAICT the answer is both "Yes" and "No"

The TL;DR version is if you modify the code then no. For example you take some C++ code and you compile it. The compiled code is a modified version of the code you took. As such your project has to be released under the same license. Conversely if you take some JavaScript, you do NOT run it through a builder so it stays the same code, and you just include it via a script tag or an import statement then it's likely ok of course with proper attribution.

Examples from the Creative Commons organization that suggests this conclusion.

From the actual license

3.b

ShareAlike.

In addition to the conditions in Section 3(a), if You Share Adapted Material You produce, the following conditions also apply.

  1. The Adapter’s License You apply must be a Creative Commons license with the same License Elements, this version or later, or a BY-SA Compatible License.
  2. You must include the text of, or the URI or hyperlink to, the Adapter's License You apply. You may satisfy this condition in any reasonable manner based on the medium, means, and context in which You Share Adapted Material.
  3. You may not offer or impose any additional or different terms or conditions on, or apply any Effective Technological Measures to, Adapted Material that restrict exercise of the rights granted under the Adapter's License You apply.

And from the defintions in the same license

Section 1 – Definitions.

a. Adapted Material means material subject to Copyright and Similar Rights that is derived from or based upon the Licensed Material and in which the Licensed Material is translated, altered, arranged, transformed, or otherwise modified in a manner requiring permission under the Copyright and Similar Rights held by the Licensor. For purposes of this Public License, where the Licensed Material is a musical work, performance, or sound recording, Adapted Material is always produced where the Licensed Material is synched in timed relation with a moving image.

b. Adapter's License means the license You apply to Your Copyright and Similar Rights in Your contributions to Adapted Material in accordance with the terms and conditions of this Public License.

c. BY-SA Compatible License means a license listed at creativecommons.org/compatiblelicenses, approved by Creative Commons as essentially the equivalent of this Public License.

d. Copyright and Similar Rights means copyright and/or similar rights closely related to copyright including, without limitation, performance, broadcast, sound recording, and Sui Generis Database Rights, without regard to how the rights are labeled or categorized. For purposes of this Public License, the rights specified in Section 2(b)(1)-(2) are not Copyright and Similar Rights.

For example say you have a website, you put a CC-BY-SA image on the site. The image itself is unmodified, you've given the required attribution, people are free to download the image from you and continue to use it a CC-BY-SA.

Similarly would be a library marked as CC-BY-SA. You use that library without modification and give correct attribution. Does the rest of your app or site now have to be CC-BY-SA?

The wiki link above says

The ShareAlike licenses require that licensees make their contributions to adapted material available under the same terms and conditions

Adding a single image to one article in a 50 page website is not "making their contributions to adapted material". Editing the picture is "making their contributions to adapted material" and if it was code then adding feature or fixing bugs is "making their contributions to adapted material" but not using the library as "making their contributions to adapted material"

The actual license says CC-BY-SA is required when ...

in which the Licensed Material is translated, altered, arranged, transformed, or otherwise modified in a manner requiring permission under the Copyright and Similar Rights

A single CC-BY-SA image in a large website or using a CC-BY-SA library is not

  • translated (no, nothing was translated)
  • altered (it has not been altered it)
  • transformed (it has not transformed)
  • or otherwise modified (it has not been modified)

That leaves arranged . Arranging seems to be related to musical scores since CC was designed for art/music/video and not code.

Some other examples from the Creative Commons site that make this more clear

Can I share CC-licensed material on file-sharing networks?

Yes. All CC licenses allow redistribution of the unmodified material by any means, including distribution via file-sharing networks.

So yes, including some CC-BY-SA content on a site does not infect all the other content.

When is my use considered an adaptation?

... Generally, a modification rises to the level of an adaptation under copyright law when the modified work is based on the prior work but manifests sufficient new creativity to be copyrightable, such as a translation of a novel from one language to another, or the creation of a screenplay based on a novel.

... Under CC licenses, synching music in timed relation with a moving image is always considered an adaptation, whether or not it would be considered so under applicable law.

I called out music there to show it's special but otherwise putting an unmodified image or using an unmodified library doesn't fit the defintion of adaptation above.

Can I combine material under different Creative Commons licenses in my work?

... If the combination does not create an adaptation, then you may combine any CC-licensed content so long as you provide attribution and comply with the NonCommercial restriction if it applies ...

Combining the last 2 paragraphs CC-BY-SA is more like LGPL than GPL. In other words if you link to it (via script or import) then you're okay. If you compile it or link with it you're not ok

If I create a collection that includes a work offered under a CC license, which license(s) may I choose for the collection?

All Creative Commons licenses (including the version 4.0 licenses) allow licensed material to be included in collections such as anthologies, encyclopedias, and broadcasts. You may choose a license for the collection, however this does not change the license applicable to the original material.

It further goes on to show commercial collections are ok to include CC-BY-SA items but that particlar item stays CC-BY-SA.

CC was arguably designed for traditionally creative works (art, music, video) and hence the name "creative" commons. It's unfortuante that S.O. choose CC when CC themsevles recommend against it though I suspect that recommendation came after S.O. started using the license.

Can I apply a Creative Commons license to software?

We recommend against using Creative Commons licenses for software. Instead, we strongly encourage you to use one of the very good software licenses which are already available. We recommend considering licenses listed as free by the Free Software Foundation and listed as “open source” by the Open Source Initiative.

Also note apparently at least one judge has ruled, for example, that putting a CC-BY-SA photo on the cover of your book does not require your book to by CC-BY-SA

https://opensource.stackexchange.com/a/8364/16125

11
  • 1
    You should probably mention fair use; i.e. if you don't copy the code verbatim and instead implement the strategy yourself you're probably in the safe zone.
    – S.S. Anne
    Mar 19, 2020 at 12:39
  • Too many parts of this answer are irrelevant. Completely pointless to talk about rulings of book cover photos. Related only if a chapter's paragraph (ie text) was share-alike. Or, Related only if a manga's 1 page/window out of so-called "50 pages" was share-alike. Does the whole work end up being share-aliked? GPL says yes. Also, pointless to talk about code libraries as none are found on stackoverflow; 99.99% all functions/snippets.
    – Pacerier
    Aug 20, 2020 at 7:27
  • Is there a legal definition of code libraries? Here's a famous one that's easily the size of a snippet. Only 4.4million downloads this week. Here's another, without comments it's 8 lines of code. I'm sure if I spent more than 2 minutes searching I could find smaller libraries.
    – gman
    Aug 20, 2020 at 9:58
  • 1
    @gman, The packaging is more important than the char content. If npm install foobar works, then great(!) foobar is a library. But 99% of the times I can't do SE-npm godinstall /a/153624 and have it work. Modification is needed, be it the function signature or the internals or the global variables. (That 2 examples you gave are on npmjs.com not stackoverflow.com.) So those modifications are also infected all the way to the borders of the packaging. And 99% of the times, there is no such boundary. 100.00% of your app is infected; if you're lucky maybe >90%. Now you say, what if I'm the 1%: I
    – Pacerier
    Aug 20, 2020 at 20:42
  • 1
    ...create a class called InfectedBorder and every character I take from stackoveflow is placed within InfectedBorder. So I do InfectedBorder.Foo() or new InfectedBorder.Bar(). Am I okay? Yes I'm okay if I pass the analyses A, B, C, D, E, F, G, H, I, J, K, L,
    – Pacerier
    Aug 20, 2020 at 20:51
  • 1
    ...M, N, O, P, Q, among others (good luck trying to claim that InfectedBorder is armslength (a requirement), that it has its own update process, and the user can freely exercise his freedom to swap InfectedBorder with InfectedBorderV2, the only way to even be likely to succeed at that is to segregate each nonrelated part, so instead of one InfectedBorder, you will have InfectedBorderAreaAA to InfectedBorderAreaZZ) which among other things require me to say my
    – Pacerier
    Aug 20, 2020 at 21:19
  • 1
    ... project contains contributions from User1 at page1 modified by modlist1, User2 at page2 modified by modlist2, ..., User500 at page500 modified by modlist500 before I can package InfectedBorder in my app. Who does that? Does any
    – Pacerier
    Aug 20, 2020 at 21:20
  • 1
    ...of the Fortune 500 do that? (conversely it's a mere 1-liner footer to say "my website contains contributions from NPM left-pad, BravoPad, uppad padAA, ..., padZZ"). You can use 50 NPM libraries and it's still a 1-liner affair since you modify at most 1 or 2 libraries whereas for those 500 stackoverflow functions you need links to 500 users + 500 pages + 500 github projects logging all modifications made (and yes SE snippets need modification before use).
    – Pacerier
    Aug 20, 2020 at 21:20
  • 1
    ¶ And 1, 2, 3, 4, 5. Separately, re """if you take some JavaScript..""", I don't believe there's a citation which says if C/Java this, if JS/HTML that, but plenty of citations mentioning that the rules apply the same way regardless of language, bit.ly/2Q8EJVt. ¶ I completely fail to see how is putting line/s into a function not an adaption? How
    – Pacerier
    Aug 20, 2020 at 21:20
  • 1
    ...is putting function/s into a class not an adaption? / Re """if you link to it (via script or import) then you're okay""", what does "link" even mean here, and no it's not okay.
    – Pacerier
    Aug 20, 2020 at 21:21
  • I'm not sure what your point is. The "is it or is it not a library" is irrelevant. Code on S.O. is CC-BY-SA licensed. That license has rules. If you don't want to obey those rules then don't use code from S.O.
    – gman
    Aug 21, 2020 at 4:40

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .