104

I translated a GPLv2 C program to Python, but found it was hard to extend as designed and rewrote significant portions of it. The program is now structurally completely different, but there are several verbatim translated functions in use.

The Ship of Theseus Paradox (as stated from Wikipedia) "raises the question of whether an object which has had all its components replaced remains fundamentally the same object."

If I did manage to write replacements for the verbatim functions, would I be able to relicense to a license I prefer?

Related, would I be able to pull the evolved architecture out and reuse it with a different license? I think it would be very useful on its own, but do not like the idea that it is now "tainted" with the GPL license.

Followup: I decided to contact the copyright holder and received permission to relicense. Sometimes the best way is to interact socially rather than programmatically!

15
  • 6
    Compare the ReactOS audit: there was the allegation that ReactOS (a Free Windows replacement) was tainted by using leaked and reverse engineered MS Windows code (for which they never took a license). They solved it by systematically replacing all code of unclear origin with legal "clean-room reverse engineered" code - basically new code written from a clean spec.
    – jdm
    Oct 19, 2014 at 11:24
  • 3
    @jdm Chinese Wall/clean room code must also be written by people who were not involved in the reverse engineering and have limited (legally reviewed) communication with them. WRT to ignoring the license and just "violating copyright instead" -- it would amount to the same thing, since you would still not be entitled to redistribute material on which you have violated copyright.
    – goldilocks
    Oct 19, 2014 at 13:33
  • 9
    @jdm The GPL is not a contract and does not need to be accepted by anyone. The GPL is a license and you must abide by it if you take advantage of the license. It is not a two way street or a negotiation or setting of multual obligations the way a contract is. What it does is state the only rules under which you are allowed to use the code. IANAL but I have had this explained to me by several licensing lawyers.
    – Elin
    Oct 19, 2014 at 21:34
  • 3
    @CrazyCasta: You're mistaken about the scope of the GPL. You state it's the only reason to have any rights. This is explicitly incorrect and outright denied by the GPL itself. GPL covers only distribution rights. You have an unlimited right to use and study the code even without accepting the GPL.
    – MSalters
    Oct 20, 2014 at 7:07
  • 2
    @Elin: Right, you must abide by the GPL if you want to take advantage of the license. What I was saying is that you could in principle say "I never accepted your license" and fall back to the unlicensed state with no rights, but no GPL obligations. So instead of violating the GPL, you would be violating copyright (which might not be better). Whether that's possible depends on your jurisdiction. I know that in many parts of Europe, licenses are not automatic. You can't make someone accept a license (that's why EULAs are possibly unenforceable here).
    – jdm
    Oct 20, 2014 at 9:23

7 Answers 7

98

First, the answer is no (for a translation), you cannot legally relicense it or do anything outside of the original license legalities. You may very well have done 10 times the work of the original author, but it doesn't matter, it is viral. Not just because it is GPL, but because it isn't clean design or rewrite.

I struggled briefly with this in 1992 when I had done massive rewrite of an old MUD codebase. We had a successful game, but wanted to do our own thing, and people were willing to pay for it, yet the DikuMUD license strictly forbid us to make money. A competitor, at the time, also had based theirs on the same codebase, and they opted to blatantly ignore the copyright, rip out all traces of it, and basically lie to everyone including themselves. Their logic was "none of the original code exists" and "we have done massive rewrites and improvement" and generally ignoring the fact that they started with 20,000 lines of code. They were charging for items in the game, and making too much money to stop.

I was admittedly envious. But I researched copyright law, and consulted my conscience, and decided I could not even use the code I had written because I honestly did not architect the game server from scratch.

So I decided to put my money where my mouth was and write from scratch, with a copy of W. Richard Steven's UNIX Network Programming with me at all times, I started. Writing from scratch, my way, taught me so much more than when I had rewritten DikuMUD, and it also taught me that I didn't really understand what it meant to stand on someone else's shoulders. Within six months I had 50,000 lines of operational code that I could call mine. I named it MUD++ and released it under BSD. Badly written in early style C++, it was still the first free, open source C++ MUD that I am aware of. To this day nobody can take it away from me. I had the best TCP server at the time, nobody else could do a "hot reboot" without dropping players, and soon everyone was stealing the feature (and I've noted many GPL MUDs have snippets of my BSD code -- always interesting how GPL can hijack BSD-ware but not vice-versa). Eventually, I moved on, so it wasn't like the decision was a make or break for my fortune, but while the other guys made a lot of money for a while, last I looked they had dwindled, in a world of graphical games there isn't much mass demand for text anymore.

