Laws of Programming

2025-01-04   essay programming




Programming laws are distilled wisdom from hard-earned lessons from the trenches. They provide a powerful shorthand for hackers to avoid the same mistakes that have been made time and time again. I’ve grouped them by topic below, and prioritized by how much they’ve saved me from wasted effort.


Avoid early optimization


Iterate fast, launch early

  • Boyd’s Law of iteration: speed of iteration beats quality of iteration.

  • LeBlanc’s Law: later equals never

  • Third Rule of Unix Philosophy: Design and build software, even operating systems, to be tried early, ideally within weeks. Don't hesitate to throw away the clumsy parts and rebuild them.

  • Gall’s Law: A complex system that works is invariably found to have evolved from a simple system that worked. The inverse proposition also appears to be true: A complex system designed from scratch never works and cannot be made to work. You have to start over, beginning with a working simple system.


Done is better than perfect


Keep it stupidly simple


Have an eyesight on complexity

  • Lehman’s Law of increasing complexity: Complexity grows unless work is done to reduce it.

  • Second-System Effect: tendency of small, elegant, and successful systems to be succeeded by over-engineered, bloated systems, due to inflated expectations and overconfidence

  • Zawinski’s Law: Every program attempts to expand until it can read mail.

  • Scope Creep: The gradual expansion of a project’s goals and tasks beyond its original objectives

  • Brian W. Kernighan–“Controlling complexity is the essence of computer programming”


Expect it to take longer than expected

  • The 90-90 Rule: The first 90% of code accounts for 90% of the development time; the last 10% takes another 90% of the time.

  • Hofstadter’s Law: It always takes longer than you expect, even when you account for Hofstadter’s Law.


Design well


Think your code as lego pieces––Composability


Be intuitive


Data model > algorithms

  • Linus Torvalds: "Bad programmers worry about the code. Good programmers worry about data structures and their relationships."

  • Rob Pikes: "Data dominates. If you've chosen the right data structures and organized things well, the algorithms will almost always be self-evident. Data structures, not algorithms, are central to programming."

  • Eric Raymond (in The Cathedral and the Bazaar)––“Smart data structures and dumb code work a lot better than the other way around.“


Debugging

  • Fail Fast Principle: Crash early when something goes wrong. It's better to face problems head-on than let them fester.

  • Linus’s Law: Given enough eyeballs, all bugs are shallow

  • Murphy’s Law: Anything that can go wrong will go wrong. Write your code to expect failure, not sunshine and rainbows.


Profiling: Look for the bottlenecks

  • Amdahl’s Law: the overall performance improvement gained by optimizing a single part of a system is limited by the fraction of time that the improved part is actually used

  • Liebig’s Law of the Minimum: growth is dictated not by total resources available, but by the scarcest resource


Trust the old

  • Lindy Effect: Code that's been around for a while is likely stable. Don't mess with it unless you have a good reason.

  • Chesterton’s Fence: Before you remove or refactor code, make sure you understand why it was there in the first place. Deleting unknowns invites new bugs.




[This article is mirrored at mirror.xyz]





Incoming Internal References (0)

