12

Actually CC BY-SA 3.0 is a license which looks pretty good for most Stack Exchange Network sites, but on Stack Overflow which is used mainly for coding questions, is pretty much rigid since a lot of answers contains portions of code that usually are intended to be copy-pasted.

For example yesterday I did need to copy the following 2 lines of code from How to make a div's background color translucent? in order to give some style to a css file.

background-color: #fff;
background-color: rgba(255,255,255,0.5);

As I understood the conditions on the Terms of service I should include something like the following in my code:

/*!
 * Code snippet from StackExchange Network question on <https://stackoverflow.com/q/4729196> by at. <https://stackoverflow.com/users/326389>
 * Edited by user <https://stackoverflow.com/users/3075942>
 * Answered and copied from <https://stackoverflow.com/a/4729214> by David Thomas <https://stackoverflow.com/users/82548/david-thomas>
 * Licensed under CC BY-SA 3.0 <http://creativecommons.org/licenses/by-sa/3.0/>
 */

Which could be ok to certain point considering just 1 copy-paste on my entire project. But not for the daily work.

As today, I needed to copy 20 characters from How would you convert secs to HH:MM:SS format in SQLite?, and I don't know if it's wrong to not attribute, but I know it's wrong to attribute 20 characters.

Is copying 1 or 2 lines of code considered fair use? Varies by country? Should we think on other license for programming sites?

  • 1
  • Your code comment snippet should be enough in my opinion. – angussidney Nov 26 '15 at 8:49
  • 1
    I think that is insane in a lot of cases. – Hacktivista Nov 26 '15 at 21:18
  • 1
    I just re-read the question and realised that you were asking if it was OK to copy without attribution for that small amount of code, rather than asking whether that was enough citing. I think that it should be OK to copy that without attribution. – angussidney Nov 27 '15 at 5:12
  • 2
    I don't think it's actually possible to copyright transparent backgrounds via CSS. – user1228 Nov 30 '15 at 16:11
  • Related: meta.stackexchange.com/questions/271080/… – Nemo Dec 20 '15 at 17:55
8

Those 2 lines are public domain because they don't meet the threshold of originality. Copying them is not fair use: it's entirely free as far as copyright goes. This is valid in all countries.

However it's possible even for a single line of code to be original and hence copyrighted. The distinction is usually hard to make and varies per jurisdiction, which is why some users release their code snippets in the public domain with the Creative Commons Zero (CC-0) waiver, as recommended by FSF. See also a fuller list and users mentioning a license. Dual licensing is not forbidden by ToS, either.

I think most code snippets which are really meant to be copied "virally", or more or less indiscriminately, tend to be of the unoriginal, public domain kind.

I'm not sure you really need such a big code comment, that's probably another question.

  • 1
    Not sure if this applies. If the ToS, which we all agree to when we use SE, gives more restrictions than just the copyright laws, we still have to follow the ToS. – Patrick Hofman Nov 26 '15 at 9:22
  • 2
    @PatrickHofman that's why I said "as far as copyright goes". Applicability of ToS for content reusers is a complex and politically charged matter which I decided to leave out of my answer. I'm convinced ToS are not an issue for the specific case at hand, though. – Nemo Nov 26 '15 at 10:35
  • 1
    @Nemo ToS are a big issue here, as you are allegedly accepting them when you visit the site, indistinctly of opinions about the legal validity of the terms, nobody should make terms in order to be ignored. My point is that if terms are wrong, should be corrected. – Hacktivista Nov 26 '15 at 21:24
  • @Hacktivista If you mean article 3 of the ToS, I'll note that 1) the attribution requirements are just an appendix to the cc-by-sa legal text and cannot override it; 2) all CC licenses recognise the public domain and copyright exceptions and explicitly deny any attempt to circumvent either; 3) attribution in CC licenses must be "reasonable" for the medium; 4) your example is arguably not even an example of reproduction; 5) ToS is vague, hence your example might not qualify as "Subscriber Content" or "post or otherwise use Subscriber Content". Hence I'd go by the letter of the license. – Nemo Nov 27 '15 at 18:41
  • @Nemo All that I'm saying is not about my case in specific, but the applicability of ToS to common Stack Overflow use. My question is: "Should we think on other license for programming sites?" – Hacktivista Nov 27 '15 at 21:13
  • @Hacktivista you say the problem is ToS but then ask about license? The license is not an issue AFAICS. – Nemo Nov 27 '15 at 21:14
  • @Nemo ToS specifies a license that applies to all activity when you use the Stack Exchange Network. So yes, It's about ToS and licenses. – Hacktivista Nov 27 '15 at 21:17
  • @Hacktivista is the license the only issue you have with ToS? Can you clarify what makes you think the license is an issue? – Nemo Nov 27 '15 at 21:18
  • @Nemo "Actually CC BY-SA 3.0 is a license which looks pretty good for most Stack Exchange Network sites, but on Stack Overflow which is used mainly for coding questions, is pretty much rigid since a lot of answers contains portions of code that usually are intended to be copy-pasted." – Hacktivista Nov 27 '15 at 21:19
  • @Hacktivista yes, and what makes you think that the portions of code which are intended to be copy-pasted are negatively affected by the license? – Nemo Nov 27 '15 at 21:20
  • @Nemo If I help anybody with a code snippet I would love to share it with no restrictions in order to help more people widely. The current ToS doesn't allow me to do that. More here: creativecommons.github.io/labs/2011/05/28/… or opensource.stackexchange.com/questions/887/… – Hacktivista Nov 27 '15 at 21:29
  • @Hacktivista nothing forbids you to use a less restrictive license for your own content, as I said in my answer. Do you have reason to believe the contrary? As for code really meant for indiscriminate copy-paste, I think that's most likely to be unoriginal and hence public domain. – Nemo Nov 27 '15 at 21:41
  • @Nemo As I understood, ToS explicitly forbids me to do that: "You agree that all Subscriber Content that You contribute to the Network is perpetually and irrevocably licensed to Stack Exchange under the Creative Commons Attribution Share Alike license." – Hacktivista Nov 27 '15 at 21:46
  • 1
    @Hacktivista no, that sentence definitely doesn't forbid dual licensing. – Nemo Nov 27 '15 at 21:48
  • @Nemo I think you could be right, "In the event that You post or otherwise use Subscriber Content outside of the Network or Services, with the exception of content entirely created by You, You agree that You will follow the attribution rules of the Creative Commons Attribution Share Alike license as follows" could be interpreted. In any case, commonly people is not thinking on include a license on a code snippet. And as you can see in comments, this is something that affects people who "tries to understand and make his work in an original way". Others simply don't care about. – Hacktivista Nov 27 '15 at 21:58
