Start of main content

How to catch recursion by the tail


Converting tail recursion into a loop is a popular optimization in functional programming languages, but in the Java world, this conversion is shrouded in mystery.

Let's investigate if it's possible to replace a tail recursion call with a loop in Java; why should we do it at all; which virtual machines do it (and is it legal?). We'll also try third-party tools that can help optimize programs in a functional way. And, of course, look at JVM-friendly languages that have more pronounced functional inclinations (Scala, Kotlin, etc.). 

  • #computer-science
  • #kotlin
  • #scala
  • #compilation
  • #bytecode