views:

1342

answers:

12

A couple of questions I've read today discuss the legal implications of using someones code in your project:

This has left me wondering where example code found online fits into things.


Scenario:

  • A developer is working on a project and encounters a problem.
  • They ask a question on the internet somewhere (ie stackoverflow.com)
  • Someone answers their question and provides a nice code snippet that just about does what they want.


Where does one legally stand if the developer includes the code verbatim in their project's code?

I know I've done this before...and I'm sure others have too...but I'd really like to know what the legal or ethical answer is to this question.

  • Should one use the example code and move on?
  • Should one use the example code and provide a comment referencing its origin?
  • Should one inform the provider of the example code that they've used their code?
  • Should one not use the example code at all and use the basic idea to create your own code?
  • Is it ok to use said example code in proprietary closed-source projects?
  • Is it ok to use said example code in proprietary but internal-use-only projects?
  • Are the legal implications currently undefined?
+1  A: 

The best answer for many of these scenarios is for you to ask your employer -- or if you're working for yourself, consult a lawyer.

Curt Hagenlocher
+8  A: 

It's much wiser to get inspired by the code and write your own. It's code that's protected by the copyright, not what the code does.

sharptooth
+1 "Inspired by" does that mean reading it from one window and typing it in another :-)
Dead account
Nope, that's copying. Many people call this re-typing, but it's really copying and in many cases copying is copyright violation.
sharptooth
+5  A: 

Personally, I think that if you post your own code on a public site like this you have implicitly posted it into the public domain - at least that's what I expect with my own code when I post answers.

So the answer to you question is that it depends on whether there's an reasonable expectation of release into the public domain. A public web site, like this, with code posted as-is likely falls clearly within that parameter.

However, if the code is posted with a copyright statement or license reference, then you should think twice, and probably assimilate, understand and rewrite, not copy.

And, of course, IANAL.


Thinking about some of the comments, I find it difficult to reconcile the idea that: I could see a question on SO asking, "How do I do such and such?" And I respond, "Here's some code - that's how I think you should do it". To then suggest that the questioner is somehow not permitted to use the code I provided, verbatim, just seems somewhat ludicrous.

It just seems to me that under any reasonable interpretation of "fair use", I have pretty clearly given the questioner carte blanche to use my code in anyway they want, and if not that liberally, then certainly, at least, to resolve the problem about which they posted.

Software Monkey
If I cut and paste some code from a gpl:ed program as answers to a question, the gpl do not disappear! If I cut and paste secrete code from microsoft... But on the other hand who is going to prove it?
Johan
The site you post must have terms of use like "whatever you post becomes public domain" and you must have right to post that into public domain. Otherwise it doesn't become public domain.
sharptooth
No, you have to explicitly release it into the public domain (regardless of the site unless you signed a contract when joining). And some countries don't even recognize the concept of PD.
paxdiablo
Copyright does not require an explicit statement. This used to be true, but not anymore. See http://www.keytlaw.com/Copyrights/top10myths.htm
Bill Karwin
Yeap, the other way to say it is "you hold copyright by default". You have to explicitly deny your copyright if you wish. See http://www.sqlite.org/copyright.html, section "Contributed Code" for an expample of how that can be done.
sharptooth
Wrong. It depends upon the site's user agreement as to the licence under which content will be posted. On this site, it's CC-BY-SA, which is not at all like "public domain". Works in the public domain have no copyright at all, whereas CC-BY-SA is a licence (i.e. you continue to hold the copyright).
Rob
+3  A: 

If you understand the example code and rewrite it a little then you have in some sense circumvented the original copyright, and things like gpl do not matter any more.

But if you just cut and paste, you can get in all kinds of problems :-)

Take the example of a musician, he can borrow a little from his friends without any problems with the copyright law, but if he borrows too much then he is in trouble...

/Johan

