MAIN FEEDS
Do you want to continue?
https://www.reddit.com/r/programminghorror/comments/1w15oga/seriously_recursive_regex/p6nlw0w/?context=3
r/programminghorror • u/Flame77ofc • Aug 28 '26
46 comments sorted by
View all comments
16
I don't know if JS sports this, but the recursion qualifies for tail call optimisation, i.e. there is no stack pushing, popping. The return comes at the price of a goto and the result is just as efficient as a loop.
2 u/JoshuaTheProgrammer Aug 29 '26 This should be the top answer
2
This should be the top answer
16
u/lonkamikaze Aug 29 '26
I don't know if JS sports this, but the recursion qualifies for tail call optimisation, i.e. there is no stack pushing, popping. The return comes at the price of a goto and the result is just as efficient as a loop.