Specifically in the following scenarios where you’re working on an open source library using an incompatible license like the MIT license.
- You copy & paste a method from a GPL library – blatantly a violation assuming the GPL library created the method themselves.
- You create a function with a similar purpose but you create it from scratch – presumably not a violation
- You use the same code as a GPL library, but you improve on it (optimize performance for example) – is this a violation?
- You use the same code as a GPL library, but you superficially refactor it (e.g. rename variables for clarity, add comments, but don’t really change the underlying logic) – is this a violation?
- You translate code from a GPL library to another language but keep the logic exactly the same – presumably not a violation?
I know these are possibly questions for lawyers but I’m hoping to get a rough idea.
0
(…) using an incompatible license like the MIT license.
In general, I like to work with this baseline:
- GPL + MIT => GPL
- MIT + GPL => GPL
- (anything else) + GPL => GPL
- GPL + (anything else) => GPL
In other words, if you mix GPL with anything else, you get GPL’ed code. There are some exceptions, but not at the level of actually mixing code. Note that you can do as you please as long as you keep the code to yourself — only when you distribute your code you must adhere to the rules of the GPL.
You copy & paste a method from a GPL library – blatantly a violation assuming the GPL library created the method themselves.
Not a violation as long as you release your code under the GPL and quote the original author. This is called a derivative work (one that has all parts but one removed).
You create a function with a similar purpose but you create it from scratch –
presumably not a violation
If you see a GPLed program and think to yourself, “gee, that would be useful if it were not GPLed” and the go and write your own program without copying any code and other protected parts, probably not a direct violation. Very much depends on the jurisdiction.
You use the same code as a GPL library, but you improve on it (optimize performance for example) – is this a violation?
As long as you put your code under the GPL that’s one of the core ideas of GPL – allow you to improve on the previous work, freely, as you see fit. As long as you stick to the rules, of course.
You use the same code as a GPL library, but you superficially refactor it (e.g. rename variables for clarity, add comments, but don’t really change the underlying logic) – is this a violation?
Again, as long as you keep the result GPL’ed and quoting the original author, that’s probably fine.
You translate code from a GPL library to another language but keep the logic exactly the same – presumably not a violation?
It’s still copying, right? If your intention is to take a GPL’d program in language A and transform it to language B just to get rid of the GPL, think again. That is at least plagiarism, if not worse, in most jurisdictions.
Disclaimer: IANAL
6
You violate the GPL when you do two things.
- Create a “derivative work” from GPL’d code.
- Fail to follow the requirements of the GPL for creating such works.
You can in fact do ALL of what you noted, so long as you follow the GPL’s rules. That’s the point of copyleft. You can copy and paste all or part of a GPL’d program into your own, modify it to suit your purposes better, or completely re-write it, and so long as you do what the GPL requires you’re 100% in the clear.
If you don’t want to follow the GPL’s requirements, what you can do becomes far more restrictive. In fact, it becomes exactly as restrictive as what you could do if someone emailed you the source code to some closed-source program, like Microsoft Windows 10.
3