# Premature Optimization
> [!quote] [[Donald Knuth]]
> The real problem is that programmers have spent far too much time worrying about efficiency in the wrong places and at the wrong times; ==premature optimization is the root of all evil== (or at least most of it) in programming.
> \- Donald Knuth, [[The Art of Computer Programming]]
^7261c9
## [[Data-oriented programming]]
# [[Asymptotic Behavior]]
Asymptotic behavior and the big-O notations don't matter as much.
Don't get me wrong. This is still fundamental computer science that everyone should know. The difference between $\mathcal{O}(1), \mathcal{O}(log\ n), \mathcal{O}(n), \mathcal{O}(n\ log\ n)$ are real. However:
- Well-established data structures and algorithms offer the practically near-optimal asymptotic behaviors.
- The overhead associated with obscure data structures make them impractical.
- Example: hashmaps are ubiquitous, but as far as disk storage is concerned, sorted storage (B-Trees, LSM-trees) are king as they offer better behavior, even though they are suboptimal data structure even when ordering is not needed.
- Beyond the single machine use cases, various parallel computing constructs need to be used. These further limit the performance.
# [Amdahl's Law](https://en.wikipedia.org/wiki/Amdahl%27s_law)
> [!quote]
> 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.
This one isn't just an adage but an actual mathematical formulation.
# My Adage
> [!quote]
> #adage on performance
> Software performance and optimization doesn't matter, until it does. When it does, it matters *hard*.
# In praise of high performance software
- see: [[Rust or Go or Zig based developer tools]]
- New breed of [[Rust]] or [[Go]] based tools, especially in the realm of dynamic programming languages - `uv`, `swc` `esbuild`, ...
- Figma, with its WASM / WebGL foundation
# Gripe of low-performance software
- [[Electron]] - I don't mind an individual electron app; I can't agree with the