Why Programmers Want to Write Code From Scratch
In his article “Things You Should Never Do, Part I”, Joel Spolsky writes:
"They write their own function because it's easier and more fun than
figuring out how the old function works."
This sentence got me thinking. Is it really just about fun? As I pondered, I realized there’s more to it. Here’s what I believe is the reason:
It’s not just about fun; it’s a necessity. We can’t truly learn until we do it ourselves. Reading alone doesn’t make you a writer; you must write. This applies to painting, music, photography, construction - anything. You have to do it yourself to truly grasp it.
This is especially true for software, where the final product exists only in your imagination. You must visualize the complex interflow of commands and communications in your head. This is challenging even when you’ve written it yourself, and nearly impossible when you’re only reading someone else’s code. Reading makes you aware of its existence but doesn’t make you capable of replicating it.
Therefore, it’s crucial for software developers to do it themselves. Merely reading and using someone else’s code is insufficient because it doesn’t teach you much; you remain confused about the system’s inner workings. You need to build it yourself to see how the gears fit together.
However, this approach isn’t always practical. You have to choose an abstraction level. For instance, an architect doesn’t need to understand how bricks are made, just how to use them effectively.
The best compromise I can suggest is that when reusing software, your exposure should be limited to its interface. If you have a good interface and can understand what it does, don’t reinvent that functionality. Problems arise when you’re asked to reuse the same source code to make minor changes or add features.
You should either do it all yourself or use it all as-is. Anything in between requires intimate understanding of the code, which you can’t achieve just by reading it. You have to write it yourself to become truly familiar with it. Without this, there’s no real learning, sense of growth, or self-achievement - all critical in any artistic field.
If a task is involving and gives you a feeling of achievement, even modest projects will receive good focus and commitment. Conversely, if it feels like dull work, even potentially amazing end results may fail to inspire programmers, leaving success mostly to personal discipline and commitment.