How many times have you heard this:
I need to lose weight for the summer. I’m on a beach diet.
I’m guessing your answer is “a lot”. That person wants to lose weight not because it will make him/her feel good or because it will increase his/her lifespan, but because other people are watching.
The more you think about it, the eyes of others are a very powerful motivational tool. Sure, everyone does a little self-improvement because it feels good, but most improvement is a result of outside pressure/scrutiny.
I’m sure at this point you are thinking “what the hell does this have to do with programming”? And the answer is: writing for open source is like going on a beach diet. When you contribute code to an open source project, or just open source a project of your own, I’m sure you spend extra time cleaning up the code and making sure it’s not “hackish”. Even the most accomplished programmers refactor their code before they release it to open source, even if the functionality doesn’t change. The sense that others are watching motivates us, and it’s part of what makes open source code so great. Nobody wants to show up to the open source beach with fat, heavy code, and that is, in my opinion, the real power of the open source movement.
What’s the lesson here? It should be obvious: write code that is open sourced. It doesn’t matter what the project is, you will only do a better job if you have to show other people your code. It does not depend on the intelligence or ability of the people reading your code, but only on their presence. I am starting to learn this lesson now, and in the future I plan to release every piece of code that can.