The thing to remember with copyright is it covers copying. If you read a book and rewrite it in another language you didn't copy it, you copied the ideas, perhaps, but copyright covers expression and not ideas.
Like I said, the copyright law makes an explicit exception for "translations". Copyright also covers translations, despite the fact that they share none of the "expression" of the original.
Creating a translation of a work is a derivative work itself. This applies to porting software from C++ to Java as well as translating of Harry Potter to French.
Re-writing a story and translation are different things entirely.
If I describe at an abstracted level the working of a C++ program to you and you implement it in Java then you have not copied the work, nor even created a derivative, ergo clean-room implementation being a thing.