this post was submitted on 22 Dec 2023
0 points (NaN% liked)

Programming

17278 readers
280 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
top 6 comments
sorted by: hot top controversial new old
[–] morphballganon@lemmy.world 0 points 10 months ago (1 children)

One of my big takeaways from CS classes was that goto loops are more efficient than for loops. So I'd start with comparing that with a recursive function.

[–] Knusper@feddit.de 0 points 10 months ago

Any reasonable compiler should effectively transform them to be the same. (At the assembly level, a for-loop just uses a jump instruction, which is also what a goto effectively is.)

[–] xmunk@sh.itjust.works 0 points 10 months ago (1 children)

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.

[–] xxd@discuss.tchncs.de 0 points 10 months ago (2 children)

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.

[–] Knusper@feddit.de 0 points 10 months ago

I feel like lots of people assumed that performance would solve itself. Hardware continuously gets faster, but even in 2023, you can usually tell that something has been implemented in Python, NodeJS, JVM languages etc., even if it's relatively well-optimized.

The responsiveness of C/C++, Rust etc. is still noticeably better, often without really having to optimize your application code.

[–] Diplomjodler@feddit.de 0 points 10 months ago

Those performance issues should obviously be found in testing, not after you shipped stuff. Also, if you have readable code, tuning it for performance will be much easier than fixing something that runs fast but nobody understands.