Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add the 3 maxims? #13

Open
joyrexus opened this issue Dec 3, 2014 · 0 comments
Open

Add the 3 maxims? #13

joyrexus opened this issue Dec 3, 2014 · 0 comments

Comments

@joyrexus
Copy link

joyrexus commented Dec 3, 2014

The following 3 maxims are attributed to Tony Hoare, Ken Thompson, and Fred Brooks, respectively. The 5 rules (distributed under the maxims) are attributed to Rob Pike.


Premature optimization is the root of all evil

You can't tell where a program is going to spend its time. Bottlenecks occur in surprising places, so don't try to second guess and put in a speed hack until you've proven that's where the bottleneck is.

Measure. Don't tune for speed until you've measured, and even then don't unless one part of the code overwhelms the rest.

When in doubt, use brute force

Fancy algorithms are slow when n is small, and n is usually small. Fancy algorithms have big constants. Until you know that n is frequently going to be big, don't get fancy. (Even if n does get big, use Rule 2 first.)

Fancy algorithms are buggier than simple ones, and they're much harder to implement. Use simple algorithms as well as simple data structures.

Write stupid code that uses smart objects

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant