27

I have reviewed/read this page: https://blog.stackoverflow.com/2009/06/attribution-required/

Which is linked from the bottom of every stackoverflow.com page.

How does it work when I want to use a small piece of code, or a [small] idea contributed by someone to stackoverflow, but only in code?

I.e. not "republishing" the content, but simply using the content as a starting point/idea, and maybe re-using the same classes etc.

Would it be ok to do so without attributing every detail?

Thanks!

0

2 Answers 2

28

All content contributed by users on Stack Overflow is released under the Creative Commons Attribution-ShareAlike 3.0 Unported (CC BY-SA 3.0) license. That page and the Attribution Required blog post cover what you need to do when you're republishing content from a Stack Exchange site somewhere else.

If you're reading code snippets from Stack Overflow and using them to make your software work, then you're using the site as it was meant to be used. (I'm assuming you're not just copy/pasting large chunks of code verbatim. I doubt that would work for 99% of the code on here anyway.) You don't have to disclose this in the user interface or documentation of your product, but it would be a good idea (mostly for your own benefit) to document where that code came from in a source code comment. That way, when you come back to that code for maintenance, you can go back to the original source for any additional information you may need.

17
  • 11
    +1 for but it would be a good idea (mostly for your own benefit) to document where that code came from in a source code comment
    – JimmyPena
    Commented Jul 13, 2012 at 18:08
  • Bill, thank you - that clarifies. So I assume the "Share Alike — If you alter, transform, or build upon this work, you may distribute the resulting work only under the same or similar license to this one." part of the CC BY-SA 3.0 license does not apply to the limited use ("reading code snippets from Stack Overflow and using them to make your software work") we discussed here? Commented Jul 18, 2012 at 3:32
  • 5
    @Roel I don't think so. I think that only applies when you're republishing the code or someone's explanation of some code on a blog, in a book, etc. Using code you find here as a guide to getting your own software to work shouldn't require you to release your software itself under the same license. If it did, most of us would be in violation.
    – Bill the Lizard Mod
    Commented Jul 18, 2012 at 11:06
  • 2
    @Roel, you asked for a company confirmation, so here it is: While it's not legally necessary, to be on the really safe side, I'd encourage you to include some kind of attribution of the source in a source code comment, as Bill suggests. But yes, you may absolutely use code snippets (excerpts) in your code without public attribution, as long as you aren't publishing it somewhere.
    – Jaydles StaffMod
    Commented Jul 31, 2012 at 21:11
  • @Roel, you asked for further clarification that you wouldn't have to release your software under the "share alike" clause. I'd reiterate that it sounds like the type of excerpting you're describing would be fair use of a quote or excerpt, which would not require that, but it's impossible to say for sure, as it's an interpretation of what constitutes legitimate excerpting.
    – Jaydles StaffMod
    Commented Aug 2, 2012 at 20:51
  • Fair use doctrine states that length is not a factor. If you plan on sharing or distributing your code at all, the viral nature of the CC-BY-SA license dictates that the entire work falls under that license. If you want to share your work, but don't want it to fall under that license, you should not use code from SO directly. Ideas and concepts aren't covered under the license, so presumably, if you understand what code does, you can reimplement it yourself. Commented Mar 17, 2013 at 5:21
  • 2
    Bill can you clarify why you don't have to attribute the use of SO code in your app's documentation or UI? If SO had used a proper Open Source license for its code (instead of a documentation license), like MIT or BSD, we would have to include attribution in the source and binary. Using the CC-WIKI license, SO makes using code from this site very undesirable legally -- which seems to be the opposite of the contributors' intent. Why not just use a real open source license and make this site really open for sharing?
    – Gil Yehuda
    Commented Jun 26, 2013 at 18:59
  • @GilYehuda Why do you think it's undesirable legally to use code from Stack Overflow?
    – Bill the Lizard Mod
    Commented Jun 26, 2013 at 19:06
  • 1
    Bill, if I take code verbatim from SO and put it in my mobile application, then distribute the app to my customers, what obligations must I satisfy? If the code was Open Source licensed, it's well understood. Since the code is CC-Wiki licensed its a problem. According to the license, I may have adapted the work (1a) depending on how that is interpreted in the relevant jurisdiction, and distributed it (1d) since it's a mobile app.
    – Gil Yehuda
    Commented Jun 26, 2013 at 20:20
  • 1
    Bill (cont) I now have to take "reasonable steps to clearly label, demarcate or otherwise identify that changes were made to the original Work" (3b), and to do so "in all media and formats" (3) -- which I think means I have to add the attribution the binary's UI and comment any code changes I make, or I'm violating a copyright! I think I'd also be violating 4b if my code is compiled and I don't let you reverse engineer my app.
    – Gil Yehuda
    Commented Jun 26, 2013 at 20:21
  • 2
    Bill (final) According to 4d, I'm restricted from adding a comment saying the code is poorly written. Can I redistribute my app under a commercial licence? Can I put it on the Apple iStore without violating 4a "You may not impose any effective technological measures." I'm not a lawyer, but it sure seems that CC was created for "content" (text, pictures, plays, music) and not for "source code" (that is designed to be compiled and included as a part of a larger work). Seems that people want to share their code so that it could be used in real life apps, not just read as instructive ideas.
    – Gil Yehuda
    Commented Jun 26, 2013 at 20:22
  • @GilYehuda Most answers aren't code that you copy/paste, compile, and run. They have explanatory text. That content is why SO uses the CC-BY-SA license. I don't think it's the case that people are sharing code that they expect to be used verbatim here. They're sharing knowledge.
    – Bill the Lizard Mod
    Commented Jun 26, 2013 at 20:34
  • 2
    I understand that most code here is not runable by intent, but SO's license means that no code is. When I see code that was cut/paste from SO (and I do see such code in production apps since I scan for it), I see that I must remove that code from the source. I think this is a shame, since the author's intent to share is not being supported by SO's license that actually restricts it, even in cases where the author does share runable code. I would gladly credit the author and use the code if s/he used an open source license.
    – Gil Yehuda
    Commented Jun 26, 2013 at 20:53
  • 1
    @BilltheLizard, of course not. But it does impose other restrictions that I do not believe are an accurate representation of the author's intent. Most code authors I know seems to want to share and have you either apply a WTFPL or an MIT-style license (to get credit for their code). Some prefer the LGPL or GPL if they have philosophical leanings against proprietary code. But CC-Wiki is neither, as I explained above. CC is great for content, but code is not content. I wish you'd clarify the licence on the content is CC, but the license on the code is something more suitable for code.
    – Gil Yehuda
    Commented Jun 26, 2013 at 21:00
  • 1
    @GilYehuda I can't clarify that because it's not. This isn't a site for releasing open source projects, it's a site for questions and answers. All content is CC-BY-SA. I think you're reading a lot in to the author's intent that just isn't there. If they want to release their code under some other license they'd post it on a site created for that purpose.
    – Bill the Lizard Mod
    Commented Jun 26, 2013 at 21:54
