I'm working on a JavaScript port of a red-black tree implementation in Java from the book Algorithms 4th Edition, by Sedgewick and Wayne. I believe that my JavaScript port qualifies as a derivative work. It's not nearly a line-for-line copy, but the core logic for RBT manipulation is quite similar.

On the book site, it states that the libraries stdlib.jar and algs4.jar are licensed under GPLv3. The red-black tree implementation in Java is part of the algs4.jar library. Ideally I'd like to release the port under a more permissive license, but that doesn't appear to be possible, for understandable reasons.

However I'm unclear about how users of my port will be bound by the license. Does any software making use of my JavaScript red-black tree port, regardless of the overall size of the project, need to make the entire project's source available under the same terms, or just the source for the JavaScript port itself?

In other words, would the authors of some larger project be bound to release their entire project under GPLv3 just because it uses a port of an algorithm implementation released under those terms in some part of the project?

2 Answers 2


Your code needs to be released under the GPLv3 as you believe it is a derivative work of the algs4.jar implementation.

Other projects utilizing your code will likely need to be released as GPLv3. Most larger applications just incorporate code from smaller projects, and treat the smaller code base as part of the larger. That will trigger the "viral" aspect of GPLv3.

If you provide a way to access your code in one of the accepted "escape mechanisms" then the larger project will not be affected by the viral aspect of GPLv3. This section of the GPL FAQ explains some of the ways that GPL code can be used in proprietary code without triggering the viral aspect of the GPLv3.

However, in many cases you can distribute the GPL-covered software alongside your proprietary system. To do this validly, you must make sure that the free and non-free programs communicate at arms length, that they are not combined in a way that would make them effectively a single program.

You may also be able to license your project as LGPL, which can make it easier for other projects to link to your project without being impacted by the GPL/LGPL license.

  • 1
    So he should make the determination based on his belief that it is a derived work? Commented Dec 11, 2014 at 20:33
  • @RobertHarvey: If the OP felt that their program was not a derivative work, then they could argue that it's not required to be released under the GPL. That circumstance would render this question moot. But given that the OP believes their work qualifies as a derivative work, then using the GPL is appropriate for their code. As far as their belief being the determining factor, that's a two part answer. In this case, OP isn't arguing against it being derivative. So yes, the determination is made by the OP's belief. If they weren't certain, they should likely consult an attorney.
    – user53019
    Commented Dec 11, 2014 at 20:40
  • Yeah, I noticed that too. If it's a derivative work, the answer seems self-evident to me; they're bound by the terms of the GPL. I think what your answer may be missing is that, to avoid the GPL, his program's ability to function cannot be dependent on the GPL'd library, escape hatches notwithstanding (I suppose " they are not combined in a way that would make them effectively a single program" covers that). Commented Dec 11, 2014 at 20:43
  • It would be hard to justify that the port isn't a derivative work, especially since I believe it to be. The book itself doesn't seem to specify a license, but then it's RBT implementation is quite scant. I had to refer to the book site to get details missing from the book, such as the logic for deleting a key-value pair. I could always search for another implementation, or write more original code from a paper or a non-code description of the algorithm.
    – t.888
    Commented Dec 11, 2014 at 21:08
  • @t.888: If your question is whether or not a GPL'd library three steps removed from the end user that you use in your project can require the end user to abide by the GPL: yes, yes it can. The only way you can prevent that is by holding copyright, and the only way you can do that is if your work is an original work and does not incorporate GPL derived works. If the book is using GPL'd libraries, then its code is also most likely GPL. Commented Dec 11, 2014 at 21:11

In order to attach your own license to code, you must own the copyright. Generally speaking, that means that it must be code that you have written.

As an example, there are libraries out there already that provide some capability I want in my program. I have two choices: I can either live with the license that the library provides, or I can write my own library that performs a similar function.

The safest way to write my own clone library is to do it as a clean room implementation: that is, I write my library with no knowledge of the original library's internals. That way, I can be accused of neither stealing the code nor the algorithms that the code implements, because all of my work is original work.

Things get a little dicier if you're examining the code of the original library in detail. In order for a transformative work (that is, work that incorporates elements of an already copyrighted work) to qualify for copyright protection of your own, your work must be novel in some way; that is, it must contain original work. It seems to me that a library directly transcribed into another language is not novel enough to meet this criteria.

Further Reading

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.