What are rules with copying code exactly?

Started by
12 comments, last by swiftcoder 2 years, 7 months ago

Hello,

So I had a question regarding other peoples work, preferably C++? I know that it's common curtesy to give credit to the source, but what about legality of it? I don't think you could possibly own a piece of code?

Scenario 1: You find a math class that has everything you were going to do anyways. I'm assuming this has been done a lot and would you still credit the source? If anything, they are doing the work you wanted to avoided, but is it necessary even? It's nothing really special?

Scenario 2: You find a fast algorithm that required more knowledge then you know.

Scenario 3: You find a barebone framework and expand upon it greatly. It's possibly it won't even be recognizable by the end.

Lastly, at what point is it no longer even consider the original code? What if everything was renamed? It just got me curious because I often look through GitHub and get ideas how to accomplish specific things, let's say A*. I often alter a lot of it especially to make it work with my current setup, but is it even necessary to give credit to someone who did A*? He's essentially applying a known piece of code, but because he typed it he gets the credit? I think I do more copying and pasting then I'd be proud of. I'll often learn from a book, for example, and at that point I just prefer always doing it that way and make my own little adjustments.

This is all curiosity and I think in general it's always nice to give credit to code you really think deserved to be mentioned. It just really had me thinking about all this legally and at what point and alterations would be considered “your own?” Any other points or explanations would be appreciated.

Thanks, have a great weekend.

Advertisement

Disclaimer: If you want to know exactly, talk to a lawyer. They are the only persons that can say something useful about it. I am not such a person. Anything I say is not legal advice.

As far as I know, writing code is a creative process. Its author thus owns it. Just like you would make a painting. It's your painting if you make it. To use code from someone else, you need permission from its owner. Just finding it on the Internet isn't enough. If you find a car parked on the street, it doesn't mean you can use it.

A license is the usual way to handle permission. It tells you what you are allowed to do, and what not. If there is no license, you have to ask and get permission, else it's hands-off. If you are allowed to copy the code and change it (copying and changing don't always come together!), you can do so. As long as you stay within the bounds of the license or the given permission, you are legally covered.

As for feeling ownership, I consider code written by someone as not my code. All changes and additions are mine though, for me. I am happy to share code ownership, I don't need it to be “all mine”.

Interesting. Yeah, I don't need to go as far as talking to a lawyer haha. Strictly a question that popped up in my head. I don't think everything could pass as creative process though. I can see a full engine, or complete API or partial for that matter, as they obviously are with giant documents and price tags at times. Somethings are just standard, and besides names have been implemented 99% the same way. So who gets the “authority” to say “that's MINE!”

Going to my example of a book I always use. It's literally how I always do my StateMachine and setup a Window class. It's nothing special, he for sure didn't come up with the idea, but it's essentially the way I was taught, thus I always resort back to it. I typically add a lot more to it and switch around parts I didn't like from the book, but it's more or less the same.

Anyways, thanks for your opinion!

LedMar said:
I don't think everything could pass as creative process though. I can see a full engine, or complete API or partial for that matter, as they obviously are with giant documents and price tags at times. Somethings are just standard, and besides names have been implemented 99% the same way. So who gets the “authority” to say “that's MINE!”

Thats a moot point though. Everything in the creative industry has been done before. Just because there are 100 models of zombies, doesn't also mean that the person who creates model #101 hasn't done a creative process, and looses his rightful authorship and copyright over his art. The same goes for code. Even if an ECS as a concept has been done in 20 different ways doesn't mean you can just take the code for my implementation of it and just copy it and don't disclose the fact that you copied it. Now you can take inspiration from it and do your own spin, sure.

But in general, I think its all depending on a couple of factors. First, does the author of the code intend for people to copy it? In case of a book, I'd say sure, there's nothing keeping you from taking something from a book you bought and integrating it into your own work (I do that occasionally with shader-snippes, as shader-math is not my strong point). Second, you have to be open about it. To me, that doesn't even mean you have to openly credit everything, but you should at least not claim that things you copied are your own, just because you modified a few LoC from the original.
Thats just my two cents anyway.

LedMar said:
It's nothing really special?

A valid argument, but who decides what's special and what not? The safe bet is to treat everything as special / property.

It's clear many people share code for others to use it or learn from it. Licenses should confirm and show all the details.
But a fellow web developer told me: Some shady people also put code on internet and then seek out for others which copied it to request compensation.
Not sure if this is actually true or just super rare. Maybe less a problem for games / apps where code mostly isn't included.

@JoeJ It wouldn't surprise me if that's true. A year or two ago, I seen a random guy reselling a free programming book on Amazon as brand new and just had to taddle on him. Just felt wrong and it was going for $70! When it's free! It was taken off the next day. I was reading the book and I said, “Wow, this is good stuff, it all seems so familiar though, yet this is brand new” and figured it out quickly where it was from. I think it was called GoalKickers, if anyone looking for basic books for the many languages out there.

