The Two Rules of Great Programming
2008.11.07 prev next
As for what this all means, I’m still trying to figure that out. I abandoned seven long-held principles about business and software engineering, and nothing terrible happened. Have I been too cautious in the past? —Joel Spolsky
Figure out the absolute least you need to do to implement the idea, do just that, and then polish the hell out of the experience. —John Gruber
I’M about to save you a lot of money on books about programming theory. There are really just two rules of good programming:
Bugs are bad — Your app should work correctly as designed and/or as its end-users expect it to.
Occam’s Razor — Simpler solutions are better, provided they still accomplish the same result. So simpler code is better if it does the same thing as more complex code. And a simpler, more intuitive user interface is better than a more complex one that enables the user to do the same things.
That’s it! Those are the only real rules to good programming. That, and of course being smart enough to know what algorithms you need and how to code them.
You can’t fill a thick book with rules about what good programming is all about unless you make up a whole lot more than the quarter-of-a-page taken up by the above rules. And all that made-up filler is utterly arbitrary. It’s what the author(s) of the book prefer to do. Or maybe not even that — it might be merely what the author(s) would like you to do if they were your boss, even if they don’t consistently practice it themselves. It might be stuff that sounds really good in a book, until you actually try to do it and discover it sucks. And of course a whole lot of it is vacuous, fortune-cookie fluff, in the same vein as “buy low, sell high,” or “spend more time exhaustively looking into everything” — or just “do more.” It sounds like good advice, but it really doesn’t help you at all.
And when they conflict, which authors do you follow? Try to figure out who’s right in the following (fictional) conversation:
A: And then the webpage builds a temporary PDF file in this folder on the server, and serves it up to the user. Problem solved!
B: What happens to those PDFs? Will they just accumulate on the server?
A: No, every time it creates a new PDF, it first deletes existing PDFs that are older than 24 hours.
B: Oh. But what if nobody uses the app for days? How will the PDFs older than 24 hours get deleted?
A: They won’t — but if no one is using the app, then PDFs aren’t accumulating.
B: That sounds flaky. I think we need a service that checks every night and deletes these PDFs if they’re older than 24 hours.
A: But what if that service goes down and nobody knows it? Then the PDFs will just accumulate. And do we really want yet another service to maintain?
B: Well, we can’t depend on future user activity to delete temporary files. That’s just a bad idea.
You could write a proper-programming book and in it argue for either A or B — whichever you like better — and present it as if it’s obviously the correct position. Here’s a choice example from a certain programming theory book of which I once was required to read large portions:
What you’re trying to do [by appointing a project librarian, setting up meetings and forums, and frequently reviewing each other’s code] is foster an environment where it’s easier to find and reuse existing stuff than to write it yourself. If it isn’t easy, people won’t do it. And if you fail to reuse, you risk duplicating knowledge.
Bad news, guys: If it isn’t easy to appoint a project librarian, set up meetings and forums, and frequently review other developers’ code, people won’t do that. As I pointed out a little while ago, authors of programming books want you to think that your job is to make things easier for other programmers, because that’s what they (the authors) do. But if you really want to make something that people go “wow” over, then you’re not trying to make things easier for other programmers; you’re trying to make things easier (and better) for the end-users, who typically aren’t programmers — and even when they are, they would probably rather your app kicked ass from an end-user perspective than be easy for them to goof around with in the sourcecode.
My biggest and most appreciated project to date is SWTSG. When I think about how I would have to have written that app to satisfy almost any “good programming” book’s authors, I can only recoil in horror. Among many other things, I would have to have:
developed six OS-compatible fonts, then figured out a way to make the required glyph distortions work with fonts in that format (if possible at all)
figured out a way to include those six new fonts with my app and make them install on the user’s computer
supported Unicode from the get-go, instead of modifying the app later to support it
written everything as OO (ObjC) classes, regardless of the effect on speed and/or portability
regularly submitted my unfinished code to other developers in internet forums for their review and criticism, which would have made the whole thing into an exasperating exercise in dealing with other persons’ attempts to project themselves as teachers and me as student, and which would have turned the whole project into a group effort with unpredictable outcome
scoured the internet and other “official” code sources for pre-existing libraries which I could link into my project and use, instead of “reinventing the wheel,” then found a way to ensure that my project can discover and draw-in any updates to those libraries
break down all the necessary complexity of the app into many, small, interdependent pieces, any one of which will not intimidate other developers into washing their hands of trying to understand it, and instead authoritatively declaring that my code is an incomprehensible mess
riddled the entire sourcecode with lines that are blank except for a single brace character — a practice which almost everybody thinks an improvement in readability, for no reason that I have been able to discover
completely forgone the “wow” factor that results when users see a fantastic finished product that they had no idea was even under development — maybe, if I was very lucky, a limited version of the app (perhaps rendering the crawl only) would be just coming out today, after years of work and general internet awareness that the project was underway. It would have been a big disappointment, and no one would say “wow.”
Grab a couple “proper programming” tomes and you can probably expand the above list to many times its current size. Suffice it to say that the project would have been utterly ruined if I had tried to satisfy these authors’ ideas of how software should be developed.
Sometimes you just have to go with your gut, and know that if you’re so far out there that society is actually threatened by your activity, then society certainly has the power to stop you. If it doesn’t stop you, then the proof of the pudding will be in the eating — and only afterwards can the recipe be subjected to an anal exam.
See also: Faster Is Better
Update 2009.09.24 — Don’t miss Joel Spolsky’s “The Duct Tape Programmer.”
Features (Regularly Updated)
A Memory of Gateway — news chronology of Apple’s ascendancy to the top of the technology mountain.
iPhone Party-Poopers Redux and Silly iPad Spoilsports— amusing litanies of industry pundits desperately hoping the iPhone and iPad will go away and die.
Embittered Anti-Apple Belligerents — general anger at Apple’s gi-normous success.
Now available on the iBookstore!
Real Solution #9 (Mambo Mania Mix) over stock nuke tests. (OK, somebody made them rip out the music — try this instead.)
Ernie & Bert In Casino
Great Explanation of Star Wars
Best commercials (IMO) from Superbowl 41, 43, 45, 46, and 47
Kirk & Spock get Closer
American football explained.
Sonos and Opalum — awesome sound stuff I saw at CEDIA.
TV: The Jinx; Breaking Bad; House of Cards; Inside Amy Schumer
Celebrity Death Beeper — news you can use.
Making things for the web.
My vote for best commercial ever. (But this one’s a close second.)
Best reggae song I’ve discovered in quite a while: Virgin Islands Nice
Pinball Arcade: Unbelievably accurate simulation of classic pinball machines from the late ’70s through the ’90s, with new ones added periodically. Like MAME for pinball — maybe better.
Best 9/11 documentaries: Inside 9/11: Zero Hour; Inside the Twin Towers; 102 Minutes That Changed America
Favorite local pad thai: Pho Asian Noodle on Lane Ave. Yes, that place; blame Taco Bell for the amenities. Use the lime, chopsticks, and sriracha. Yummm.
Um, could there something wrong with me if I like this?
This entire site as a zip file — last updated 2015.07.03
Answering the Toughest Question About Disruption Theory
SSD TRIM Command In A Nutshell
The Enderle Grope
Aha! A New Way To Screw Apple
Champagne, By Any Other Maker
iOS Jailbreaking — A Perhaps-Biased Assessment
Embittered Anti-Apple Belligerents
Before 2001, After 2001
What A Difference Six Years Doesn’t Make
Stupefying New Year’s Stupidity
The Innovator’s Victory
The Cult of Free
Fitness — The Ultimate Transparency
Millions of Strange Devotees and Fanatics
Remember the iPod Killers?
Theory As Simulation
What Was Christensen Thinking?
The Grass Is Always Greener — Viewing Angle
Is Using Your Own Patent Still Allowed?
The Upside-Down Tech Future
Motive of the Anti-Apple Pundit
Cheating Like A Human
Security-Through-Obscurity Redux — The Best of Both Worlds
iPhone 2013 Score Card
Dominant and Recessive Traits, Demystified
Yes, You Do Have To Be the Best
The United States of Texas
He’s No Jobs — Fire Him
McEnroe, Not Borg, Had Class
Conflict Fades Away
Four-Color Theorem Analysis — Rules To Limit the Problem
The Unusual Monopolist
Five Times What They Paid For It
Bypassable Security Certificates Are Useless
I’d Give My Right Arm To Go To Mars
Free Advice About Apple’s iOS App Store Guidelines
Understanding IDC’s Tablet Market Share Graph
I Vote Socialist Because...
Product Naming — Google Is the Other Microsoft
Apple Paves the Way For Apple
Why — A Poem
App Anger — the Supersized-Mastodon-In-the-Room That Marco Arment Doesn’t See
Apple’s Graphic Failure
Why Microsoft Copies Apple (and Google)
Coders Code, Bosses Boss
Droidfood For Thought
Investment Is Not A Sure Thing
Exercise is Two Thirds of Everything
Dan “Real Enderle” Lyons
Ignoring the iPod touch
Manual Intervention Should Never Make A Computer Faster
Zeroth — Why the Century Number Is One More Than the Year Number
Longer Than It Seems
Partners: Believe In Apple
Gun Control: Best Arguments
John C. Dvorak — Translation To English
Free Will — The Grand Equivocation
What Windows-vs.-Mac Actually Proved
A Tale of Two Logos
Microsoft’s Three Paths
Amazon Won’t Be A Big Winner In the DOJ’s Price-Fixing Suit
Infinite Sets, Infinite Authority
Strategy Analytics and Long Term Accountability
The Third Stage of Computing
Why 1 Isn’t Prime, 2 Is Prime, and 2 Is the Only Even Prime
Lie Detection and Psychos
Microsoft’s Dim Prospects
Humanity — Just Barely
Hanke-Henry Calendar Won’t Be Adopted
Collatz Conjecture Analysis (But No Proof; Sorry)
Rock-Solid iOS App Stability
Microsoft’s Uncreative Character
Microsoft’s Alternate Reality Bubble
Microsoft’s Three Ruts
Society’s Fascination With Mass Murder
PlaysForSure and Wikipedia — Revisionism At Its Finest
How Many Licks
Microsoft’s Incredible Run
The Size of Things In the Universe
The Self-Fulfilling Prophecy That Wasn’t
Nobody Was In Love With Windows
Apples To Apples — How Anti-Apple Pundits Shoot Themselves In the Foot
No Holds Barred
Betting Against Humanity
Apple’s Premium Features Are Free
Why So Many Computer Guys Hate Apple
3D TV With No Glasses and No Parallax/Focus Issues
Waves With Particle-Like Properties
Gridlock Is Just Fine
Sex Is A Fantasy
Why the iPad Wannabes Will Definitely Flop
Predators and Parasites
Prison Is For Lotto Losers
The False Dichotomy
Wait and See — Windows-vs-Mac Will Repeat Itself
Dishonesty For the Greater Good
Barr Part 2
Zune Is For Apple Haters
Good Open, Bad Open
Beach Bodies — Who’s Really Shallow?
Upgrade? Maybe Not
Eliminating the Impossible
Farewell, Pirate Cachet
The Two Risk-Takers
Number of Companies — the Idiocy That Never Dies
Holding On To the Solution
What You Have To Give Up
The End of Elitism
Good and Evil
How Religion Distorts Science
Laziness and Creativity
Sideloading and the Supersized-Mastodon-In-the-Room That Snell Doesn’t See
App Store Success Won’t Translate To Books, Movies, and Shows
Silly iPad Spoilsports
Five Rational Counterarguments
Reaganomics — Like A Diet — Works
Apple’s On the Right Track
Mountains of Evidence
What We Do
Hope Conquers All
Humans Are Special — Just Not That Special
Life = Survival of the Fittest
Excuse Me, We’re Going To Build On Your Property
No Trademark iWorries
The Fall of Google
The Meaning of Kicking Ass
How To Really Stop Casual Movie Disc Ripping
The Solitary Path of the High-Talent Programmer
Fixing, Not Preaching
Why Blackmail Is Still Illegal
Designers Cannot Do Anything Imaginable
Wise Dr. Drew
Rats In A Too-Small Cage
Coming To Reason
Everything Isn’t Moving To the Web
Pragmatics, Not Rights
The Purpose of Language
The Punishment Defines the Crime
Two Many Cooks
One Last Splurge
What Heaven and Hell Are Really About
America — The Last Suburb
What the Cloud Isn’t For
What You’re Seeing
What My Life Needs To Be
Taking An Early Retirement
A, B, C, D, Pointless Relativity
Stephen Meyer and Michael Medved — Where Is ID Going?
If You Didn’t Vote — Complain Away
iPhone Party-Poopers Redux
What Free Will Is Really About
PTED — The P Is Silent
Out of Sync
Security Through Normalcy
The Case For Corporate Bonuses
Movie Copyrights Are Forever
Permitted By Whom?
Quantum Cognition and Other Hogwash
The Problem With Message Theory
Bell’s Boring Inequality and the Insanity of the Gaps
Paying the Rent At the 6 Park Avenue Apartments
Primary + Reviewer — An Alternative IT Plan For Corporations
Yes Yes Yes
Hey Hey Whine Whine
Microsoft About Microsoft Visual Microsoft Studio Microsoft
Hidden Purple Tiger
Forest Fair Mall and the Second Lamborghini
Intelligent Design — The Straight Dope
Maxwell’s Demon — Two Real-World Examples
Einstein’s Error — The Confusion of Laws With Their Effects
The Museum Is the Art
Polly Sooth the Air Rage
Morality = STDs?
Fulfilling the Moral Duty To Disdain
The Two Rules of Great Programming
The End of the Nerds
Poverty — Humanity’s Damage Control
Berners-Lee’s Rating System = Google
The Secret Anti-MP3 Trick In “Independent Women” and “You Sang To Me”
ID and the Large Hadron Collider Scare
Not A Bluff
The Fall of Microsoft
Life Sucks When You’re Not Winning
The Old-Fashioned Way
The Old People Who Pop Into Existence
Theodicy — A Big Stack of Papers
The Designed, Cause-and-Effect Brain
The Capitalist’s Imaginary Line
Education Isn’t Everything
I Don’t Know
Funny iPhone Party-Poopers
Avoiding Conflict At All Costs
Behavior and Free Will, Unconfused
“Reduced To” Absurdum
Suzie and Bubba Redneck — the Carriers of Intelligence
Everything You Need To Know About Haldane’s Dilemma
Darwin + Hitler = Baloney
Designed For Combat
Speed Racer R Us
Bold — Uh-huh
Conscious of Consciousness
Where Real and Yahoo Went Wrong
The Purpose of Surface
Eradicating Religion Won’t Eradicate War
A Tale of Two Movies
The Changing Face of Sam Adams
Dinesh D’Souza On ID
Why Quintic (and Higher) Polynomials Have No Algebraic Solution
Translation of Paul Graham’s Footnote To Plain English
What Happened To Moore’s Law?
Goldston On ID
The End of Martial Law
The Two Faces of Evolution
A Fine Recommendation
Free Will and Population Statistics
Dennett/D’Souza Debate — D’Souza
Dennett/D’Souza Debate — Dennett
The Non-Euclidean Geometry That Wasn’t There
Defective Attitude Towards Suburbia
The Twin Deficit Phantoms
Sleep Sync and Vertical Hold
More FUD In Your Eye
The Myth of Rubbernecking
Keeping Intelligent Design Honest
Failure of the Amiga — Not Just Mismanagement
Maxwell’s Silver Hammer = Be My Honey Do?
End Unsecured Debt
The Digits of Pi Cannot Be Sequentially Generated By A Computer Program
Faster Is Better
Goals Can’t Be Avoided
Ignoring ID Won’t Work
The Crabs and the Bucket
Communism As A Side Effect of the Transition To Capitalism
Google and Wikipedia, Revisited
National Geographic’s Obesity BS
Theodicy Is For Losers
A Memory of Gateway
Is Apple’s Font Rendering Really Non-Pixel-Aware?
Humans Are Complexity, Not Choice
A Subtle Shift
Moralism — The Emperor’s New Success
Code Is Our Friend
The Edge of Religion
The Dark Side of Pixel-Aware Font Rendering
The Futility of DVD Encryption
ID Isn’t About Size or Speed
ID Venn Diagram
Rich and Good-Looking? Why Libertarianism Goes Nowhere
FUV — Fear, Uncertainty, and Vista
Malware Isn’t About Total Control
Howard = Second Coming?
Doomsday? Or Just Another Sunday
The Real Function of Wikipedia In A Google World
Clarity From Cisco
2007 Macworld Keynote Prediction
FUZ — Fear, Uncertainty, and Zune
No Fear — The Most Important Thing About Intelligent Design
How About A Rational Theodicy
Napster and the Subscription Model
Intelligent Design — Introduction
The One Feature I Want To See In Apple’s Safari.