Johan
+3  A: 
  • Should one use the example code and move on?
    Depends, for the most part no. If the example fits you or your company's coding standards, addresses the issue and you can live with it, sure.

  • Should one use the example code and provide a comment referencing its origin?
    If I do use some code copy/pasted or heavily similar to an example code I would comment the link/site where it was obtained. If not for legal reasons, at least for reference when someone takes a look at this code and wonders where the hell it came from.

  • Should one inform the provider of the example code that they've used their code?
    I believe that example code is provided as-is with no strings attached. I know when I post some code, it usually is a quick and dirty mash out of my proposed solution. I provide it with no strings attached.

  • Should one not use the example code at all and use the basic idea to create your own code?
    I would recommend this if it fits. alert("<>") is kind of hard to mold in your own fashion.

  • Is it ok to use said example code in proprietary closed-source projects?
    Speculation here but I am assuming code posted is of no ownership

  • Is it ok to use said example code in proprietary but internal-use-only projects?
    Speculation round 2, If its documented or generic enough to not be specific to a posted soltuion I'd say sure.

  • Are the legal implications currently undefined?
    Speculation round 3, I believe a majority of issues are handled depending on declared license. With that said there are always instances which don't fit a mold.

Pat
+2  A: 

Correct me if i'm wrong, but isn't it precisely the goal of this and similar site to provide help in programming? So if someone posts some code here, the purpose is that people use it. True, you can be inspired by it and write look-alikes, but if one ask for the simplest way to do something and gets 5 slightly different responses, would (s)he be forced to come up with another - not so simple - way of solving the problem? That can hardly be the case.

tehvan
The intension behind the site is one thing, the copyright law is the other one. Just don't confuse them or you can find yourself in front of the judge.
sharptooth
@sharptooth: Excellent point! +1 (as if I could vote up a comment)!
Bill Karwin
+26  A: 

Note: never make business decisions based on legal advice you read on the internet -- including mine! Confirm this with a qualified legal professional.

StackOverflow seems to offer its content under the Creative Commons Attribution-Share Alike 2.5 license. See the logo and link at the bottom of the page.

This means you are free to copy, distribute, and transmit any content you see here, or to remix or adapt the content.

