On Programming Well
Programs must be written for people to read, and only incidentally for machines to execute.
Simplicity is a great virtue but it requires hard work to achieve it and education to appreciate it. And to make matters worse: complexity sells better.
â Edsger Wybe Dijkstra
Iâve been programming for 9 years and itâs only beginning to dawn on me how important these quote are. Like bacteria, programs want to keep growing and growing, both in size and complexity.
It doesnât help that engineers (like myself) keep feeding the beast. Complex programs, ones that only we can understand, gratify the ego. And well, the job security helps too.
But Iâm tired of shitty software. Iâm tired of using it, working with it, writing it, re-writing it⊠I just want to rest.
Good programs are like good writing. Iâll quote William Strunk:
A sentence should contain no unnecessary words, a paragraph no unnecessary sentences, for the same reason that a drawing should have no unnecessary lines and a machine no unnecessary parts.
Likewise, a good program should contain no unnecessary lines, no unnecessary bytes. Give me the code that works, is correct, and is fast â no more!
I wish I knew the secret to keeping software just the âright sizeâ. Like good writing, it seems like the only consistent path is to keep re-writing and re-writing. Every draft you cut a little more fat off the project. More and more, until all youâre left with is skin and bones.
Learning how to program well is a lot like learning how to write well. I didnât learn how to write through grammar exercises. I learned by writing and reading. A lot. It was the practice that made me improve.
I spent far too much time reading about different tools and design theories and architectures. Some of it helped, but most of it wasted my time.
If you want to get good at writing simple programs, you need to program a lot. You need to read a lot of programs too. Nothing else will develop your eyes, ears, and fingers more than the millions of lines of monospace youâll read and type. If you are more talented or clever than me, youâll do it in fewer lines. Probably an order of magnitude fewer lines (Iâm not particularly smart).
I wish I had some secret to share with you. I wish I could say more than, âgood programming is a matter of taste, and you just have to pick it up.â But thatâs all I got.
Good luck. Youâll need it.