↓ Ir para o conteúdo principal

← todas as notas

📎 Webclip

Simple and Clean Code vs. Performance

Write readable and simple code by default. The article argues that efficiency and performance are different, that most code is not where runtime is spent, and that maintainability should come first unless profiling shows a real problem.

Reading notes
#

  • Efficiency is about doing less work, while performance is about doing work faster.
  • Before trying to squeeze more speed from code, first check whether the algorithm is efficient.
  • Most code does not matter much for total runtime, so optimizing it often has little effect.
  • If code is not a proven bottleneck, it should not be optimized for speed.
  • Programmers usually cannot predict well which code will perform best, because compilers and optimizers change a lot.
  • If performance really matters, use a profiler instead of relying on guesswork.
  • When two versions are equally readable, choose the one that probably performs better.
  • Data layout and data structures can matter more than small instruction-level changes.
  • Using well-written libraries can improve both simplicity and performance.
  • Simple code should be sacrificed for performance only as a last resort.