Imagine I find a completely new algorithm to compute the square root of a binary number (simplification of real scenario) on an internet forum that was an original creation.

Is it ethical for me to adopt that algorithm into any future projects of mine, or is that plagiarizing? Should I contact the programmer who developed the algorithm and ask for permission? What if I can't get in contact with them? If it is ethical for me to use, what about source code? Should I re-write the algorithm in my traditional programming style, or is that worse than just copy + pasting? What if the source code for the algorithm is so to-the-point that there's no room for me to change anything?

  • 2
    Yes it is completely ethical. But it may be illegal, if the code in question is copyrighted and doesn't have a permissive license, or if the code in question uses a patented algorithm.
    – JacquesB
    Commented Jul 25, 2016 at 21:34
  • on an internet forum Without any notes regarding copyright etc? And what do the conditions of use of that forum say?
    – Jan Doggen
    Commented Jul 26, 2016 at 10:02
  • 1
    Plagiarism is an academic concept. It really doesn't have any bearing on the use of algorithms. The essential concepts are copyright and patent. Commented Jul 26, 2016 at 15:40

3 Answers 3


Though I am not a lawyer...

You are conflating several issues. So, let's try to tease them apart.

There is copyright which applies to any code of sufficient size (more than a few lines?) that is re-used in another context. Here you need to abide by the copyright license of the code, which could range from forbidden to allowed. Open Source generally allows use and often with contingencies that you must propagate the copyright, attribute, and perhaps even also make your work also open source. When you reuse code under copyright, as long as you are compliant with the license, you can reformat the code as you wish. You have to honor copyright or else it is not just unethical but illegal.

If the copyright doesn't suite your needs, you can contact the copyright holders and ask their permission for another license, which they might do for free or for pay. You would have to obtain such permission from all copyright holders for the material, not just the principle holder.

If you are copy/pasting you need to concern yourself with copyright. If you are rewriting an algorithm from scratch, then not so much unless you are simply retyping (remember, IANAL).

There is another category of rights called moral rights, which is different from copyright. Plagiarism, claiming a work done by other(s) to be originally authored by you, is a violation of these moral rights. It is definitely an ethical violation, but may also have legal consequences. While we often assign (license) copyrights, by contrast, moral rights are not easily transferred (if at all). It would be wrong for someone legally holding exclusive copyrights to assume they can claim original authorship (they don't get that from copyright).

Regarding using an algorithm published by someone else, I'd use the golden rule: if either you feel that you are using an algorithm of merit that you would like credit for if you developed it and someone else used it, or you suspect that's how original the author feels, then attribution makes sense. Once attributed, you can modify as you see fit, reformat, etc..

Finally, algorithms may be protected by patent, in various forms. Patented algorithms are usually wrapped up in legal device of calling the algorithm a machine that does something, because on the face of it, algorithms, math, formulas cannot be patented. Ideally, a patented algorithm would documented as such that within code, but it is not a requirement, so this is a problematic issue. You have to decide for yourself whether researching into patent status is merited. Note that patents are a concern even if you develop the algorithm from scratch yourself, because an existing patent you don't know about may already cover that.

Search Wikipedia for Plagiarism, Moral Rights, Copyright...


Yes, it is.

Concepts that people communicate to others in online forums are intended to be adopted by others. There is neither a tradition nor a legal basis for banning others from reusing the same algorithm (copyright protects only specific expressions of ideas, not the ideas themselves, trade secret status does not apply, and algorithms cannot be patented). If it's a very clever and original new method, it's considered polite to acknowledge the inventor in comments to your implementation, but no more.

Algorithms can be patented in the U.S., although the limits are narrow and the trend seems to be towards restricting them further. They cannot be patented e.g. in Europe, but there is strong political pressure to make them so. This makes the situation on the internet unclear, to say the least. The kind of actors who would actually pursue and defend a software patent is probably distinct from the persons chatting about their neat new program online, but you can't be sure.

  • Algorithms can be patented, at least in the US. For example the LZW compression used in the GIF image format.
    – JacquesB
    Commented Jul 25, 2016 at 21:28
  • "The kind of actors who would..." - this is irrelevant. Patented algorithms are public, so anybody could share a patented algorithm online, not just the owner of the patent. And it would still be illegal to copy it.
    – JacquesB
    Commented Jul 26, 2016 at 11:14
  • "[algorithms] cannot be patented in Europe" that's only correct in theory. In practice, algorithms can be patented in Europe, you just need to properly phrase the patent. Commented Jul 26, 2016 at 12:32

First you have to distinguish between what is ethical and what is legal. You actually ask about what is ethical. This is highly subjective!

I believe there is broad consensus that:

  • Ideas shared in public can be freely used by anybody
  • Smaller sections of code shared in public can be freely copied by anybody.
  • Larger sections of code can be copied verbatim if they have a license or disclaimer by the originator which allows you to do so. If not, you are still allowed to steal ideas and small fragments of the code.
  • You should never claim you personally invented some idea or wrote some code which you actually copied from somewhere else. That would be plagiarism. But you don't have to explicitly cite the source unless the source requires you to. (In academics the questions of citing and sourcing is more serious, but I assume this is for mainstream programming, not for academic publishing.)

But what is ethical and what is legal is completely different. For example Microsoft have patented the technology of style sheets, even though they didn't invent it. So this is blatant plagiarism, but nevertheless Microsoft now legally owns this patent.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.