3 ms·
> Good programmers write good code. Great programmers write no code. Zen programmers delete code. I guess then I have been a Zen programmer from the beginning.
by combatentropy 8y ago
> Good programmers write good code. Great programmers write no code. Zen programmers delete code.
I guess then I have been a Zen programmer from the beginning. Maybe it was because first I was into writing, and my favorite book is the Elements of Style. I relish deleting code, but you have got to understand I'm not deleting features, security, or anything.
It is really hard to explain how it's possible to someone who has not known it first hand, how you can subtract things yet lose nothing --- or even gain something. The simplest example of how you can delete code and not affect features is deleting code that was commented out by the last hooligan, commented out because he did not use version control and was trying different ways to solve the problem. The next most obvious example is code that is never run: functions that are defined but never called or, trickier, branch conditions that will never be true. But most of all I guess I have just worked with a lot of people who subscribed to the copy-and-paste method of code re-use. It's easy to pull out the repetition into functions.
One of my favorite examples of less-is-more is outside the field of programming, in the field of sports cars. The Lotus Elise weighed 1,600 pounds, so even though its engine had just 118 horsepower, it could go 0 to 60 in 6 seconds. In constrast to heavier sports cars, who solved the speed problem with the more obvious solution of dropping in a bigger engine, the Lotus also had these advantages: more miles per gallon, faster braking, nimbler cornering. As the founder, Colin Chapman, said, "Adding power makes you faster on the straights. Subtracting weight makes you faster everywhere."
How do you shave weight while retaining rigidity? Through another minimalist technique: reducing pieces. The chassis was of one piece, a "monocoque." Since things break at joints, instead of reinforcing the joints, you just do away with them. Steve Jobs, another minimalist, used the same technique in MacBooks. By cutting them out of one piece of aluminum, the frame can be thinner and lighter yet still stronger than competitors.
- btschaegg 8y agoTo add the obligatory quote of Antoine de Saint-Exupéry: > Il semble que la perfection soit atteinte non quand il n'y a plus rien à ajouter, mais quand il n'y a plus rien à retrancher. > Obviously, perfection is not attained when there's nothing left to add, but when there's nothing left to take away.
- EForEndeavour 8y agoObligatory quote from Frank Herbert's Dune: > Arrakis teaches the attitude of the knife - chopping off what's incomplete and saying: 'Now, it's complete because it's ended here.'
- eddieh 8y agoThe best code to delete is when someone was cargo cult programming and put code in that doesn’t do anything or is completely unnecessary in some way.
- pureliquidhw 8y agoJust be careful before ripping out too much! https://en.wikipedia.org/wiki/Wikipedia:Chesterton%27s_fence https://en.wikipedia.org/wiki/Wikipedia:Chesterton%27s_fence
- eddieh 8y agoYup, that is a risk. I had an issue once where the person transcribed the wrong bug ID in a comment above a piece of code that appeared as though it was meaningless. I was able to catch the error and put the correct bug ID in and a more assertive comment describing why the code was needed. Long story short, always comment weird shit and use the correct bug ID.