TE
TechEcho
Home24h TopNewestBestAskShowJobs
GitHubTwitter
Home

TechEcho

A tech news platform built with Next.js, providing global tech news and discussions.

GitHubTwitter

Home

HomeNewestBestAskShowJobs

Resources

HackerNews APIOriginal HackerNewsNext.js

© 2025 TechEcho. All rights reserved.

Ask HN: How prevalent is the use of recursion in production level software?

4 pointsby curious16over 2 years ago
Recursion is often portrayed as something that can crash your system if not tamed properly. But recursion is really useful to deal with naturally recursively structured data like trees and all.<p>So, is recursion widespread in real software that is used by a lot of people or is it avoided whenever possible?<p>Is it entirely dependent on the language used?

5 comments

dupedover 2 years ago
It&#x27;s extremely common.<p>Recursion only blows up if your PL has fixed size stacks and no tail call elimination. There are plenty of languages which support both, and recursion is safe.<p>Particularly with growable stacks, the alternative to recursion is to use something that has equivalent runtime characteristics as a growable stack (even making one explicitly). That&#x27;s still using recursion, it&#x27;s just explicit.<p>It is also used extensively in parsers and compilers. There&#x27;s also recursive data structures, which are also extremely common.
tus666over 2 years ago
Quite regularly in Python, despite the stack limitation.<p>Why? It&#x27;s sometimes the only elegant way to walk over small tree-like data structures, the depth of which you can be safely assured will never approach Python inbuilt limit (and if they did, it would always be a data error that should fail anyways).<p>I do wish Python had Perl-style tail-recursion though.
josephcsibleover 2 years ago
In Haskell, it&#x27;s effectively mandatory in all but the simplest programs, as there&#x27;s no other way to implement any form of looping. It&#x27;s usually done via higher-order functions like foldr rather than explicitly, though, which mitigates almost all of the danger.
jamesfinlaysonover 2 years ago
I think I&#x27;ve seen it used once or twice in my career so not common.
kstenerudover 2 years ago
Often, if the language guides people towards recursion.<p>Almost never if it doesn&#x27;t.<p>You need strong language support, otherwise you&#x27;ll be in for a world of hurt.