Hacker News new | ask | show | jobs
by guelo 3521 days ago
This might be a joke but everybody does it manually for real. Whenever I copy-paste some tricky function from SO I like to add a code comment with the url pointing to the stackoverflow.com answer. This allows future maintainers to refer back to SO and see if a better answer has surfaced or read comments about any issues.
4 comments

Almost 3 years ago Visual Studio demo-ed a feature that would copy-paste code from StackOverflow, while automatically renaming the variables to fit your code :

https://blogs.msdn.microsoft.com/visualstudio/2014/02/17/int...

The tool is available here:

https://visualstudiogallery.msdn.microsoft.com/a1166718-a2d9...

I never, ever copy paste code, unless it's really long. I always end up rewriting everything myself, so I have the time to think about what's happening.
Hmmmm. I'm the other way round. I copy and paste short snippets because I'm lazy and I can see if they are ok at a glance. Longer code I'll go through line by line and try and 'touch' each line to force me to think about it.
I do it for that reason but also for license attribution and indicate that I didn't write it.
> everybody does it manually for real

I've been programming professionally for much longer than there's been a stack overflow. I have never, ever, cut and pasted code from stack overflow.

I've worked with people who did it with pride. When I pointed out we had no license for the code, they proudly told me anything without an explicit license was public domain.

I quit not longer after that.

StackOverflow code is under a license - cc by-sa 3.0. They were planning on clarifying this by moving to the MIT license, but there was some pushback on that and they are holding off for now at least: https://meta.stackexchange.com/questions/272956/a-new-code-l...

Besides that, most snippets are small and trivial enough that using them would easily fall under fair use.

Obviously, your case showed a lack of care on their part, but you can use SO code.

How do you know how to loop over an array for (int i=0;... ? You didn't invent that code. You read it somewhere many years ago and have copied it over and over many times since then. Do you have a license for that code? The author you learned it from did not invent it either, was he violating a license? It wasn't even invented by Dennis Ritchie since he copied the idea from earlier languages.

My point is that trying to copyright basic snippets of code is just ridiculous, it's something lawyers have tried to force on programmers but it makes no sense. We would be completely unable to program at all if we listened to lawyers all the time.

Well, actually I just typed [] in my browser's console, expanded it, then expanded the prototype and found a method called "forEach" which sounded like what I wanted. Fiddled with it a bit until it worked.

Clean room usage~