However, you must attribute the work in the manner specified by the author (though I can't find where this is specified on StackOverflow), and if you alter or build upon the content, you may distribute it only under a compatible license. So it's similar to LGPL, in that respect.

I would recommend that you do not copy code or other content from StackOverflow verbatim, if you need to use it in a commercial project.

  • Should one use the example code and move on?

    No. You need to be aware of the license and comply with it, or in theory you could get your project into trouble. Realistically, this is very unlikely. But it is still possible to cause problems.

  • Should one use the example code and provide a comment referencing its origin?

    Yes, attribution is required by the Creative Commons license used by StackOverflow.

  • Should one inform the provider of the example code that they've used their code?

    You are not obligated to do so, so it would be a courtesy and that's up to you.

  • Should one not use the example code at all and use the basic idea to create your own code?

    Yes, this would be a conservative and safe policy. Plus, it's always better to understand how the code works, which you would have to in order to write code with similar functionality.

  • Is it ok to use said example code in proprietary closed-source projects?

    No. The license would require you to make your project available under the same Creative Commons Share Alike (or compatible) license.

  • Is it ok to use said example code in proprietary but internal-use-only projects?

    Technically, yes, because like GPL & LGPL, the licensing requirement only activates when you distribute a derived work. But how can you be sure that code from the internal-use-only project will never be duplicated into a product that gets distributed? Do you plan to annotate code fragments within your internal projects? I would not recommend relying on this.

  • Are the legal implications currently undefined?

    No, they are spelled out in the Creative Commons license mentioned above.

Bill Karwin
I have been recently trying to post links to github with longer samples, so my code is shared under the terms I want it shared
Sam Saffron
@sambo99: Good idea! I'm okay with the code I post being shared under the CC license. Besides, I haven't given up my ownership of the code, I've simply allowed it to be used by SO (and therefore by SO users). I could still use my own code for my own purposes, even closed-source.
Bill Karwin
Are user contributions (posts) covered under creative commons?
Kyle Trauberman
@ktrauberman: I would assume that by posting to StackOverflow, we have granted SO license to use our contributions, under the Creative Commons license. I can't find an EULA to that effect, though.
Bill Karwin
I may disagree with you here, but a lawyer would definitely have a better idea. I know that SO licenses its content under CC-BY-SA, which means that anyone can use any content here by complying with the license. However...
Sparr
IMHO, the person providing an answer to a question is implicitly giving the asker, at least, a no-strings-attached license for reuse. The forum seems moot, the same would apply if I asked you a programming question over the water cooler and you gave me a snippet on a post-it note.
Sparr
@Sparr, I neither agree nor disagree. The point is that StackOverflow lacks any kind of EULA, so we actually don't know under what terms we contribute our questions, answers, and comments.
Bill Karwin
I don't understand. The bounty period is over and this answer hasn't been automatically accepted as the answer. I'll raise this on uservoice and once it has been investigated I'll mark it as accepted. I don't want to accept and it not give the 100pt bounty.
mezoid
@mezoid: Thanks for that, I noticed it too and wondered. The FAQ says the top answer gets 1/2 the bounty if none are accepted by the end of the bounty period. But my answer shows only 220 rep (as for the 22 upvotes). Maybe the bounty system doesn't update rep immediately?
Bill Karwin
I didn't realize that if I didn't accept the answer you'd only get half the bounty. It had 9 hours to go when I went to sleep last night and I was expecting to accept the answer this morning before the bounty period ran out. I'll try to get this sorted out...and to get you awarded the full bounty.
mezoid
The uservoice issue is listed here: http://stackoverflow.uservoice.com/pages/general/suggestions/133672-bounty-not-auto-accepting-answers
mezoid
@mezoid: Wow, thanks, but no worries either way. I'm glad mine was a helpful answer. Rep points are fun, but to me SO is more about sharing knowledge than it is about points.
Bill Karwin
@mezoid: Okay, it seems I got 1/2 the bounty points once the answer was marked as accepted. Cheers!
Bill Karwin
+2  A: 

I guess not using the code verbatim but using the idea to create your own is usually the best idea - and not just because of copyright issues (my guess there would be that just using it would be perfectly OK).

If you write your own code, you have a much better chance of really understanding what happens; the code will fit the coding standards of the project better, and generally feel more like its a natural part of the code around it. Also, by writing it yourself, you will remember it better, and have a better chance of using that idea again when it next becomes useful.

Jan de Vos
+7  A: 

In US law, there are three mitigating factors to code "re-use" as I like to put it - the method often used to detect infringement is abstraction, filtration and comparison.

  • Abstraction is the dissection of the allegedly infringing work into various elements.
  • Filtration is the removal of those elements not subject to copyright protection.
  • Comparison is checking what remains for infringement.

The second stage is the key. Things that are NOT protected are, at a minimum:

  • ideas.
  • elements dictated by efficiency concerns.
  • elements dictated by compatibility concerns.
  • elements dictated by industry standards.
  • elements in the public domain.
  • elements licensed to the alleged copyright violator.
  • scenes a faire (no other way to do it).

That's quite a laundry list of filters. A lot of them would include quite a bit of the code you see on SO (best sort algorithm, how do I read Outlook PST files, and such forth).

However, those protections only come into play once you're already before the courts so you're already wasting bucketloads of money by then.

In addition, large companies have (or should have, I know IBM does) a policy where their developers have to create certificates stating that their code was original.

Your best bet is to get ideas from SO (or anywhere on the web) and implement those. Copyright covers the expression of an idea but not the idea itself).

Disclaimer: I am not a lawyer (although I've had enough dealing with them to get a small bit of knowledge, just enough to be dangerous to myself). Even if I was, I'm not your lawyer, or even licensed to practice in your jurisdiction.

paxdiablo
+1  A: 

Programming questions are generally syntax or process.

Reading one version of the steps or syntax and writing it in your own words is pretty common.

This boils down to the question, is there truly an original thought, problem, idea, solution in this world? I am in the camp that believes most problems have already been solved in bits, pieces, chunks, or wholes. It's only our awareness that such solutions are out there.

In school, didn't we piece together and extended a textbook's examples with with our own additions?

Based on the above, I don't see the need to copy and paste code -- it's usually easier to write it up yourself anyways.

Interesting question!

Jas Panesar
+2  A: 
  1. Use the code privately, in a spike.
  2. Once you get it working, rewrite the code properly in your codebase.
  3. Profit!

ianal

Matt Hinze
A: 

I think it works more or less like quotes and cliches. If you see a cliche in someone else's work, it's small enough that you can use it in your own. If it's a larger quote, you probably want to give attribution or find your own wording. If it's a full work, then you have to obtain the rights to redistribute it.

Two programmers can easily find the same sequence of instructions that work, but as that gets larger it gets more likely that one programmer is drafting off the other ....

Paul.

Paul W Homer