You can narrow what special is by something as simple as a math formula that he didn't create. The only thing different is the language implemented in. Just for example, 50 people have a distance function, or basic Vector2 class for that matter. What you will write down, will me 99% of what everyone else does. It just seems off to me without adding some type of own creative twist.

@Juliean There is difference between something being done before and the code itself. The code is different, while accomplishing the same goal. Creating your own zombie isn't going to be the same as someone else's zombie. You can clearly distinguish your own art. We are talking about code that on a basic level can be copied almost exactly the same. Stack class. Whatever it may be, just seems pointless to give credit to someone for typing what you will type regardless. Now, this is all exaggeration and you can apply it all appropriately with no issue, but I just wanted some thoughts on it.

Lots of people on Github and books as well give free permission to use their code. So finding something to be used freely is easy, but I don't really stop and think who I should be giving credit to things for. But I appreciate your 2 cents.

EDIT: Also, the car example. It would be more like 5000 people having a 2021 Honda Civic, and saying I own that car so I get to drive yours too verse customizing your own car and having your own license plate and clearly being able to determine the difference between one or the other.

LedMar said:
We are talking about code that on a basic level can be copied almost exactly the same. Stack class. Whatever it may be, just seems pointless to give credit to someone for typing what you will type regardless.

The key word here is almost. Every developer's code has its own idiosyncrasies that differentiate it from the next developer, just like artists have their own style and quirks with their artwork that make it their own.

Keep in mind, it's not just a legal issue but also one of morals.

If you blatantly copy someone else's work and don't give credit (even if it would have been line for line what you would have wrote), then you have morally disregarded the time and effort of the original author for your own personal gains. In other words, it says a lot about your own character.

Be honorable, be just, and do what's right.

LedMar said:
@Juliean There is difference between something being done before and the code itself. The code is different, while accomplishing the same goal. Creating your own zombie isn't going to be the same as someone else's zombie. You can clearly distinguish your own art. We are talking about code that on a basic level can be copied almost exactly the same. Stack class. Whatever it may be, just seems pointless to give credit to someone for typing what you will type regardless. Now, this is all exaggeration and you can apply it all appropriately with no issue, but I just wanted some thoughts on it.

Even for something as basic as a stack-class, the actual interface and implementation details will vary profoundly. If you compare the c++ STL-library with something like EASTL, you'll find the difference is night-and-day. Even the different standard-libraries vary tremendously in their implementations, even though they are pretty much bound by the C++-standard. Especially in C++, which is a very expressive and low-level language, there is a lot of room for customization. For example, I'm rolling my own vector-class, with some of the key differences:

  1. Usage of “if constexpr” to remove lots of compile-time and debug-runtime overhead for vectors of trivial types (while the standard-libraries seem to start adapting this since a few years, back when I did it it was something that alone is enough to varant my vector being its own thing)
  2. Lots of custom “algorithms” build in like MaxIndex, ResetToSize, Extract(Front/Back), RemoveIndex … based on my own coding-patterns.
  3. The ability to construct a vector in-place with capacity and then insert elements w/o the possibility of reallocation; a bit of a peep-hole optimization, but also reduces compilation-overhead and allows constructing a vector of non-moveable types (which is a pending but probably rejected paper for the standard)
  4. The ability to allocate a vector with unitialized data, which is something the standard can absolutely not do (to interface with c-libraries etc…)

Just to give a few examples. Also, the entire class has been written from scratch using my own “system” libraries and abstractions, so its definately its own thing; and I wouldn't want you to essentially copy it and just say “oh its the same like everything else so I might have written it myself”.

I do think that you are measuring with two spoons here. Just because you can easily see how art is different or similar, code isn't just all the same, just because a few common patterns recur all the time. You have a lot of choice in designing code as well, and you have to develop a concept of what algorithms you use, how to use them; how much you value speed or security, what type of error-checking you apply etc… So, even if a “vector” will always have constructors, a destructor, and a few choice functions ([]-operator, back/front, size, capacity…) there is enough room to distinquish it from others.

Think of it this way: If you were tasked with writing a “vector”, would you have done exactly my points 1-4? Even I only added #4 just recently after noticing the recurring pattern of having vectors that are (init) reserved once, and then filled, never to be touched again. That finding alone makes it unique, even if the resulting code is a regular EmplaceBack-method with a different name and 90% less code.

LedMar said:
…. You can clearly distinguish your own art. We are talking about code that on a basic level can be copied almost exactly the same. Stack class. Whatever it may be, just seems pointless to give credit to someone for typing what you will type regardless.

False. I can distinguish code that I wrote from code that I didn't write. Length of the lines, spacing, names of variables, and function, comments, alignment, indenting, blank lines, order of computations, etc.

This topic is closed to new replies.

Advertisement