Ask HN: I am a copy/paste programmer, is that bad?

9 points by bikamonki ↗ HN
I wouldn't be able to write a simple HTML page from scratch. Google (more specifically Stackoverflow) is a vital part of my IDE! I've always sucked at remembering stuff but in compensation I got logical and analytical skills. I do not blindly paste the code, I do read it and see if it fits, but I would certainly have a bad time if not code references where around while coding. So, am I a bad programmer? Or is this way of programming more common than I think?

15 comments

[ 2.9 ms ] story [ 45.8 ms ] thread
That's normal don't let the online video tutorials fool you. They have it on another screen or a paper to make you think they are super genius by typing long snippets of code without even a typo.
A great man by the name of Einstein said something to the effect of: "Never try to remember anything you can easily look up in a book." (paraphrasing here). I don't think I've ever met a programmer that codes complicated programs by memory alone.
(comment deleted)
> I do read it and see if it fits, but I would certainly have a bad time if not code references where around while coding.

This is the most positive part of your copy/pasting practice: reading and understanding.

Reading the documentation alone is time consuming if the documentation does not contain example code, which visually put together what must be understood.

That said, looking up SO can also be a time sink: checking two or three questions until finding the correct question/answer. Maybe in no time http://devdocs.io would have answered the question. I also have a private gist app to gather snippets that I can quickly search.

> So, am I a bad programmer?

I read that a lot, experts don't need to look up the documentation. I'm not sure how true it is. That said I recognize that knowing basics perfectly, common Object, Array & jQuery methods, common modules in ruby/python etc... helps to build things faster.

Having good tools helps a lot.

+1 for devdocs.io - very useful extension
If you ever meet someone who says they can code with Spring without Google, they're lying.
To be honest I think alot of programmers copy and paste, unless it is something that they use often. If there is a module that you rarely use, or have never used before, why would you know how to use it off the top of your head? Also, some things you may be able to do on your own but copy and pasting could save you the time that it would take you to type those X amount of lines.
Every programmer probably does this.

If I see a function that works perfectly, is short and clean, and solves my problem, why not use it? That lets me spend less time reinventing the wheel and allows me to move onto more difficult problems.

It isn't fair to say that "Every programmer probably does this." I know for a fact I don't.
So what do you do? Study the code, close the browser, and rewrite it line for line?
Keep in mind, Stack Overflow code is generally licensed as: http://creativecommons.org/licenses/by-sa/2.5/

For many snippets there is no license so they're assumed to be under full copyright.

I was at a company that was required to send their code through Black Duck once, and they caught a 3-line function that was lifted from the Java runtime classes (because it couldn't be overridden). We had to issue a new release over this.

Also, I'm surprised how positively copy-paste coding is received here. Looking at docs is one thing, but otherwise it's not very good to rely on snippets from the web. A lot of things you want to program are not found by googling. Can you imagine a journalist saying they don't write their own their own stories, they just copy-paste paragraphs from already published stories and add some sentences to connect them?

I disagree with most people here. If it's remembering it's one thing. It just takes a while to remember certain things, but if you can't start out own projects or just write a project (or part of a project) that you feel like you know it may be a reason to worry.

But in the end it really depends on this. The problem is not the looking part, but if you have to copy stuff and can't start projects on your own, I don't know how that makes you a programmer.

Also it must be really hindering. What's important I guess is that it doesn't hinder you, that you are able to get into flow while programming, that you don't get stuck.

In other words. If you can't get into flow or if you don't understand the code it's a pretty big problem. If you are sometimes in flow and understand what you are doing it's nothing you should worry about. If you are in between it probably means you need more practice. For that maybe find something that interests you and write a small project (with as much looking as you like).

I often look up things as I jump between a couple different languages depending on what I'm working on. I'm not really looking how to do things, but more like how something worked, or maybe a more efficient way to do something. Usually if I'm going to copy/paste something it's just to paste into my code as a comment to use as an example. If I had to program without access to the internet, I'd need to have reference books around or I'd get stuck pretty quick.
I don't think it's strictly bad. Having said that there's nothing more blissful than spitting out 100-500+ lines of code that work (or makes sense as an outline) without looking anything up.