r/ProgrammerTIL • u/Acrobatic_Raisin_114 • Apr 05 '21
Other Is it ethically wrong to copy/paste from the internet?
I had a tree question that count the minimum depth of a tree, instead of spending time trying to figure out how to solve it, I found a solution online and understood it then I copied pasted it, and in the future if I needed to update something then I can do it easily by myself.
so my question for you is: is it wrong (morally/career-wise) to be approaching this way? especially if I don't claim that the code was mine? thank you.
70
Upvotes
7
u/[deleted] Apr 05 '21
Do you understand the code? Will it impact people's lives if you're inept at your job? The problem isn't copy pasting from the internet, numbnuts, the problem is copy pasting from the internet and including the code in your cancer detection software or the like. And if you need to ask if it's ethical or not, it isn't. Learn your shit. Fuck you.
83
u/McMasilmof Apr 05 '21
I copy from the internet all the time and i dont see a problem with it at all. I mostly dont do literal copy-paste, but type the answer i find, just because i need different variable names or structure. If its a clever solution i add a comment with the link to the page(mostly stack overflow) i found the solution to show how i got this and add a bit of context.
Stack overflow is made for this, its clear that others will use the provided solution.
90
u/picturestone Apr 05 '21
There is no need to reinvent the wheel. I‘d even go as far as saying that copying code is quite usual. As long as you understand what you are copying and give credit where credit is due I see no issue.
30
u/[deleted] Apr 05 '21
As purlyeboy has said, check the license. If you pull in code which uses a license which requires all code to be open sourced, and you don't work on academia or in open source, then your boss is going to be mad as hell.
Copy/pasting code from the web is also pretty bad for your own learning. I've mentored juniors who have built amazing things, but they have no idea how it all works because they've copy/pasted swathes of code from Stack Overflow and documentation without actually grokking what it does and how it works. As long as you're taking the time to read the code, understand what it's doing, and (more importantly) take on the risk of supporting it, then I don't see a problem.
That second point goes into something posted on meta Stack Overflow: intentionally posting malicious code as answers. If you're blindly copy/pasting code from the web, and you're not taking the time to read and understand it, how do you know that its not malicious?
If you're grokking the code then feel free to copy/paste all you want.
If you're just copy/pasting without reading and grokking, then you're going to have a bad time.
17
u/purleyboy Apr 05 '21
Be careful of copying from AGPL OSS, this can cause you licensing issues and require you to release your sw (or your employers) under the same license.
4
u/SakishimaHabu Apr 05 '21
Just make sure you link the stackoverflow page so the next person that looks at it has some documentation.
1
u/PennyPriddy Apr 05 '21
You called it a "tree question," was this for a class or an interview?
3
u/[deleted] Apr 05 '21
While learning, it's useful to try to figure stuff out yourself because new problems you encounter in the future won't necessarily be variations on data structure problems, but will depend upon the the sort of reasoning you developed solving those. Once you're a professional and just trying to get things built to spec, copy whatever you can find that people have shared or is open source. Just don't copy a whole application.
3
u/seanprefect Apr 05 '21
If it was an academic situation then yes. Outside of that it's standard.
3
u/JCDU Apr 06 '21
As several others have said - copying the solution is no problem as a lot of problems have one or two optimal solutions so you'd only be re-inventing the wheel.
HOWEVER - you need to understand what you've copied, how and why it works and any limits / bugs etc. that could catch you out. Just pasting a block of code in without understanding it is asking for a huge fuck-up later and you'll have no idea why.
Also as others have said - at least paste the URL and maybe a short description into a comment so you or whoever else finds it later has some sort of reference for WTF is going on.
2
u/swapripper Apr 05 '21
Repeating my comment from another reply here
As a human, you tend to forget things.
When I noticed I was googling/SOing multiple times for the same things/errors, I decided to:
On weekend, revisit those 5 docs for the week & move them where each belong. Like Python, Elasticsearch, Django ( based on whatever tech specific things I was working on). Also read up only a bit of formal tech documentation around the same thing. Point is to also know how to navigate & look up things in docs, not just rely on SO all the time. You’ll come to a know a few more things which again will go into the index files.
Doing this for a few times and I noticed
I’d be happy to know if some other experienced folks practice something similar.
2
u/Geemge0 Apr 05 '21
As others have said, as long as you understand it.
The problem though is that you've deprived yourself of the difficult task of learning a hard problem through struggling and your own analytical thought. You've already done yourself a disservice to being better at your chosen career path, the understanding it helps but you didn't struggle and find it yourself.
This isn't a hard and fast rule though, but bear that in mind.
2
u/jsh1138 Apr 05 '21
If you don't give credit to whoever did the work, yes it's ethically wrong.
Career-wise, as long as you understand the solution it's probably fine.
2
u/Kaligraphic Apr 05 '21
Yes, it is absolutely ethically wrong to copy/paste from the Internet.
You should download things locally and copy/paste from that.
More seriously, comply with license restrictions, and make sure you understand what you're copying. There's plenty of bad code on SO that you might not want to throw into production.
2
u/WestonP Apr 06 '21 edited Apr 06 '21
If it's in something with a license, then you need to abide by that license.
If it's truly public domain with no requirements, I add a comment to the code noting where I got it from, and any modifications I made to make it fit my purpose. That's also helpful if I find a newer version of it later and want to update while keeping my own changes.
And every time that I've posted my own code as an answer to a question, or otherwise to the public domain, I hoped that others would find it useful and integrate it into their own projects. I mean, why post code if you don't want that? Ideally, people would learn how/why it works and get that benefit too, but that doesn't mean they can't or shouldn't copypasta it as-is.
2
u/nxpnsv Apr 06 '21
Is your goal learning, then your just wasting your time. Otherwise, everybody copies...
2
u/coder111 Apr 06 '21
No it's not wrong. Leave a note with authors name or source (stack overflow link) if you can.
This whole obsession with copyright is a fairly new thing and designed mostly to keep corporations in power and money. For most of human history there were no copyright law at all...
2
u/NickUnrelatedToPost Apr 05 '21
Totally fine. We all do it.
In the end my employer wants a program that does what it should. And he wants me to arrive there in the shortest possible time. So why should I not use what's already there?
2
u/reallyserious Apr 05 '21
You can turn this question around. Is it morally right to spend a long time reinventing the wheel if there is a perfectly useable one available? Who is paying for your time and can that time be used more efficiently by solving actually unsolved problems instead?
1
u/Dudeguybrochingo Apr 05 '21
Is it wrong to copy a sentence structure to better articulate yourself in writing? No.
1
u/rdr11111 Apr 15 '21
I have this inexplicable urge to copy, consolidate and repost all the answers in a single reply.
1
u/[deleted] Apr 30 '21
if you aren't claiming it i dont see a problem. It's just part of the business and its why I love open source communities so much. If we had to reinvent the wheel every time tech would not be nearly as advanced as it is.
1
u/neoKushan Apr 05 '21
Your employer is paying you to produce solutions to problems they have.
They're not paying you to re-write code someone else already wrote, from a moral standpoint they don't care how you get the software written as long as it's legal and compliant (So heed the advice about licenses, etc. but you asked specifically about morals).
If I had to take a stance, I'd say it was immoral not to take the code that is already-written, you're effectively wasting time that you're being paid for.
0
u/cdrini Apr 05 '21
I would say it depends. For your specific example, I would probably try to implement it myself without searching for a solution. That seems like a classic tree manipulation algorithm, and those sort of algorithms are at the heart of CS. It also shouldn't take too much time to implement it from scratch.
On the other hand, if I'm looking for something that's more platform/language specific (like "how to determine screen DPI in JavaScript"), where I won't be learning anything super abstract/general by implementing it myself, then I'm ok copy/paste/massage/cite.
In general, I think you learn more by implementing something yourself, so for me, if (1) it's something you want to be better at, and (2) the amount of time required to do it yourself isn't ludicrous (i.e. you're not like implementing a compression algorithm), then implement it yourself. If it's something that's more esoteric/specific and not generally re-applicable, copy/massage/cite.
-2
u/aloisdg Apr 05 '21
nope my whole career is build on copy/pasting. Copy/paste into a library and put it online. In the normal world, their is a whole movement about that. It is call free and open source software.
0
u/[deleted] Apr 05 '21
[deleted] — view deleted comment