Thanks, I'll definitely look into that,. I was hop...
# random
a
Thanks, I'll definitely look into that,. I was hoping see if anyone knew about how the Kotlin language structures itself around recursion in general
g
what is “recursion in general”?
a
lol
I'm sure you're familiar with recursion - what I'm trying to find out is whether recursion is also treated as an afterthought in Kotlin like it is in Java.
the question is directed at someone who may have been involved in creating the language or worked with the language itself
or maybe asked a similar question at some point?
g
Why recursion is “afterthought” in java? Because of lack of tail recursion?
a

https://www.youtube.com/watch?v=2y5Pv4yN0b0&t=1h02m18s

<-- background
Java executes their program with stacks and because Java is more conservative on the security end, the initial implementation for tail recursion caused a break with the stack count. Hence, tail recursion now "eventually gets done"
I personally think it's a funny reason, but I'm curious to know if Kotlin development ever looked into a similar issue and if it's possible to execute true recursion (although my suspicion is "no" bc of JVM)
g
Kotlin runs on JVM on the same stack
But there is compiler optimization for tail recursion (if you mark it explicitly)
👍 1
implementation for tail recursion caused a break with the stack count
In other words, java doesn’t have tail recursion. Kotlin have, if you explicitly marked your function with tailrec
👍 1
To be honest I don’t think that this is something really important. Yeah, it’s nice to have. But in case of kotlin it’s completely compiler thing, just convert tail recursion to something like while loop, you can do that manually if you want
a
Hey @gildor thank you so much! Appreciate it. And you're absolutely right, it is definitely not important, but for the work I'm doing it is absolutely worth looking into. It may not matter in the end, but for this upcoming project I am looking into whether it might be possible for me to leverage recursion optimization