The story doesn't end... a few years later, I was working for IBM and Disney hired us to write a realtime 3D multiplayer game for Epcot center, and I was able to use the TCP core from MUD++ as a base for that game server! Had I not owned my own code, I wouldn't have been allowed to use it, and it honestly saved me weeks of coding time. In the end, I am proud of the choices I made and I have a story to tell my kids.

People understate and underestimate the benefit of starting with someone else's framework to build on.

If you think you "own" it, test yourself. Start over, with a Python book beside you. See how it feels. Don't cheat and don't look at the old codebase. Look at the output. Force yourself to think through every aspect on your own, doing the honest research. You'll be better for it, and likely have a better product.

Before you do that, though, try to contact the original author. Ask them if they would be willing to relicense. If you plan to sell binaries, offer royalties. Many authors who released things GPL in the 90s and 2000s, are now in their 30s, 40s and 50s and understand what it means to make a living at software. I've seen more than one relicense their stuff from GPL to MIT, Apache, Boost or BSD.

Lastly, a license doesn't override prior rights to code you may have. Or if you wrote a clean add-on independently, for example, if you wrote a TCP engine as an add-on to a single player Tetris game, and it can cleanly stand alone (especially if you previously released under another license) then you can reuse your code in other projects. You have authorship rights too.

My belief is free is FREE. If you gotta attach strings, don't call it free. Someone mailed me years later and said that they had used my game in a commercial engine, mainly the TCP and possibly the bytecode interpreter. They were making money. I didn't mind one bit. I was happy as I still am now, as a proud father.

38
  • 4
    Actually I was going to suggest that and I got lost in my story. Yes, by all means, consult the original author, pay him homage, so to speak, and you will probably be surprised at how often the author is just happy you took the trouble to ask. And many young college guys that were big on GPL in the 90s and 2000s are now realizing that programmers have to make a living.
    – codenheim
    Oct 19, 2014 at 1:17
  • 18
    I like this answer, and would like to upvote, but I can't, because of all the anti-GPL spin in the last paragraph. The string the GPL attaches is that strings may not be attached in the future. Oct 19, 2014 at 2:52
  • 9
    Good answer, and esp. for recommending working out a deal with the original author. Self-sufficiency is often a road to poverty, and while rewriting a whole library/platform/app can be a worthwhile endeavour, it isn't always so.
    – Dan1701
    Oct 19, 2014 at 3:48
  • 16
    @MichaelShaw: Actually I thought that was the most brilliant part of this answer. Your claim on the other side is factually wrong. If the author of the GPLd code decides to release new versions of his code under a different licence, they are well in their rights. They attach the strings not to themselves, but only to those who they "share" their code with. The nicest way I can describe this is as a fundamental lack of faith in humanity.
    – back2dos
    Oct 19, 2014 at 10:06
  • 11
    The way I see it is that BSD-style licenses make this code, right here, free, which is simple. GPL-style licenses aim to set up a free software community/ecosystem/whatever in competition with closed and otherwise un-free software. In order to do that they make a number of strategic moves, and the length, and variety of GPL and GPL-like licenses (and their development over time) shows that this is a complex business involving many value judgments. If those who prefer one perceive the other to be non-free, or those advocating the other to be spinning against them, both lose. Oct 19, 2014 at 13:02
32

This scenario is covered in the GPL FAQ:

What does the GPL say about translating some code to a different programming language?

Under copyright law, translation of a work is considered a kind of modification. Therefore, what the GPL says about modified versions applies also to translated versions.

