Hacker News new | ask | show | jobs
by baddox 4468 days ago
Is copy/pasting a solution without understanding how it works worse than using a library, framework, or programming environment without knowing how it works?
5 comments

Yes, it is. Using a library is a transition of abstraction layers. It's expected that some understanding might get lost at that point. It's also expected that you understand what the library promises to do when you make that call - i.e. that you read the docs.

Copy/paste lives at the same abstraction layer as code that you actually write yourself - the same level of understanding should apply. (Of course, if you don't understand any of the code you write, you're in the clear ;)

In that case, it sounds like it just depends on whether you paste the code directly into an existing file. If you paste the code into its own file, then import it into your project, the distinction seems to vanish.
A library isn't just code that happens to be in a separate file. Someone chose an abstraction layer at which to create a library, wrote the library code, tested it and wrote documentation.

If you went and copy-pasted some code on stack overflow into a file, put it on github and released it as a "library", I might not agree that it was one.

While it's good to know something about how all the component works, most of us spend most of our time at a particular level of abstraction, and don't worry about the details of the framework->language implementation->compiler->hardware instruction set->silicon pathways all the time.

If you understand your code at your current level of abstraction, you're probably doing OK. If you don't, you're definitely in trouble.

This could be an interesting debate. On the one hand, I can see similar problems arising from either copy/paste of unknown (to you) code or using an unknown (to you) library or framework. In both cases, there is black magic (again, to you) that could go wrong and you just won't know how to deal with it.

On the other hand, there's a difference in the level of abstraction between copy/paste of code and calls to a library or framework. The question is, will you recognize the difference between a bug in your code, a bug in the copied code, and a bug in the framework code?

To solve code problems, you need to be able to identify where the problem actually lies ...

I would say yes, because the effort required understand a copypasted snippet is less than the effort required to understand a library/framework/whatever.
I think it's OK to not know the implementation details of code you aren't responsible for maintaining.
To an extent. You should still know the performance details. As an example, a project a colleague was working on was generating Excel files as a report format. He didn't need to know why the library couldn't handle anything over a (forgot the exact number) 32MB, but he needed to know that detail. It failed to execute on some data files as a result, something that could have been checked and worked around (temporary fix: multiple Excel files; permanent fix: better report format).