# Recursion in Julia — bad idea?

**URL:** <https://discourse.julialang.org/t/recursion-in-julia-bad-idea/99304>\
**Category:** Performance\
**Tags:** recursion\
**Created:** [May 23, 2023, 9:16pm UTC](https://discourse.julialang.org/t/recursion-in-julia-bad-idea/99304 "2023-05-23T21:16:58Z")\
**Posts on this page:** 1\
**Showing post:** 2

<div class="post-metadata">

**Author:** ![Oscar\_Smith](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/oscar_smith/32/25343_2.png) [@Oscar\_Smith](https://discourse.julialang.org/u/Oscar_Smith)\
**Post date:** [May 23, 2023, 9:27pm UTC](https://discourse.julialang.org/t/recursion-in-julia-bad-idea/99304/2 "2023-05-23T21:27:57Z")

</div>

It’s not so much that Julia is the wrong tool, but that recursion in Julia is the wrong tool. You can always rewrite your recursion by pushing and popping from a stack, and you know better than the compiler what data you care about. With the recursive solution, the compiler needs to keep around a bunch of extra information about what functions were called in order for `return` to go to the right place.

---

_[View the full topic](https://discourse.julialang.org/t/recursion-in-julia-bad-idea/99304)._
