3 ms·
The sum of these rules seem to imply that it's difficult to theoretically model programming, so always wait for your program to be fully written so you can perf
by threatofrain 9y ago
The sum of these rules seem to imply that it's difficult to theoretically model programming, so always wait for your program to be fully written so you can perform some brute force empiricism -- and only then think about performance.
- eternalban 9y agoIt is not true that you can not "theoretically" (read: based on formal reasoning) model program performance. You don't need to run a program to determine that an O(n^2) approach will be slower than an O(log n) algorithm. You do not need to run a program to determine the impact of optimizing a bit of your para code; you can get fairly good sense using Amdahl's law. Etc. Like his creation, the Go language, Rob Pike's rules are somewhat condescending and patronizing those he deems as lesser programmers. Rule 3, however, is the exception. That is the take away gem based on experience.
- inimino 9y ago> You don't need to run a program to determine that an O(n^2) approach will be slower than an O(log n) algorithm. That depends on N and on the constant factors. Which means testing still might surprise you. More to the point, if the O(n^2) algorithm is simpler and leaves you more time for profiling and fixing actual performance issues after the code works, you may end up with faster code by doing the dumb thing.
- yeukhon 9y agoCan you define "theoretically model programming"? He doesn't imply that from what I read. He simply said be empirical and practical. Let data (inputs and what you measure) speaks for itself. This is like the simplified version of scientific method in the context of programming.