Outgoing Internal References (6)
  1. - [Kent Beck](https://www.martinfowler.com/bliki/BeckDesignRules.html)––“Make it run, then make it right, then make it fast.”
    - [[Kent Beck]]
    - [YAGNI (You Aren’t Gonna Need It)](https://en.wikipedia.org/wiki/You_aren%27t_gonna_need_it): Don’t implement functionality until it’s necessary.
  2. - [Boyd’s Law of iteration](https://blog.codinghorror.com/boyds-law-of-iteration/): speed of iteration beats quality of iteration.
    - [[John Boyd]]
    - [LeBlanc’s Law](https://yiming.dev/clipping/2019/03/21/le-blanc's-law-a-k-a-later-equals-never/): later equals never
  3. - [Gall’s Law](http://principles-wiki.net/principles:gall_s_law): A complex system that works is invariably found to have evolved from a simple system that worked. The inverse proposition also appears to be true: A complex system designed from scratch never works and cannot be made to work. You have to start over, beginning with a working simple system.
    - [[John Gall]]
  4. - [Hoare’s Law of Large Programs](http://www.robelle.com/smugbook/laws.html#:~:text=Hoare's%20Law%20of%20Large%20Programs,program%20struggling%20to%20get%20out.): inside every large program is a small program struggling to get out.
    - [[Tony Hoare]]
    - [KISS (Keep It Simple, Stupid)](https://en.wikipedia.org/wiki/KISS_principle): Simple solutions are better; avoid unnecessary complexity.
  5. - [KISS (Keep It Simple, Stupid)](https://en.wikipedia.org/wiki/KISS_principle): Simple solutions are better; avoid unnecessary complexity.
    - [Einstein](https://en.wikipedia.org/wiki/Albert_Einstein)––“[[Everything should be made as simple as possible, but not simpler]]
    - [Antoine de Saint-Exupéry](https://en.wikipedia.org/wiki/Antoine_de_Saint-Exup%C3%A9ry)––“Perfection (in design) is achieved not when there is nothing more to add, but rather when there is nothing more to take away.“
  6. - [Scope Creep](https://en.wikipedia.org/wiki/Scope_creep): The gradual expansion of a project’s goals and tasks beyond its original objectives
    - [[Brian W. Kernighan]]–“Controlling complexity is the essence of computer programming”

Outgoing Web References (42)
  1. www.youtube.com/watch?v=74RdET79q40
    • Knuth's Optimization Principle
  2. www.martinfowler.com/bliki/BeckDesignRules.html
    • Kent Beck
  3. en.wikipedia.org/wiki/You_aren%27t_gonna_need_it
    • YAGNI (You Aren’t Gonna Need It)
  4. blog.codinghorror.com/boyds-law-of-iteration
    • Boyd’s Law of iteration
  5. yiming.dev/clipping/2019/03/21/le-blanc's-law-a-k-a-later-equals-never
    • LeBlanc’s Law
  6. en.wikipedia.org/wiki/Unix_philosophy
    • Third Rule of Unix Philosophy
  7. rinciples-wiki.net/principles:gall_s_law
    • Gall’s Law
  8. www.reddit.com/r/productivity/comments/q2o1ud/done_is_better_than_perfect
    • Done is better than perfect
  9. en.wikipedia.org/wiki/Worse_is_better
    • Worse is Better:
  10. www.laws-of-software.com/laws/kernighan
    • Kernighan's Law
  11. www.robelle.com/smugbook/laws.html#:~:text=Hoare's%20Law%20of%20Large%20Programs,program%20struggling%20to%20get%20out.
    • Hoare’s Law of Large Programs
  12. en.wikipedia.org/wiki/KISS_principle
    • KISS (Keep It Simple, Stupid)
  13. en.wikipedia.org/wiki/Albert_Einstein
    • Einstein
  14. en.wikipedia.org/wiki/Antoine_de_Saint-Exup%C3%A9ry
    • Antoine de Saint-Exupéry
  15. en.wikipedia.org/wiki/Lehman%27s_laws_of_software_evolution#:~:text=\(1974\
    • Lehman’s Law of increasing complexity
  16. en.wikipedia.org/wiki/Second-system_effect
    • Second-System Effect
  17. en.wikipedia.org/wiki/Jamie_Zawinski#:~:text=Zawinski's%20Law%20of%20Software%20Envelopment,replaced%20by%20ones%20which%20can.
    • Zawinski’s Law
  18. en.wikipedia.org/wiki/Scope_creep
    • Scope Creep
  19. en.wikipedia.org/wiki/Ninety%E2%80%93ninety_rule
    • The 90-90 Rule
  20. en.wikipedia.org/wiki/Hofstadter%27s_law
    • Hofstadter’s Law
  21. en.wikipedia.org/wiki/Unix_philosophy
    • First Rule of Unix Philosophy
  22. en.wikipedia.org/wiki/Single-responsibility_principle
    • Single Responsibility Principle
  23. en.wikipedia.org/wiki/Robustness_principle
    • Postel’s law (robustness principle)
  24. en.wikipedia.org/wiki/Separation_of_concerns
    • Separation of Concerns
  25. rinciples-wiki.net/principles:principle_of_separate_understandability
    • Separate Understandability Principle
  26. en.wikipedia.org/wiki/Loose_coupling
    • Loose Coupling
  27. en.wikipedia.org/wiki/Law_of_Demeter
    • Law of Demeter (Principle of Least Knowledge)
  28. cdixon.mirror.xyz/Ie8BQeiM1JTJkKISPVaAao88-XVMoHsdUAtcnS9_Jbs
    • Composability enables compounding
  29. en.wikipedia.org/wiki/Don%27t_Make_Me_Think
    • Don't Make Me Think
  30. en.wikipedia.org/wiki/Principle_of_least_astonishment#:~:text=In%20user%20interface%20design%20and,not%20astonish%20or%20surprise%20users.
    • Principle of Least Astonishment
  31. en.wikipedia.org/wiki/Self-documenting_code#:~:text=Self%2Ddocumenting%20code%20is%20ostensibly,symbol's%20meaning%2C%20such%20as%20article.
    • Self-documenting code
  32. en.wikipedia.org/wiki/Linus_Torvalds
    • Linus Torvalds
  33. en.wikipedia.org/wiki/Rob_Pike
    • Rob Pikes
  34. www.catb.org/esr
    • Eric Raymond
  35. en.wikipedia.org/wiki/Fail-fast_system#:~:text=Fail%2Dfast%20architectures%20are%20based,in%20a%20fault%2Dtolerant%20system.
    • Fail Fast Principle:
  36. en.wikipedia.org/wiki/Linus%27s_law#:~:text=In%20software%20development%2C%20Linus's%20law,in%20honor%20of%20Linus%20Torvalds.
    • Linus’s Law
  37. en.wikipedia.org/wiki/Murphy%27s_law
    • Murphy’s Law
  38. en.wikipedia.org/wiki/Amdahl%27s_law
    • Amdahl’s Law:
  39. en.wikipedia.org/wiki/Liebig%27s_law_of_the_minimum
    • Liebig’s Law of the Minimum
  40. en.wikipedia.org/wiki/Lindy_effect
    • Lindy Effect
  41. en.wikipedia.org/wiki/G._K._Chesterton
    • Chesterton’s Fence
  42. mirror.xyz/0xA9C3cc3BeacF8Dd77DDB9349523892FA0f026403/kKVFPbxntm_-rfcgTsMPMkKwg_Jt1xAsoTlGoXYxLcs
    • This article is mirrored at [mirror.xyz

Receive my updates

Barış Özmen © 2025