Clean Code vs. Performance Code: Which One Should You Choose?

preview_player
Показать описание
I prioritise readability over a fast-loading page, though I acknowledge the importance of a speedy experience. I won’t sacrifice clean and understandable code for performance optimisation unless it becomes a noticeable issue. I believe maintainable code is of higher importance than code that simply performs well, especially for a large project that requires more people to work on.

Рекомендации по теме
Комментарии
Автор

Hey dude! I’ve found your articles & channel a few days and I must say, they’ve been eye-opening and a very informative read. Keep it up!

mwebsnl
Автор

It's true that modern processors are much faster than they used to be, and this gives us some leeway with the efficiency of the code we write. It's important, however, to consider that code "cleanliness" isn't always the top priority for more performance-critical code. Improvements in CPU speed are completely wasted when so many programs these days are horribly inefficient and slow.

You have to use the right style for the right job. Code that iterates and evaluates data from a potentially very large database simply needs to run fast; cleanliness is secondary. Conversely, code that runs relatively infrequently (e.g. setup, occasional background polling, etc.) has more headroom to look pretty, but can also reduce startup performance if it gets too inefficient.

Personally, I'd argue that prioritising readability over a fast-loading page is one of the biggest problems with the modern web. The amount of CPU and memory resources many modern websites use these days is just egregious, often struggling on modern hardware, while the content provided by them hasn't fundamentally changed for decades.

maciozo
Автор

There's no right or wrong, there's only the company policy :)

jasperferrer
Автор

uhh I find the performant example is also the "clean" one for me. Breaking down functions into the smallest operations makes it unreadable to me. I think functions should do one "task" but that task can have multiple steps.

shafouingue