4
  • This particular part is clear, but it gets fuzzy when I expand to the rest of the program (at least, in my mind.) The original program was a small curses game, but my work on it beyond translating includes adding networking so players can compete head to head as well as rearchitecting it to be more modular/extensible. In essence, the game engine shares little similarity to the original, but the game itself derives heavily. This goes back to my related question, is the engine now GPL or would I be able to pull it out and reuse it for an MIT or BSD license project.
    – Landon
    Oct 19, 2014 at 7:12
  • 7
    @Landon Your work is still a derivate from a GPL work, and so it's bound to the terms of the GPL.
    – Philipp
    Oct 19, 2014 at 7:16
  • 1
    @Landon: what determines whether the GPL applies isn't really anything to do with the GPL, it's whether your final result is a "derivative work" or not. Adding more stuff doesn't turn a derivative work into a non-derivative work because in law it's not about the proportion of the work that's derivative, it's the raw amount. A routine conversion to another language is also derivative, and that's what the FAQ is informing/reminding you of. The question you have to ask your lawyer is, "given my procedures, would a court find this to be a derivative work?". Oct 20, 2014 at 12:09
  • ... however, this answer focusses on the "verbatim translated functions" which presumably are derivative, but which you say you're planning to remove. As such, I don't think it really covers your intended scenario. It covers your current one, and it covers the scenario you'd be in if you make a mistake and don't manage to excise everything you need to. Oct 20, 2014 at 12:19
8

It is doubtful, even if you rewrote the entire library from scratch, that it would pass legal scrutiny. The code would be considered "tainted" because you have seen the code in the GPL licensed library.

The standard approach to this problem is called "clean room implementation". You write a requirements document and have someone else implement it (who hasn't seen the GPL code).

Also see this question: Rewriting GPL code to change license

As someone aptly put it there, a Chinese translation of Harry Potter is still a derivative work, even though all the information has been replaced.

Of course, the probability of you getting sued over rewriting a GPL licensed library (and the morality of relying on that low probability) are entirely different discussions.

As far as adding functionality to the original code, this is (part of) the very definition of derivative works: adding to the original work. It doesn't matter how much you added, or how small the initial work was - it's still derivative.

5
  • 3
    I'm not sure I like the choice of the analogy: the original question sounds more like they think they were originally bundling their stuff with Harry Potter, but now want to bundle it with their own fantasy epic novel with magic and villains that takes place primarily in a school in a castle.
    – user122173
    Oct 19, 2014 at 10:09
  • 1
    @Hurkyl So 50 Shades of Gray? Oct 19, 2014 at 16:57
  • 9
    Having seen the code doesn't mean you copied it. A cleanroom implementation is useful if you expect that the owner of the original code doesn't like what you do and will sue you, so you can say in court "we didn't copy the code; even if we had wanted to, we couldn't" which is a strong defence. Having seen the code you can still say "we didn't copy the code" as long as it is the truth.
    – gnasher729
    Oct 20, 2014 at 10:03
  • 2
    Agree with @gnasher729. GPL specifically states that you are allowed to study the code. The premise is that the author released it to teach you (among other things). For this reason, I've never applied the clean room argument to GPL code. One can't publish a cookbook and then sue people who create their own recipes, unless, of course, the code is patented, then patent protection covers the techniques and inventions, but not the implementation (AFAIK). Copyright and Patent are different issues.
    – codenheim
    Oct 20, 2014 at 17:04
  • 1
    I would say there is a very low probability of ending up in a courtroom if you violate GPL because with just one or two exceptions every time there has been an issue, one the lawyers of the people violating the GPL understand the GPL they tell them to either stop or make a deal. This was certainly my experience any time I've had to write a letter about a violation. And there are pro bono lawyers who will defend the GPL for the original developer. Really, the best advice is to talk to the original coder. I've asked people to dual/relicense code and they have almost always said okay.
    – Elin
    Oct 20, 2014 at 23:25
7

Observation: The GPL is only relevant if you release your work. Have you released it yet?

Observation: This is not a legal-counsel website, so throw out all that legal FUD, and apply common sense.

Opinion: The GPL, or any license, does not copyright ideas, it claims the sourcecode, not matter how small its part. So, if, and only if your "derivative" work cannot be identified as being derived from the original, because you changed the structure of the code and reimplemented all functionality, it is for all practical purposes no longer derivative, because, well it would be indistiguishable from a clean room implementation.

This is very hard (impossible?) to acheive though when you have an existing codebase you modify, instead of starting from scratch.

3
  • 10
    "Observation: This is not a legal-counsel website, so throw out all that legal FUD, and apply common sense." Er, since this is clearly a legal question, the solution is not to pretend the legal issues don't exist but to ask a lawyer. My understanding is that a derivative work cannot stop being a derivative work just because you do more deriving. Oct 20, 2014 at 12:08
  • 1
    @DavidRicherby : If it is a legal question then the answer is specific to the jurisdiction and the q should be closed as too localized. :-)
    – Martin Ba
    Oct 20, 2014 at 12:24
  • 2
    @MartinBa - international law is pretty much in agreement about copyright. Local variations exist, but I don't think the question/answers are necessarily too localised to be useful.
    – cloudfeet
    Oct 20, 2014 at 16:00