2

I wish that StackOverflow used a better clearer license for source code contributions, like the MIT license.

Here is my best attempt at how to copy source code from StackOverflow and abide by the CC BY-SA license. If anyone (especially a lawyer) sees a problem with how I'm doing this, I'd appreciate hearing from you.

Put a comment like the following above the copied code:

// The class below was written by StackOverflow user John Leidegren and is licensed
//  under CC BY-SA 3.0 ( http://creativecommons.org/licenses/by-sa/3.0/ ).
// http://stackoverflow.com/a/4634505/386091

Here are the key points that I see from the full text of this license:

  • Section 4(a): include the URL to the license.
  • Section 4(c)(i): give credit to the original author, by name or pseudonym.
  • Section 4(c)(iii): give a URL to the SO source code. (If the source code is in an answer, use the 'share' button on the answer to get a perma-link.)
  • Section 3(b): If you make any changes to the source code, add a comment saying "The original code has been modified."

I think that's it, as far as what you have to do.

I would argue that the copied source code is being added to a Collection in your software project, from the viewpoint of this license. That means that the copied source code is under the CC BY-SA license, but the rest of your source code is unaffected.

I think that copied source code also becomes an Adaptation when compiled to machine code, because the license says in Section 1(a) that translations from one language to another (e.g., English to French) count as an Adaptation. So, the one little bit of the executable would be covered by this license. Section 4(b) says that you have to link to the license as part of every "performance" (meaning when the copied code executes) but that's just not possible with most bits of code; you can't display a message "the code that is executing right now is covered by CC BY-SA" in the nanoseconds it takes most code snippets to run! I don't think you have to describe the copied code in credits, if your software has a list of credits, unless you do it for all code snippets from SO, because Section 4(c) says that you only have to make a listing in the credits if you list all contributing authors.

You must log in to answer this question.

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