DigiNews

Tech Watch by Johan Denoyer

← Back to articles

"Clean" Code, Horrible Performance (2023)

Quality: 8/10 Relevance: 8/10

Summary

The post argues that popular 'clean code' guidelines harm performance. Through concrete C++ examples comparing a polymorphic class hierarchy versus a flat, switch-based or table-driven approach, it demonstrates large performance gains from dropping some 'clean' rules. The author shows initial ~35 cycles per shape with polymorphism, then 24 cycles with a switch, and up to 3-4x faster with table-driven approaches, culminating in a claim that optimizing for runtime can justify deviating from 'clean code' prescriptions and that four of five 'clean' rules can be detrimental to performance. The piece advocates performance-aware programming and suggests using profiling-driven design instead of rigid orthodoxy.

🚀 Service construit par Johan Denoyer