5

You own the copyright for any code you write. What the GPL mandates is: any code you contribute or release alongside GPL code, you must also release under a similar license. However, the copyright is still yours.

So, if you release your software part-way through the re-write (so there's a mixture of your code and old code), then you have to release that part of your code as GPL, and this cannot be revoked. However, the copyright holder is the one who decides on licensing terms, so you still have the right to essentially "dual-license" that part of the code, including combining it with other code you alone wrote and selling/relicensing, etc.

Caveats:

  • although the copyright on code you write is yours by default, it can be changed by another contract/agreement, e.g. a CLA that specifies copyright transfer, or a contract with an employer who owns all the work you do on "their time".
  • whether your re-write constitutes enough of a "derivative work" that you end up sharing the copyright with the original author is a matter of degree. If you translate the code line-by-line into another language (as your question mentioned), then those parts might well count as derivative. If you implement an API-compatible replacement without looking at the details, then that probably wouldn't.

(source: a "copyright and open-source" session organised by my company a few weeks ago)

3
  • You may want to replace "document" with either "contract" or "agreement." It's not enough to just write on a paper "DougM owns cloudfeet's code". We'd have to have a legal exchange that would pass court review.
    – DougM
    Oct 20, 2014 at 13:46
  • Depends on the jurisdiction - at least where I am, even verbal contracts are binding, merely hard to prove. A post-it with appropriate handwriting on would hold up pretty well in theory. :p
    – cloudfeet
    Oct 20, 2014 at 14:24
  • However, your point is good, and contract/agreement is a better description - thanks :)
    – cloudfeet
    Oct 20, 2014 at 14:25
3

Yes.

The other answers use far too much text explaining opinions on whether you should or not, but those opinions are not that relevant to the question.

The fact is that you will have a new work once you replaced the last parts, which admittedly was constructed by looking at a GPL'ed work. That's not a major concern in copyright law (patents would be another issue). Everything you distribute will be your creation.

There is plenty of material backing the theory that the copyright in a software program is the sum of partial copyrights. For instance, the MPL explicitly acknowledges this model. The Google/Oracle lawsuit got down to line-level copyrights.

8
  • 4
    A work constructed "by looking" at another work is a derivative work, and would be stained by the same copyright as the work you "looked at."
    – DougM
    Oct 20, 2014 at 13:44
  • 1
    @DougM: Sorry, but that's a very conservative assumption which I've never seen used successfully in court. Don't forget, if that theory had any legal relevance, it would also apply to books - computer code doesn't have special laws to determine what is a derivative work. Nobody is going to argue that your book is a derivative of Shakespeare merely because you read one of his plays in school. Thus that precedent establishes that the bar of "derivative work" is a lot higher than "have read a similar work".
    – MSalters
    Oct 20, 2014 at 15:25
  • 1
    GPL specifically states that you are allowed to study the code. This isn't proprietary IP, it is free, open source. I've seen no legal support, in the lifetime of GPL, for the claim that looking at a published recipe to make my own recipe implies a derivative.
    – codenheim
    Oct 20, 2014 at 17:08
  • 1
    One might wonder how far Linux could have gone if replacing Unix code with original code wasn't sufficient. Oct 20, 2014 at 20:15
  • 3
    @user2338816 Linux did not start with Unix code, it started with MINIX. And technically, it is possible that MINIX could have had a case against Linux. This would depend on how Linux rewrote their code and the license under which the MINIX code was shared with Universities. However, it also comes down to politics and money, does MINIX really want to go after Linux, and does Linux have the money (through corporations like Red Hat) to fight them off.
    – CrazyCasta
    Oct 21, 2014 at 0:48
1

The short answer is that you cannot know.

When you talk with Richard, you find he is "crazy like a fox" in many of his implementations. The GPL is written specifically to have ambiguities and unclear phrasings. These are generally expressed against the benefit of the license writer but also give your IP lawyer concerns. Cleverly, it gives your IP lawyer increasing concerns as the company gets bigger. A small commercial enterprise doing the "reasonable interpretation" of the GPL might be an acceptable risk, but a large software company might find it more prudent to burn an entire team that managed to get a taint of GPL.

There is no answer. There will not be an answer. That is the answer.

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