31
you are viewing a single comment's thread
view the rest of the comments
view the rest of the comments
this post was submitted on 22 Dec 2023
31 points (91.9% liked)
Programming
17314 readers
73 users here now
Welcome to the main community in programming.dev! Feel free to post anything relating to programming here!
Cross posting is strongly encouraged in the instance. If you feel your post or another person's post makes sense in another community cross post into it.
Hope you enjoy the instance!
Rules
Rules
- Follow the programming.dev instance rules
- Keep content related to programming in some way
- If you're posting long videos try to add in some form of tldr for those who don't want to watch videos
Wormhole
Follow the wormhole through a path of communities !webdev@programming.dev
founded 1 year ago
MODERATORS
When you can't reasonably use a loop or when it's not particularly important for performance and the recursive function is more readable.
Honestly, in code the absolute most important quality is readability. Readability should always be prioritized until you find performance issues that matter in a specific block of code.
On a side note: not caring about performance "until you find performance issues" is a huge problem with modern software imho. That's the reason apps are so slow, updates take so long, everything uses so much space. I'd wish that performance would always be a point of consideration, not an afterthought once there are problems.
I'd rather people err on the side of readability... senior devs should know the importance of readability but still lay decent groundwork towards performance... do things the right way when it can be simple.
Junior developers should just focus on readable code. Chances are their code will be slow, indecipherable, and wrong - I'd rather they focused on fixing the indecipherablity, the wrongness, and then the speed.
But, to sort of generally undermine my own point - no rule should be an absolute in software development - sometimes premature optimization is totally justified - you just need to use common sense.
I agree that junior devs should focus on readability, rather than focusing on everything and just getting it all wrong. but as you say, if you have more experience, performance should be a point of consideration.
I think people talking about premature optimisation are often talking about micro-optimisations. Those are almost always unnecessary until you've identified choke points. Optimising the overall architecture of the code base on the other hand, is in my opinion something that should be thought about before you even start coding. That's where the major gains can often be done anyway.