jackpot@lemmy.ml to Programming · 11 months agowhen is it best to use a recursive function vs a for loopmessage-squaremessage-square52fedilinkarrow-up134arrow-down13
arrow-up131arrow-down1message-squarewhen is it best to use a recursive function vs a for loopjackpot@lemmy.ml to Programming · 11 months agomessage-square52fedilink
minus-squareLmaydevlinkfedilinkarrow-up9·edit-211 months agoGotos are generally avoided wherever possible in modern programming. They make the code a lot harder to read and reason about. With modern compilers I seriously doubt there’s a huge difference. But generally you want your code to be readable first and optimised where needed. https://stackoverflow.com/questions/2288856/when-implementing-an-infinite-loop-is-there-a-difference-in-using-while1-vs-f/2288893#2288893
Gotos are generally avoided wherever possible in modern programming.
They make the code a lot harder to read and reason about.
With modern compilers I seriously doubt there’s a huge difference.
But generally you want your code to be readable first and optimised where needed.
https://stackoverflow.com/questions/2288856/when-implementing-an-infinite-loop-is-there-a-difference-in-using-while1-vs-f/2288893#2288893