I'm an iOS developer and I've found myself porting code from several other languages recently for various projects and it got me thinking about code licensing.

When porting code, is that considered to be "use" of the existing code, or since I'm not copying and pasting anything, is the code a new entity?

  • 3
    I believe porting is, by definition, a derivative work. Therefore the port should the licensing restrictions regarding derivative works. Now a rewrite in another language/platform...
    – Vitor Py
    Mar 15, 2011 at 19:20

3 Answers 3


There is porting which is to taking someones source code to create something that works on a different system or in a different language.

Then there is reverse engineering which is to make something that behaves like someone else's program, but has nothing of substance from the original work.

Porting means you have their permission. So you need to ask the original creator what your rights are regarding license and how you release it.

Reverse Engineering means you either can't or won't talk to the original creator, and you can do whatever you darn well please. (just keep on the lookout for any lawyers)


Is the algorithm patented? If not, then the only thing left is copyright. Copyright applies to the original source code in the original language. So the question is, how different is the new version?

  • It's in the same language, but calls to system libraries are updated: in this case, I would highly recommend keeping the original license just to stay out of murky waters. It's a derivative work, and subject to the terms specified in the original license for derivative works.
  • It's a clean room implementation in a new language: in this case, it's not the same project. Ideas can be patented, but they can't be copyrighted. It is likely in this case you would also make the API a little more friendly to the way other libraries are designed on the platform.

The more you have to change the library, the more it is a completely new work.

  • 1
    What makes it a "clean room" implementation? If I convert javascript to C, in as close to line-by-line as I can (forgiving the occasional transgression that the JS jitter allows but C does not), is that a "clean room" implementation?
    – jcolebrand
    Mar 15, 2011 at 19:26
  • Why would you want to be so close to the original when the language is so different? Prototype languages like JavaScript have a different character to them. If the average lay-person can look at the two source code files and surmise that they are the same thing, it's more than likely a derivative work. If the code looks completely different, even though it accomplishes the same task, it is a clean room implementation. Mar 15, 2011 at 19:46
  • Because Javascript is often written in a C style, that's why I happened to choose that particular pair. I think if it were Ruby and TSQL it would look wildly different. But with C and JS, if you rely on the loosely coupled nature of JS for comparisons, you might have to set up more elaborate comparisons in C, but for all intents and purposes they would read the same, given a certain initial JS implementation. Does that make more sense?
    – jcolebrand
    Mar 15, 2011 at 20:02
  • @drachenstern, I'm not sure if it's what Berin was referring to specifically, but in general "clean room" is a process whereby the person who writes the new code has never seen the old code, just had specifications described to him by someone else who has. This lets you borrow the ideas of others, which is legal in many cases, without risking accidental copying of implementation, which is not (without a permissive license). Mar 15, 2011 at 20:06
  • Go back and re-read my last comment. I understand that the syntax of C and JS are similar. However, if you were to implement the C algorithm in a way that is befitting JS (or the reverse also applies), they will look very differently. What you are proposing is too close to the first option in the answer. Both JS and C have different mindsets for breaking down problems--by playing to those strengths you avoid the license issues you are wanting to avoid and you get a better API. Mar 15, 2011 at 20:07

This does depend on the original license - for GPL you would need to be very careful in order to avoid their copyleft rule on "derived" software.

See this question on SO for more information - https://stackoverflow.com/questions/3256967/what-are-the-copyright-licensing-issues-of-porting-code

For LGPL, the situation seems to be similar - see https://stackoverflow.com/questions/481216/porting-lgpl-code-what-license-can-i-use

  • What about LGPL?
    – Moshe
    Mar 15, 2011 at 19:20
  • it's worth looking on SO - I've just linked another question for you
    – Stuart
    Mar 15, 2011 at 19:24

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.