4

For code posted on Stack Overflow, there are three relevant cases:

  • {1} The posted code isn’t licensed under CC BY-SA 3.0. This could happen if the poster had no right to post/license it, or if the poster quoted it.

  • {2} The posted code is not eligible for copyright protection (e.g., not meeting the threshold of originality, or being in the public domain).

  • {3} The posted code is licensed under CC BY-SA 3.0.

If you want to include the posted code in your code (which you intend to distribute), you are

  • {1} not allowed to do it
  • {2} allowed to do it without restrictions
  • {3} allowed to do it if you follow the terms of CC BY-SA 3.0

Note that {3} does not only mean that you have to attribute accordingly, you also have to license your code under CC BY-SA 3.0 (or under a compatible license in addition, in case you adapted the code).


Category {1} will hopefully be flagged (if the poster had no right) or formatted with quote markup (assuming the specific quote is legally allowed). But it’s your risk.

It’s not always easy to decide if code would fall into category {2} (it’s for judges to decide, should it come to that), but the two lines of CSS are most likely in category {2}, because there is no originality involved, anyone would do it like that. But if you are unsure, better be safe than sorry, and assume {3}.

1

I'm not a lawyer, and I don't actually know what I'm talking about here. So this is not meant as a legal answer, but asa different interpretation of this issue and my personal opinion on how to handle this.

Imagine the answer was simply describing the rgba() function and how it works. You would end up at the same code, but you wouldn't have copied it directly. Nobody could actually tell that you copied the code from the answer as it is simply the obvious method to achieve this goal in CSS.

I don't consider code that simply shows how to use a library or language feature to be an original work. The actual text of an explanation would be an original work. But if the code is simply demonstrating how to use a particular API or language feature, I don't think copying it needs attribution.

I think your example is pretty clear as there is simply no way for you to read the answer, understand the concepts and then arrive at an independent implementation of the concept. You will end up with pretty much the same CSS as it is posted in the answer, there aren't many different ways of implementing this.

  • 3
    The results could be interesting if you spent a day avoiding doing anything in a way that you've seen it done on SO in an answer before. – Marty Nov 26 '15 at 10:44
  • 3
    I don't consider code that simply shows how to use a library or language feature to be an original work Ah, the Google v Oracle API defense. Look how well that turned out eff.org/deeplinks/2015/06/… /sarcarm – cde Nov 27 '15 at 6:55
-2

No. There is no difference in copying one line or an entire code block from an answer. The license the content is licensed on requires you to attribute the copied content to a specific user, linking to his/her profile.

I understand this is quite difficult when it comes to copying only one line of code, but actually there is no difference. Another licence won't really help much.

Personally I don't mind if you copy some or all the code I posted. Usually when I want to copy some code from SO, I try not to copy it, but take the general idea behind it and rewrite the code myself, also based on the documentation I find from official sources.

(Small note: the license doesn't only protect the author, but also Stack Overflow Inc. from site scrapers)

  • Considering the examples I've provided there's no way to not copy the code posted, because are simple instructions, although I could write the instructions instead of copying, it would be a copy anyway. I understand that copyright protects from indiscriminate use, but it's not intended to hindering the work of others. A solution in my opinion would be to maintain the current license for actual answers, and CC0 for code snippets (with free choice to license under another license if necessary). That way SO is protected from scrapers and the programmers can have a proper way to work. – Hacktivista Nov 26 '15 at 7:49
  • I wonder how they would to that. They can't simply change the license on the existing material. Can they? – Patrick Hofman Nov 26 '15 at 8:39
  • I suppose we have nothing to do with older questions (at least a user actively passess all of their code snippets to the new license, which could be a solution for a lot of answers), but can be changed for every future question. – Hacktivista Nov 26 '15 at 21:17
  • @PatrickHofman they can change them, and any use after that change would fall under the new license. And depending on the existing license stipulations, the change can be retroactive, or could grandfather people using the code under the old license. – cde Nov 27 '15 at 7:16

You must log in to answer this question.

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