BEAM vs. JVM: TCO's Core Implementation Divide

Erlang's BEAM VM inherently supports and guarantees tail-call optimization for both direct and general tail calls. In contrast, the Java Virtual Machine (JVM) generally lacks native TCO, especially for general tail calls, often due to its debugging model and stack trace requirements. This forces JVM-based languages like Scala and Clojure to use explicit annotations or special forms (e.g., `recur`) to achieve tail recursion, and still often cannot optimize mutual tail recursion.

Sources

Open the full topic