19

I've looked through a few of the questions about the licensing of posts on SO, but haven't found any really satisfactory answers. Can an answer be used in an open source project (with an MIT license)? I'm not looking to simply cut and paste, because I would need to modify the snippet to suit my project and also because the answer is in a different programming language. Also, if the answer can be used, how should it be credited? Should it just be a link to the SO page? Should it include the user name? Should the user be contacted?

1

6 Answers 6

12

IANAL, but just be honest how you got the code.

http://creativecommons.org/licenses/by-sa/2.5/

You should be able to use the code in your project provided you supply attribution details and source code. Just make sure the license you are using allows for this.

e.g.

// thanks to RodgerB from StackOverflow
// special thanks to rcar for suggesting I use doubles
// http://stackoverflow.com/questions/169041/how-should-a-so-answer-be-credited-for-use-in-an-open-source-project
private int AddNumbers(double a, double b)
{
    return Convert.ToInt32(a+b);
}
5
  • 1
    You should probably cast a and b to doubles before you make the addition, then round them and cast it back to an integer.
    – Randy
    Commented Oct 3, 2008 at 22:00
  • Would an MIT license be compatible?
    – VirtuosiMedia
    Commented Oct 3, 2008 at 22:03
  • Yep, if you are sharing source code and telling the user reading your source where you got the information from. I am not a lawyer though, this is just my understanding.
    – RodgerB
    Commented Oct 3, 2008 at 22:05
  • 3
    stackoverflow.com/questions/169041#169060
    – Swati
    Commented Oct 3, 2008 at 22:14
  • upmodded, this is an excellent function, would read again
    – Colen
    Commented Oct 3, 2008 at 22:17
6

Most projects will be unable to incorporate expressive content from StackOverflow due to the ShareAlike element. Neither Apache 2.0 (by extension MIT and BSD) or GPL licenses list it as compatible.

Apache: say to contact the Legal committee, I wouldn't expect there to be happiness regarding CC-SA in software. The same type of thinking would hold for MIT and BSD projects.

FSF: don't explicitly list LGPL or AGPL, but I would expect the same to hold.

Mozilla and Eclipse may be happier with CC-SA and I could see it being feasible that a future CC-SA license could resolve the FSF concerns.

Summary: you probably need to ask each SO answer to license the code differently than the default.

3

Linking directly to the answer (or question and multiple relevant answers) should satisfy the attribution provision of the cc-wiki (attribution, share alike) license that has been selected for SO.

3

The full text of the CC by-sa 2.5 license says:

"You may distribute, publicly display, publicly perform, or publicly digitally perform a Derivative Work only under the terms of this License, a later version of this License with the same License Elements as this License, or a Creative Commons iCommons license that contains the same License Elements as this License (e.g. Attribution-ShareAlike 2.5 Japan)."

My personal opinion is that this renders the sa CC licenses viral: there is no such thing as a "compatible" license, because the share-alike requirement is that one of an enumerated set of licenses is used, not just "any license with similar terms". Whether your work is a Derivative Work or not depends on what you've copied - seeing a copyrighted implementation of bubble sort doesn't necessarily mean you can never use bubble sort again. If it's not a Derivative Work then the CC license is irrelevant, so you can distribute your work under any license you want, including MIT.

However, I am not any kind of lawyer, and certainly not your lawyer, so my personal opinion is worth what you're paying for it.

Note that CC Deeds (the thing you see when you follow the link in the corner of the page) each have a really tiny link at the bottom, behind a door marked "beware of the leopard", leading to the actual license.

[Edit: I have just added the following text to my userinfo:

"All my original contributions to StackOverflow are placed into the public domain. If this is not legally possible, then anyone receiving a copy of them by any means is granted a non-exclusive perpetual license to use, distribute and modify them, and to distribute modifications, under any license or none, with or without attribution to me. Please note that this license applies only to my original contributions."]

2
  • Is that text under a license, or may I use it too? =D
    – NickAldwin
    Commented Oct 15, 2009 at 19:08
  • Steve: The Unlicense does exactly what you want, but is more thorough.
    – bukzor
    Commented Mar 10, 2014 at 18:56
0

If the input is important, I would put somewhere (in a credit page/file perhaps): "With help from XyzAtSO given at https://stackoverflow.com/questions/151515/bla-bla" or something along these lines.

Personally, I see my (original!) code snippets here more or less as public domain but giving credit is always nice and appreciated.

1
  • Some Wikipedians employ a legal "hack" for this - you explicitly place your contributions into the public domain, thus offering an alternative to the license offered by Wikipedia. You've just reminded me to do this here - thanks!
    – onebyone
    Commented Oct 3, 2008 at 23:27
0

Well, as all content on Stack Overflow seems to be licensed under the Creative Commons Attribution-Share Alike 2.5 Generic license, I think that a link to the answer should be provided. That should satisfy the "Attribution" part of the license.

The "Share Alike" portion is a bit harder, because it requires the code/product to be licensed under the same or a similar license. I cannot tell whether the MIT license counts as a similar license. However, you might be able to find a compatibility matrix or so …

You must log in to answer this question.

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