[0] https://stackoverflow.blog/2021/04/19/how-often-do-people-ac...
[0] https://stackoverflow.blog/2021/04/19/how-often-do-people-ac...
Do the first thing that works, don't overthink it.
In my opinion, the bottom line with obvious caveats is this - Human-time is more valuable than CPU-time.
If you are shipping at scale then the calculus is different - Don't waste end-users' human-time and their cpu-time and/or server's cpu-time.
If you're writing code with a team the calculus is different - Use/Learn techniques and tools to reduce the teams' human-time wastage plus all the above.
If you're writing code just for yourself the calculus is different - Save your own human-time.
I had a few of these cases in my life:
- discovering optimized patterns in Perl, which led to code I could not understand the next day
- discovering decorators in Python, which led to better code
- discovering comprehensions in Python (a magical thing) that led to better code, except when I wanted to be too clever and ended up with Perl-like code
Humans writing code is suboptimal. I can't wait for the day when robots/AI do it for us. I just hope it leads to a utopia and not a dystopia.